From 0e89d9be1d6a2a1ca470f9ca92e0d59e5945ca18 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Thu, 15 Jun 2017 07:45:46 +0800 Subject: create DotMenu components and add dotmenu IDs to posts at center and RHS (#6642) --- webapp/components/dot_menu/dot_menu_flag.jsx | 70 ++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 webapp/components/dot_menu/dot_menu_flag.jsx (limited to 'webapp/components/dot_menu/dot_menu_flag.jsx') diff --git a/webapp/components/dot_menu/dot_menu_flag.jsx b/webapp/components/dot_menu/dot_menu_flag.jsx new file mode 100644 index 000000000..105363211 --- /dev/null +++ b/webapp/components/dot_menu/dot_menu_flag.jsx @@ -0,0 +1,70 @@ +// 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 PropTypes from 'prop-types'; + +import {flagPost, unflagPost} from 'actions/post_actions.jsx'; +import * as Utils from 'utils/utils.jsx'; +import Constants from 'utils/constants.jsx'; + +function formatMessage(isFlagged) { + return ( + + ); +} + +export default function DotMenuFlag(props) { + function onFlagPost(e) { + e.preventDefault(); + flagPost(props.postId); + } + + function onUnflagPost(e) { + e.preventDefault(); + unflagPost(props.postId); + } + + const flagFunc = props.isFlagged ? onUnflagPost : onFlagPost; + + let flagId = null; + if (props.idCount > -1) { + flagId = Utils.createSafeId(props.idPrefix + props.idCount); + } + + if (props.idPrefix.indexOf(Constants.RHS_ROOT) === 0) { + flagId = props.idPrefix; + } + + return ( +
  • + + {formatMessage(props.isFlagged)} + +
  • + ); +} + +DotMenuFlag.propTypes = { + idCount: PropTypes.number, + idPrefix: PropTypes.string.isRequired, + postId: PropTypes.string.isRequired, + isFlagged: PropTypes.bool.isRequired +}; + +DotMenuFlag.defaultProps = { + idCount: -1, + postId: '', + isFlagged: false +}; -- cgit v1.2.3-1-g7c22