diff --git a/webapp/src/components/cardDetail/cardDetail.tsx b/webapp/src/components/cardDetail/cardDetail.tsx index 9cc811795..72f78ed82 100644 --- a/webapp/src/components/cardDetail/cardDetail.tsx +++ b/webapp/src/components/cardDetail/cardDetail.tsx @@ -5,7 +5,6 @@ import {FormattedMessage, injectIntl, IntlShape} from 'react-intl' import {BlockIcons} from '../../blockIcons' import {BlockTypes} from '../../blocks/block' -import {PropertyType} from '../../blocks/board' import mutator from '../../mutator' import {Utils} from '../../utils' import {BoardTree} from '../../viewModel/boardTree' @@ -15,14 +14,13 @@ import Editable from '../../widgets/editable' import EmojiIcon from '../../widgets/icons/emoji' import Menu from '../../widgets/menu' import MenuWrapper from '../../widgets/menuWrapper' -import PropertyMenu from '../../widgets/propertyMenu' import BlockIconSelector from '../blockIconSelector' import CommentsList from '../commentsList' import {ContentHandler, contentRegistry} from '../content/contentRegistry' -import PropertyValueElement from '../propertyValueElement' import CardDetailContents from './cardDetailContents' +import CardDetailProperties from './cardDetailProperties' import './cardDetail.scss' @@ -120,55 +118,11 @@ class CardDetail extends React.Component { {/* Property list */} -
- {board.cardProperties.map((propertyTemplate) => { - const propertyValue = card.properties[propertyTemplate.id] - return ( -
- {this.props.readonly &&
{propertyTemplate.name}
} - {!this.props.readonly && - -
- mutator.renameProperty(board, propertyTemplate.id, newName)} - onTypeChanged={(newType: PropertyType) => mutator.changePropertyType(boardTree, propertyTemplate, newType)} - onDelete={(id: string) => mutator.deleteProperty(boardTree, id)} - /> -
- } - -
- ) - })} - - {!this.props.readonly && -
- -
- } -
+ {/* Comments */} diff --git a/webapp/src/components/cardDetail/cardDetailProperties.tsx b/webapp/src/components/cardDetail/cardDetailProperties.tsx new file mode 100644 index 000000000..607e9003f --- /dev/null +++ b/webapp/src/components/cardDetail/cardDetailProperties.tsx @@ -0,0 +1,80 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. +import React from 'react' +import {FormattedMessage} from 'react-intl' + +import {PropertyType} from '../../blocks/board' +import mutator from '../../mutator' +import {BoardTree} from '../../viewModel/boardTree' +import {CardTree} from '../../viewModel/cardTree' +import Button from '../../widgets/buttons/button' +import MenuWrapper from '../../widgets/menuWrapper' +import PropertyMenu from '../../widgets/propertyMenu' + +import PropertyValueElement from '../propertyValueElement' + +type Props = { + boardTree: BoardTree + cardTree: CardTree + readonly: boolean +} + +const CardDetailProperties = React.memo((props: Props) => { + const {boardTree, cardTree} = props + const {board} = boardTree + const {card} = cardTree + + return ( +
+ {board.cardProperties.map((propertyTemplate) => { + const propertyValue = card.properties[propertyTemplate.id] + return ( +
+ {props.readonly &&
{propertyTemplate.name}
} + {!props.readonly && + +
+ mutator.renameProperty(board, propertyTemplate.id, newName)} + onTypeChanged={(newType: PropertyType) => mutator.changePropertyType(boardTree, propertyTemplate, newType)} + onDelete={(id: string) => mutator.deleteProperty(boardTree, id)} + /> +
+ } + +
+ ) + })} + + {!props.readonly && +
+ +
+ } +
+ ) +}) + +export default CardDetailProperties