Skip to content

Commit

Permalink
Merge pull request #53333 from twilight2294/supportAgentblocker
Browse files Browse the repository at this point in the history
[Internal QA]: Fix: Logged-In Agents Can Appear to Delete Workspaces in NewDot Without Actual Deletion or Error Message
  • Loading branch information
Beamanator authored Dec 3, 2024
2 parents bf2cc89 + c2ec2f6 commit a2ad3f3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/components/SupportalActionRestrictedModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import useLocalize from '@hooks/useLocalize';
import ConfirmModal from './ConfirmModal';

type SupportalActionRestrictedModalProps = {
isModalOpen: boolean;
hideSupportalModal: () => void;
};

function SupportalActionRestrictedModal({isModalOpen, hideSupportalModal}: SupportalActionRestrictedModalProps) {
const {translate} = useLocalize();
return (
<ConfirmModal
title={translate('supportalNoAccess.title')}
isVisible={isModalOpen}
onConfirm={hideSupportalModal}
prompt={translate('supportalNoAccess.description')}
confirmText={translate('common.buttonConfirm')}
shouldShowCancelButton={false}
/>
);
}

SupportalActionRestrictedModal.displayName = 'SupportalActionRestrictedModal';

export default SupportalActionRestrictedModal;
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,10 @@ const translations = {
chatWithAccountManager: ({accountManagerDisplayName}: ChatWithAccountManagerParams) => `Need something specific? Chat with your account manager, ${accountManagerDisplayName}.`,
chatNow: 'Chat now',
},
supportalNoAccess: {
title: 'Not so fast',
description: 'You are not authorized to take this action when support logged in.',
},
location: {
useCurrent: 'Use current location',
notFound: 'We were unable to find your location. Please try again or enter an address manually.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ const translations = {
chatWithAccountManager: ({accountManagerDisplayName}: ChatWithAccountManagerParams) => `¿Necesitas algo específico? Habla con tu gerente de cuenta, ${accountManagerDisplayName}.`,
chatNow: 'Chatear ahora',
},
supportalNoAccess: {
title: 'No tan rápido',
description: 'No estás autorizado para realizar esta acción mientras estás conectado como soporte.',
},
connectionComplete: {
title: 'Conexión completa',
supportingText: 'Ya puedes cerrar esta página y volver a la App de Expensify.',
Expand Down
28 changes: 27 additions & 1 deletion src/pages/workspace/WorkspacesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {PopoverMenuItem} from '@components/PopoverMenu';
import {PressableWithoutFeedback} from '@components/Pressable';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import SupportalActionRestrictedModal from '@components/SupportalActionRestrictedModal';
import Text from '@components/Text';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -131,6 +132,12 @@ function WorkspacesListPage() {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
((policyToDelete?.areExpensifyCardsEnabled || policyToDelete?.areCompanyCardsEnabled) && policyToDelete?.workspaceAccountID);

const isSupportalAction = Session.isSupportAuthToken();

const [isSupportalActionRestrictedModalOpen, setIsSupportalActionRestrictedModalOpen] = useState(false);
const hideSupportalModal = () => {
setIsSupportalActionRestrictedModalOpen(false);
};
const confirmDeleteAndHideModal = () => {
if (!policyIDToDelete || !policyNameToDelete) {
return;
Expand Down Expand Up @@ -169,6 +176,10 @@ function WorkspacesListPage() {
icon: Expensicons.Trashcan,
text: translate('workspace.common.delete'),
onSelected: () => {
if (isSupportalAction) {
setIsSupportalActionRestrictedModalOpen(true);
return;
}
setPolicyIDToDelete(item.policyID ?? '-1');
setPolicyNameToDelete(item.title);
setIsDeleteModalOpen(true);
Expand Down Expand Up @@ -237,7 +248,18 @@ function WorkspacesListPage() {
</OfflineWithFeedback>
);
},
[isLessThanMediumScreen, styles.mb2, styles.mh5, styles.ph5, styles.hoveredComponentBG, translate, styles.offlineFeedback.deleted, session?.accountID, session?.email],
[
isLessThanMediumScreen,
styles.mb2,
styles.mh5,
styles.ph5,
styles.hoveredComponentBG,
translate,
styles.offlineFeedback.deleted,
session?.accountID,
session?.email,
isSupportalAction,
],
);

const listHeaderComponent = useCallback(() => {
Expand Down Expand Up @@ -450,6 +472,10 @@ function WorkspacesListPage() {
cancelText={translate('common.cancel')}
danger
/>
<SupportalActionRestrictedModal
isModalOpen={isSupportalActionRestrictedModalOpen}
hideSupportalModal={hideSupportalModal}
/>
</ScreenWrapper>
);
}
Expand Down

0 comments on commit a2ad3f3

Please sign in to comment.