diff --git a/webapp/src/components/viewHeader/viewHeader.tsx b/webapp/src/components/viewHeader/viewHeader.tsx index 0fcde2ef6..dc9f97462 100644 --- a/webapp/src/components/viewHeader/viewHeader.tsx +++ b/webapp/src/components/viewHeader/viewHeader.tsx @@ -1,6 +1,6 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React from 'react' +import React, {useState} from 'react' import {FormattedMessage} from 'react-intl' import ViewMenu from '../../components/viewMenu' @@ -36,133 +36,112 @@ type Props = { readonly: boolean } -type State = { - showFilter: boolean -} +const ViewHeader = React.memo((props: Props) => { + const [showFilter, setShowFilter] = useState(false) -class ViewHeader extends React.Component { - shouldComponentUpdate(): boolean { - return true - } + const {boardTree, showView, withGroupBy} = props + const {board, activeView} = boardTree - constructor(props: Props) { - super(props) - this.state = {showFilter: false} - } + const hasFilter = activeView.filter && activeView.filter.filters?.length > 0 - render(): JSX.Element { - const {boardTree, showView, withGroupBy} = this.props - const {board, activeView} = boardTree - - const hasFilter = activeView.filter && activeView.filter.filters?.length > 0 - - return ( -
- { - mutator.changeTitle(activeView, text) - }} - readonly={this.props.readonly} + return ( +
+ { + mutator.changeTitle(activeView, text) + }} + readonly={props.readonly} + /> + + }/> + - - }/> - + +
+ + {!props.readonly && + <> + {/* Card properties */} + + + + {/* Group by */} + + {withGroupBy && + } + + {/* Filter */} + + + + {showFilter && + - + onClose={() => setShowFilter(false)} + />} + -
+ {/* Sort */} - {!this.props.readonly && - <> - {/* Card properties */} + + + } - + {/* Search */} - {/* Group by */} + - {withGroupBy && - } + {/* Options menu */} - {/* Filter */} - - - - {this.state.showFilter && - } - - - {/* Sort */} - - - - } - - {/* Search */} - - + - {/* Options menu */} + {/* New card button */} - {!this.props.readonly && - <> - - - {/* New card button */} - - - - } -
- ) - } - - private showFilterDialog = () => { - this.setState({showFilter: true}) - } - - private hideFilterDialog = () => { - this.setState({showFilter: false}) - } -} + + + } +
+ ) +}) export default ViewHeader