// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // import React, {FC} from 'react' import {injectIntl, IntlShape} from 'react-intl' import {Constants} from '../constants' import mutator from '../mutator' import {BoardTree} from '../viewModel/boardTree' import Menu from '../widgets/menu' type Props = { templateId: string boardTree: BoardTree intl: IntlShape } const TableHeaderMenu: FC = (props: Props): JSX.Element => { const {boardTree, templateId, intl} = props const {board, activeView} = boardTree return ( mutator.changeViewSortOptions(activeView, [{propertyId: templateId, reversed: false}])} /> mutator.changeViewSortOptions(activeView, [{propertyId: templateId, reversed: true}])} /> { if (props.templateId === Constants.titleColumnId) { // TODO: Handle name column } else { const index = board.cardProperties.findIndex((o) => o.id === templateId) mutator.insertPropertyTemplate(boardTree, index) } }} /> { if (templateId === Constants.titleColumnId) { // TODO: Handle title column } else { const index = board.cardProperties.findIndex((o) => o.id === templateId) + 1 mutator.insertPropertyTemplate(boardTree, index) } }} /> {props.templateId !== Constants.titleColumnId && <> mutator.changeViewVisibleProperties(activeView, activeView.visiblePropertyIds.filter((o) => o !== templateId))} /> mutator.duplicatePropertyTemplate(boardTree, templateId)} /> mutator.deleteProperty(boardTree, templateId)} /> } ) } export default injectIntl(TableHeaderMenu)