generated from mattermost/mattermost-plugin-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add todo button on team sidebar (#54)
* Add todo button on team sidebar Buttons are - Your todos, requested todos, assigned todos, refresh Resolves issue #24 * Fix lint errors * Open correct RHS state on todo button click Change icons Fix bugs * Remove the unnecessary componentDidUpdate function * remove refresh button * add websocket reconnect handler Co-authored-by: mattermod <[email protected]>
- Loading branch information
Showing
11 changed files
with
236 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {connect} from 'react-redux'; | ||
import {bindActionCreators} from 'redux'; | ||
|
||
import {list, updateRhsState} from '../../actions'; | ||
|
||
import SidebarButtons from './sidebar_buttons.jsx'; | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
issues: state['plugins-com.mattermost.plugin-todo'].issues, | ||
inIssues: state['plugins-com.mattermost.plugin-todo'].inIssues, | ||
outIssues: state['plugins-com.mattermost.plugin-todo'].outIssues, | ||
showRHSPlugin: state['plugins-com.mattermost.plugin-todo'].rhsPluginAction, | ||
}; | ||
} | ||
|
||
function mapDispatchToProps(dispatch) { | ||
return { | ||
actions: bindActionCreators({ | ||
list, | ||
updateRhsState, | ||
}, dispatch), | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(SidebarButtons); |
125 changes: 125 additions & 0 deletions
125
webapp/src/components/sidebar_buttons/sidebar_buttons.jsx
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,125 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
import {Tooltip, OverlayTrigger} from 'react-bootstrap'; | ||
import PropTypes from 'prop-types'; | ||
import {makeStyleFromTheme, changeOpacity} from 'mattermost-redux/utils/theme_utils'; | ||
|
||
import {RHSStates} from '../../constants'; | ||
|
||
export default class SidebarButtons extends React.PureComponent { | ||
static propTypes = { | ||
theme: PropTypes.object.isRequired, | ||
isTeamSidebar: PropTypes.bool, | ||
showRHSPlugin: PropTypes.func.isRequired, | ||
issues: PropTypes.arrayOf(PropTypes.object), | ||
inIssues: PropTypes.arrayOf(PropTypes.object), | ||
outIssues: PropTypes.arrayOf(PropTypes.object), | ||
actions: PropTypes.shape({ | ||
list: PropTypes.func.isRequired, | ||
updateRhsState: PropTypes.func.isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
refreshing: false, | ||
}; | ||
} | ||
|
||
openRHS = (rhsState) => { | ||
this.props.actions.updateRhsState(rhsState); | ||
this.props.showRHSPlugin(); | ||
} | ||
|
||
render() { | ||
const style = getStyle(this.props.theme); | ||
const isTeamSidebar = this.props.isTeamSidebar; | ||
|
||
let container = style.containerHeader; | ||
let button = style.buttonHeader; | ||
let placement = 'bottom'; | ||
if (isTeamSidebar) { | ||
placement = 'right'; | ||
button = style.buttonTeam; | ||
container = style.containerTeam; | ||
} | ||
|
||
const issues = this.props.issues || []; | ||
const inIssues = this.props.inIssues || []; | ||
const outIssues = this.props.outIssues || []; | ||
|
||
return ( | ||
<div style={container}> | ||
<OverlayTrigger | ||
key='myTodosLink' | ||
placement={placement} | ||
overlay={<Tooltip id='myTodosTooltip'>{'Your Todos'}</Tooltip>} | ||
> | ||
<a | ||
style={button} | ||
onClick={() => this.openRHS(RHSStates.InListName)} | ||
> | ||
<i className='icon icon-check'/> | ||
{' ' + issues.length} | ||
</a> | ||
</OverlayTrigger> | ||
<OverlayTrigger | ||
key='incomingTodosLink' | ||
placement={placement} | ||
overlay={<Tooltip id='incomingTodosTooltip'>{'Incoming Todos'}</Tooltip>} | ||
> | ||
<a | ||
onClick={() => this.openRHS(RHSStates.InListName)} | ||
style={button} | ||
> | ||
<i className='icon icon-arrow-down'/> | ||
{' ' + inIssues.length} | ||
</a> | ||
</OverlayTrigger> | ||
<OverlayTrigger | ||
key='outgoingTodosLink' | ||
placement={placement} | ||
overlay={<Tooltip id='outgoingTodosTooltip'>{'Outgoing Todos'}</Tooltip>} | ||
> | ||
<a | ||
onClick={() => this.openRHS(RHSStates.OutListName)} | ||
style={button} | ||
> | ||
<i className='icon icon-arrow-up'/> | ||
{' ' + outIssues.length} | ||
</a> | ||
</OverlayTrigger> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const getStyle = makeStyleFromTheme((theme) => { | ||
return { | ||
buttonTeam: { | ||
color: changeOpacity(theme.sidebarText, 0.6), | ||
display: 'block', | ||
marginBottom: '10px', | ||
width: '100%', | ||
}, | ||
buttonHeader: { | ||
color: changeOpacity(theme.sidebarText, 0.6), | ||
textAlign: 'center', | ||
cursor: 'pointer', | ||
}, | ||
containerHeader: { | ||
marginTop: '10px', | ||
marginBottom: '5px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'space-around', | ||
padding: '0 10px', | ||
}, | ||
containerTeam: { | ||
}, | ||
}; | ||
}); |
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,15 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {connect} from 'react-redux'; | ||
|
||
import TeamSidebar from './team_sidebar.jsx'; | ||
|
||
function mapStateToProps(state) { | ||
const members = state.entities.teams.myMembers || {}; | ||
return { | ||
show: Object.keys(members).length > 1, | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(TeamSidebar); |
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,27 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import SidebarButtons from '../sidebar_buttons'; | ||
|
||
export default class TeamSidebar extends React.PureComponent { | ||
static propTypes = { | ||
show: PropTypes.bool.isRequired, | ||
theme: PropTypes.object.isRequired, | ||
}; | ||
|
||
render() { | ||
if (!this.props.show) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<SidebarButtons | ||
theme={this.props.theme} | ||
isTeamSidebar={true} | ||
/> | ||
); | ||
} | ||
} |
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