Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal QA]: Fix: Logged-In Agents Can Appear to Delete Workspaces in NewDot Without Actual Deletion or Error Message #53333

Merged
merged 8 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -473,6 +473,10 @@ const translations = {
days: 'days',
rename: 'Rename',
},
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 @@ -463,6 +463,10 @@ const translations = {
links: 'Enlaces',
days: 'días',
},
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 @@ -126,6 +127,12 @@ function WorkspacesListPage() {
const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`);
const hasCardFeedOrExpensifyCard = !isEmptyObject(cardFeeds) || !isEmptyObject(cardsList);

const isSupportalAction = Session.isSupportAuthToken();

const [isSupportalActionRestrictedModalOpen, setIsSupportalActionRestrictedModalOpen] = useState(false);
const hideSupportalModal = () => {
setIsSupportalActionRestrictedModalOpen(false);
};
const confirmDeleteAndHideModal = () => {
if (!policyIDToDelete || !policyNameToDelete) {
return;
Expand Down Expand Up @@ -158,6 +165,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 @@ -226,7 +237,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 @@ -439,6 +461,10 @@ function WorkspacesListPage() {
cancelText={translate('common.cancel')}
danger
/>
<SupportalActionRestrictedModal
isModalOpen={isSupportalActionRestrictedModalOpen}
hideSupportalModal={hideSupportalModal}
/>
</ScreenWrapper>
);
}
Expand Down
Loading