Add ability to copy post permalink (#1255)
This commit is contained in:
parent
f16f8df0d3
commit
3c23a07d8b
3 changed files with 18 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import {createPost, deletePost, removePost} from 'mattermost-redux/actions/posts
|
|||
import {getPost} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {getCurrentUserId, getCurrentUserRoles} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getMyPreferences, getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentTeamUrl} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {isPostFlagged} from 'mattermost-redux/utils/post_utils';
|
||||
|
||||
import {insertToDraft, setPostTooltipVisible} from 'app/actions/views/channel';
|
||||
|
|
@ -49,6 +50,7 @@ function mapStateToProps(state, ownProps) {
|
|||
|
||||
return {
|
||||
config,
|
||||
currentTeamUrl: getCurrentTeamUrl(state),
|
||||
currentUserId: getCurrentUserId(state),
|
||||
post,
|
||||
isFirstReply,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class Post extends PureComponent {
|
|||
removePost: PropTypes.func.isRequired
|
||||
}).isRequired,
|
||||
config: PropTypes.object.isRequired,
|
||||
currentTeamUrl: PropTypes.string.isRequired,
|
||||
currentUserId: PropTypes.string.isRequired,
|
||||
highlight: PropTypes.bool,
|
||||
intl: intlShape.isRequired,
|
||||
|
|
@ -337,6 +338,13 @@ class Post extends PureComponent {
|
|||
Clipboard.setString(textToCopy);
|
||||
}
|
||||
|
||||
handleCopyPermalink = () => {
|
||||
const {currentTeamUrl, postId} = this.props;
|
||||
const permalink = `${currentTeamUrl}/pl/${postId}`;
|
||||
|
||||
Clipboard.setString(permalink);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
commentedOnPost,
|
||||
|
|
@ -392,6 +400,7 @@ class Post extends PureComponent {
|
|||
isSearchResult={isSearchResult}
|
||||
navigator={this.props.navigator}
|
||||
onAddReaction={this.handleAddReaction}
|
||||
onCopyPermalink={this.handleCopyPermalink}
|
||||
onCopyText={this.handleCopyText}
|
||||
onFailedPostPress={this.handleFailedPostPress}
|
||||
onPostDelete={this.handlePostDelete}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class PostBody extends PureComponent {
|
|||
message: PropTypes.string,
|
||||
navigator: PropTypes.object.isRequired,
|
||||
onAddReaction: PropTypes.func,
|
||||
onCopyPermalink: PropTypes.func,
|
||||
onCopyText: PropTypes.func,
|
||||
onFailedPostPress: PropTypes.func,
|
||||
onPostDelete: PropTypes.func,
|
||||
|
|
@ -62,6 +63,7 @@ class PostBody extends PureComponent {
|
|||
static defaultProps = {
|
||||
fileIds: [],
|
||||
onAddReaction: emptyFunction,
|
||||
onCopyPermalink: emptyFunction,
|
||||
onCopyText: emptyFunction,
|
||||
onFailedPostPress: emptyFunction,
|
||||
onPostDelete: emptyFunction,
|
||||
|
|
@ -198,6 +200,11 @@ class PostBody extends PureComponent {
|
|||
if (canDelete && !hasBeenDeleted) {
|
||||
actions.push({text: formatMessage({id: 'post_info.del', defaultMessage: 'Delete'}), onPress: onPostDelete});
|
||||
}
|
||||
|
||||
actions.push({
|
||||
text: formatMessage({id: 'get_post_link_modal.title', defaultMessage: 'Copy Permalink'}),
|
||||
onPress: this.props.onCopyPermalink
|
||||
});
|
||||
}
|
||||
|
||||
let body;
|
||||
|
|
|
|||
Loading…
Reference in a new issue