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 1 commit
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/SupportalActionNotAllowedModal.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 SuppportalActionNotAllowedModalProps = {
isSupportalActionRestrictedModalOpen: boolean;
hideSupportalModal: () => void;
};

function SuppportalActionNotAllowedModal({isSupportalActionRestrictedModalOpen, hideSupportalModal}: SuppportalActionNotAllowedModalProps) {

Check failure on line 10 in src/components/SupportalActionNotAllowedModal.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Do not use negated variable names

Check failure on line 10 in src/components/SupportalActionNotAllowedModal.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Do not use negated variable names
const {translate} = useLocalize();
return (
<ConfirmModal
title={translate('supportalNoAccess.title')}
isVisible={isSupportalActionRestrictedModalOpen}
onConfirm={hideSupportalModal}
prompt={translate('supportalNoAccess.description')}
confirmText={translate('common.buttonConfirm')}
shouldShowCancelButton={false}
/>
);
}

SuppportalActionNotAllowedModal.displayName = 'SuppportalActionNotAllowedModal';

export default SuppportalActionNotAllowedModal;
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 el soporte está conectado.',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allgandalf can you please confirm these translation ? I am still to be added on slack, the above translation for title is already present in the codebase picked it up from there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asked on slack here

twilight2294 marked this conversation as resolved.
Show resolved Hide resolved
},
connectionComplete: {
title: 'Conexión completa',
supportingText: 'Ya puedes cerrar esta página y volver a la App de Expensify.',
Expand Down
15 changes: 15 additions & 0 deletions src/pages/workspace/WorkspacesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import {PressableWithoutFeedback} from '@components/Pressable';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import SuppportalActionNotAllowedModal from '@components/SupportalActionNotAllowedModal';
import Text from '@components/Text';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -126,6 +127,12 @@
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 @@
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,7 @@
return (
<View style={[styles.flexRow, styles.gap5, styles.p5, styles.pl10, styles.appBG]}>
<View style={[styles.flexRow, styles.flex1]}>
<Text

Check warning on line 251 in src/pages/workspace/WorkspacesListPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has a missing dependency: 'isSupportalAction'. Either include it or remove the dependency array

Check warning on line 251 in src/pages/workspace/WorkspacesListPage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useCallback has a missing dependency: 'isSupportalAction'. Either include it or remove the dependency array
numberOfLines={1}
style={[styles.flexGrow1, styles.textLabelSupporting]}
>
Expand Down Expand Up @@ -439,6 +450,10 @@
cancelText={translate('common.cancel')}
danger
/>
<SuppportalActionNotAllowedModal
isSupportalActionRestrictedModalOpen={isSupportalActionRestrictedModalOpen}
hideSupportalModal={hideSupportalModal}
/>
</ScreenWrapper>
);
}
Expand Down
Loading