// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react' import {FormattedMessage, useIntl} from 'react-intl' import {Constants} from '../../constants' import {IPropertyTemplate} from '../../blocks/board' import {BoardView} from '../../blocks/boardView' import mutator from '../../mutator' import Button from '../../widgets/buttons/button' import Menu from '../../widgets/menu' import MenuWrapper from '../../widgets/menuWrapper' type Props = { properties: readonly IPropertyTemplate[] activeView: BoardView } const ViewHeaderPropertiesMenu = (props: Props) => { const {properties, activeView} = props const intl = useIntl() const {viewType, visiblePropertyIds} = activeView.fields const canShowBadges = viewType === 'board' || viewType === 'gallery' || viewType === 'calendar' const toggleVisibility = (propertyId: string) => { let newVisiblePropertyIds = [] if (visiblePropertyIds.includes(propertyId)) { newVisiblePropertyIds = visiblePropertyIds.filter((o: string) => o !== propertyId) } else { newVisiblePropertyIds = [...visiblePropertyIds, propertyId] } mutator.changeViewVisibleProperties(activeView.boardId, activeView.id, visiblePropertyIds, newVisiblePropertyIds) } return ( {activeView.fields.viewType === 'gallery' && } {properties?.map((option: IPropertyTemplate) => ( ))} {canShowBadges && } ) } export default React.memo(ViewHeaderPropertiesMenu)