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

Automatic Merge
Этот коммит содержится в:
Harshil Sharma
2023-05-24 18:34:31 +05:30
коммит произвёл GitHub
родитель 3ac15290ef
Коммит c8ee05fb76
3 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@@ -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),
}; };
}; };
} }

Просмотреть файл

@@ -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 => {

Просмотреть файл

@@ -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);