This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-10017] Plugin framework: add support for plugins to override righ…
…t-hand sidebar (#2827) * Added support for plugins to override right-hand sidebar [MM-10017](mattermost/mattermost#10169) * Updated and added RHS tests for plugin case * Removed unused props for RHS Plugin component * Changed plugin export to export RHS action. Added pluginId to Pluggable component to support showing only one when multiple of the same components are registered. * Return the RHS action from the registry function * Changed RHS registry to return the showRHSPlugin action with plugin id already set. Title passed to RHS registry changed to support string or JSX element. * Fixed id to check for which pluggable component to show
- Loading branch information
1 parent
ef540eb
commit 4454b53
Showing
13 changed files
with
209 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {connect} from 'react-redux'; | ||
|
||
import {getPluginId} from 'selectors/rhs'; | ||
|
||
import RHSPlugin from './rhs_plugin.jsx'; | ||
|
||
function mapStateToProps(state) { | ||
const rhsPlugins = state.plugins.components.RightHandSidebarComponent; | ||
const pluginId = getPluginId(state); | ||
|
||
const pluginName = rhsPlugins.find((element) => element.id === pluginId).title; | ||
|
||
return { | ||
title: pluginName, | ||
pluggableId: pluginId, | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(RHSPlugin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import SearchResultsHeader from 'components/search_results_header'; | ||
|
||
import Pluggable from 'plugins/pluggable'; | ||
|
||
export default class RhsPlugin extends React.PureComponent { | ||
static propTypes = { | ||
title: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.object, | ||
]), | ||
pluggableId: PropTypes.string.isRequired, | ||
} | ||
|
||
render() { | ||
return ( | ||
<div | ||
id='rhsContainer' | ||
className='sidebar-right__body' | ||
ref='sidebarbody' | ||
> | ||
<SearchResultsHeader> | ||
{this.props.title} | ||
</SearchResultsHeader> | ||
<Pluggable | ||
pluggableName='RightHandSidebarComponent' | ||
pluggableId={this.props.pluggableId} | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.