forked from Ivasoft/mattermost-mobile
MM-13654: Removes pin and delete longpress options from posts in arch… (#2495)
* MM-13654: Removes pin and delete longpress options from posts in archived channels. * MM-13654: Maintains existing option order. Updates others' posts options.
This commit is contained in:
committed by
Elias Nahum
parent
1a8be5444c
commit
1ff4c6ce83
@@ -41,6 +41,8 @@ function mapStateToProps(state, ownProps) {
|
||||
let canAddReaction = true;
|
||||
let canEdit = false;
|
||||
let canEditUntil = -1;
|
||||
let canDelete = true;
|
||||
let canPin = true;
|
||||
|
||||
if (hasNewPermissions(state)) {
|
||||
canAddReaction = haveIChannelPermission(state, {
|
||||
@@ -52,6 +54,8 @@ function mapStateToProps(state, ownProps) {
|
||||
|
||||
if (channelIsArchived) {
|
||||
canAddReaction = false;
|
||||
canDelete = false;
|
||||
canPin = false;
|
||||
} else {
|
||||
canEdit = canEditPost(state, config, license, currentTeamId, currentChannelId, currentUserId, post);
|
||||
if (canEdit && license.IsLicensed === 'true' &&
|
||||
@@ -66,6 +70,8 @@ function mapStateToProps(state, ownProps) {
|
||||
canAddReaction,
|
||||
canEdit,
|
||||
canEditUntil,
|
||||
canDelete,
|
||||
canPin,
|
||||
currentTeamUrl: getCurrentTeamUrl(state),
|
||||
isMyPost: currentUserId === post.user_id,
|
||||
post,
|
||||
|
||||
@@ -29,6 +29,7 @@ export default class PostOptions extends PureComponent {
|
||||
additionalOption: PropTypes.object,
|
||||
canAddReaction: PropTypes.bool,
|
||||
canDelete: PropTypes.bool,
|
||||
canPin: PropTypes.bool,
|
||||
canEdit: PropTypes.bool,
|
||||
canEditUntil: PropTypes.number.isRequired,
|
||||
channelIsReadOnly: PropTypes.bool,
|
||||
@@ -210,13 +211,19 @@ export default class PostOptions extends PureComponent {
|
||||
const actions = [
|
||||
this.getEditOption(),
|
||||
this.getFlagOption(),
|
||||
this.getPinOption(),
|
||||
this.getAddReactionOption(),
|
||||
this.getCopyPermalink(),
|
||||
this.getCopyText(),
|
||||
this.getDeleteOption(),
|
||||
];
|
||||
|
||||
const {canDelete, canPin} = this.props;
|
||||
if (canPin) {
|
||||
actions.splice(2, 0, this.getPinOption());
|
||||
}
|
||||
if (canDelete) {
|
||||
actions.push(this.getDeleteOption());
|
||||
}
|
||||
|
||||
return actions.filter((a) => a !== null);
|
||||
};
|
||||
|
||||
@@ -224,13 +231,19 @@ export default class PostOptions extends PureComponent {
|
||||
const actions = [
|
||||
this.getFlagOption(),
|
||||
this.getAddReactionOption(),
|
||||
this.getPinOption(),
|
||||
this.getCopyPermalink(),
|
||||
this.getCopyText(),
|
||||
this.getEditOption(),
|
||||
this.getDeleteOption(),
|
||||
];
|
||||
|
||||
const {canDelete, canPin} = this.props;
|
||||
if (canPin) {
|
||||
actions.splice(2, 0, this.getPinOption());
|
||||
}
|
||||
if (canDelete) {
|
||||
actions.push(this.getDeleteOption());
|
||||
}
|
||||
|
||||
return actions.filter((a) => a !== null);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user