[MM-52444] - Hide dot menu for users when they can't delete a system post (#23487)

Automatic Merge
This commit is contained in:
Harshil Sharma 2023-05-24 18:34:31 +05:30 committed by GitHub
parent 3ac15290ef
commit c8ee05fb76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -30,7 +30,7 @@ import {getIsMobileView} from 'selectors/views/browser';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import {isArchivedChannel} from 'utils/channel_utils'; import {isArchivedChannel} from 'utils/channel_utils';
import {areConsecutivePostsBySameUser, shouldShowActionsMenu, shouldShowDotMenu} from 'utils/post_utils'; import {areConsecutivePostsBySameUser, canDeletePost, shouldShowActionsMenu, shouldShowDotMenu} from 'utils/post_utils';
import {Locations, Preferences, RHSStates} from 'utils/constants'; import {Locations, Preferences, RHSStates} from 'utils/constants';
import {ExtendedPost, removePost} from 'mattermost-redux/actions/posts'; import {ExtendedPost, removePost} from 'mattermost-redux/actions/posts';
@ -228,6 +228,7 @@ function makeMapStateToProps() {
isPostPriorityEnabled: isPostPriorityEnabled(state), isPostPriorityEnabled: isPostPriorityEnabled(state),
isCardOpen: selectedCard && selectedCard.id === post.id, isCardOpen: selectedCard && selectedCard.id === post.id,
shouldShowDotMenu: shouldShowDotMenu(state, post, channel), shouldShowDotMenu: shouldShowDotMenu(state, post, channel),
canDelete: canDeletePost(state, post, channel),
}; };
}; };
} }

View File

@ -117,6 +117,7 @@ export type Props = {
isPostAcknowledgementsEnabled: boolean; isPostAcknowledgementsEnabled: boolean;
isPostPriorityEnabled: boolean; isPostPriorityEnabled: boolean;
isCardOpen?: boolean; isCardOpen?: boolean;
canDelete?: boolean;
}; };
const PostComponent = (props: Props): JSX.Element => { const PostComponent = (props: Props): JSX.Element => {

View File

@ -50,6 +50,7 @@ type Props = {
shortcutReactToLastPostEmittedFrom?: string; shortcutReactToLastPostEmittedFrom?: string;
isPostHeaderVisible?: boolean | null; isPostHeaderVisible?: boolean | null;
isPostBeingEdited?: boolean; isPostBeingEdited?: boolean;
canDelete?: boolean;
actions: { actions: {
emitShortcutReactToLastPostFrom: (emittedFrom: 'CENTER' | 'RHS_ROOT' | 'NO_WHERE') => void; emitShortcutReactToLastPostFrom: (emittedFrom: 'CENTER' | 'RHS_ROOT' | 'NO_WHERE') => void;
}; };
@ -201,7 +202,7 @@ const PostOptions = (props: Props): JSX.Element => {
</button> </button>
</div> </div>
); );
} else if (isPostDeleted) { } else if (isPostDeleted || (systemMessage && !props.canDelete)) {
options = null; options = null;
} else if (props.location === Locations.SEARCH) { } else if (props.location === Locations.SEARCH) {
const hasCRTFooter = props.collapsedThreadsEnabled && !post.root_id && (post.reply_count > 0 || post.is_following); const hasCRTFooter = props.collapsedThreadsEnabled && !post.root_id && (post.reply_count > 0 || post.is_following);