Skip to content

Commit

Permalink
restrict actions for read-only chats
Browse files Browse the repository at this point in the history
  • Loading branch information
rezkiy37 committed Apr 23, 2024
1 parent c5da50e commit 6b41cde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -513,5 +513,17 @@ const ContextMenuActions: ContextMenuAction[] = [
},
];

const restrictedReadOnlyActions = [
'common.download',
'reportActionContextMenu.replyInThread',
'reportActionContextMenu.editAction',
'reportActionContextMenu.joinThread',
'reportActionContextMenu.deleteAction',
];

// @ts-expect-error Not all actions have textTranslateKey
const RestrictedReadOnlyContextMenuActions: ContextMenuAction[] = ContextMenuActions.filter((action) => restrictedReadOnlyActions.includes(action.textTranslateKey));

export {RestrictedReadOnlyContextMenuActions};
export default ContextMenuActions;
export type {ContextMenuActionPayload, ContextMenuAction};
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import type * as OnyxTypes from '@src/types/onyx';
import type {OriginalMessageActionableMentionWhisper, OriginalMessageActionableTrackedExpenseWhisper, OriginalMessageJoinPolicyChangeLog} from '@src/types/onyx/OriginalMessage';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import AnimatedEmptyStateBackground from './AnimatedEmptyStateBackground';
import {RestrictedReadOnlyContextMenuActions} from './ContextMenu/ContextMenuActions';
import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu';
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu';
import {hideContextMenu} from './ContextMenu/ReportActionContextMenu';
Expand Down Expand Up @@ -914,6 +915,7 @@ function ReportActionItem({
originalReportID={originalReportID ?? ''}
isArchivedRoom={ReportUtils.isArchivedRoom(report)}
displayAsGroup={displayAsGroup}
disabledActions={ReportUtils.isReadOnly(report) ? RestrictedReadOnlyContextMenuActions : []}
isVisible={hovered && draftMessage === undefined && !hasErrors}
draftMessage={draftMessage}
isChronosReport={ReportUtils.chatIncludesChronos(originalReport)}
Expand Down

0 comments on commit 6b41cde

Please sign in to comment.