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 3 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/SupportalActionModal.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 SupportalActionModalProps = {
isSupportalActionRestrictedModalOpen: boolean;
hideSupportalModal: () => void;
};

function SupportalActionModal({isSupportalActionRestrictedModalOpen, hideSupportalModal}: SupportalActionModalProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do y'all think about shortening isSupportalActionRestrictedModalOpen to just isOpen since that's a pretty clear prop name internal to this component? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

umm, isOpen is quite generic how about isSupportalModalOpen? defines purpose ?!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm what about isModalOpen? 😅 I just don't think we need to be TOO specific, but I do agree isOpen is a bit too generic 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

worksssss for mee! :team-work:

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

SupportalActionModal.displayName = 'SupportalActionModal';

export default SupportalActionModal;
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
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 SupportalActionModal from '@components/SupportalActionModal';
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
/>
<SupportalActionModal
Copy link
Contributor

Choose a reason for hiding this comment

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

What do y'all think about calling this SupportalActionRestrictedModal or RestrictedSupportalActionModal to make it super clear that this modal specifically tells the user that an action is restricted since they're supportaled?

Copy link
Contributor

Choose a reason for hiding this comment

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

I’m down with this suggestion 🙌, @twilight2294 please update this name

isSupportalActionRestrictedModalOpen={isSupportalActionRestrictedModalOpen}
hideSupportalModal={hideSupportalModal}
/>
</ScreenWrapper>
);
}
Expand Down
Loading