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

[Free trial] Implement Restricted Action screen #43855

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,10 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/taxes',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/import/taxes` as const,
},
RESTRICTED_ACTION: {
route: 'restricted-action/workspace/:policyID',
getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` as const,
},
} as const;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const SCREENS = {
TRAVEL: 'Travel',
SEARCH_REPORT: 'SearchReport',
SETTINGS_CATEGORIES: 'SettingsCategories',
RESTRICTED_ACTION: 'RestrictedAction',
},
ONBOARDING_MODAL: {
ONBOARDING: 'Onboarding',
Expand Down Expand Up @@ -378,6 +379,7 @@ const SCREENS = {
KEYBOARD_SHORTCUTS: 'KeyboardShortcuts',
TRANSACTION_RECEIPT: 'TransactionReceipt',
FEATURE_TRAINING_ROOT: 'FeatureTraining_Root',
RESTRICTED_ACTION_ROOT: 'RestrictedAction_Root',
} as const;

type Screen = DeepValueOf<typeof SCREENS>;
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import WalletAlt from '@assets/images/simple-illustrations/simple-illustration__
import Workflows from '@assets/images/simple-illustrations/simple-illustration__workflows.svg';
import ExpensifyApprovedLogoLight from '@assets/images/subscription-details__approvedlogo--light.svg';
import ExpensifyApprovedLogo from '@assets/images/subscription-details__approvedlogo.svg';
import LockClosedOrange from '@assets/images/simple-illustrations/simple-illustration__lockclosed_orange.svg'

export {
Abracadabra,
Expand Down Expand Up @@ -192,4 +193,5 @@ export {
SendMoney,
CheckmarkCircle,
CreditCardEyes,
LockClosedOrange,
};
12 changes: 12 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2683,6 +2683,18 @@ export default {
errorDescriptionPartTwo: 'reach out to Concierge',
errorDescriptionPartThree: 'for help.',
},
restrictedAction: {
restricted: 'Restricted',
actionsAreCurrentlyRestricted: ({workspaceName}) => `Actions on the ${workspaceName} workspace are currently restricted`,
workspaceOwnerWillNeedToAddOrUpdatePaymentCard: ({workspaceOwnerName}) => `Workspace owner, ${workspaceOwnerName} will need to add or update the payment card on file to unlock new workspace activity.`,
youWillNeedToAddOrUpdatePaymentCard: 'You\'ll need to add or update the payment card on file to unlock new workspace activity.',
addPaymentCardToUnlock: 'Add a payment card to unlock!',
addPaymentCardToContinueUsingWorkspace: 'Add a payment card to continue using this workspace',
pleaseReachOutToYourWorkspaceAdmin: 'Please reach out to your workspace admin for any questions.',
chatWithYourAdmin: 'Chat with your admin',
chatInAdmins: 'Chat in #admins',
addPaymentCard: 'Add payment card',
}
},
getAssistancePage: {
title: 'Get assistance',
Expand Down
12 changes: 12 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,18 @@ export default {
errorDescriptionPartTwo: 'contacta con el conserje',
errorDescriptionPartThree: 'por ayuda.',
},
restrictedAction: {
restricted: 'Restringido',
actionsAreCurrentlyRestricted: ({ workspaceName }) => `Los gastos para ${workspaceName} están actualmente restringidos`,
Copy link
Contributor

Choose a reason for hiding this comment

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

@pac-guerreiro Please resolve this comment once you update the spanish translation with the correct text.

Copy link
Contributor

Choose a reason for hiding this comment

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

The word in the ES file for workspace is espacio de trabajo

So this would be:

Los gastos para {workspace_name} espacio de trabajo están actualmente restringidos

CC: @Gonals to quickly confirm.

Copy link
Contributor

Choose a reason for hiding this comment

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

Los gastos para el espacio de trabajo {workspace_name} están actualmente restringidos

😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Gonals Muchas gracias! 🙏

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah coming back here - the copy for this has an additional change that was made in the design doc reviews --

Instead of "Los gastos para el espacio de trabajo {workspace_name} están actualmente restringidos", we want to change the copy to "Las acciones en el espacio de trabajo {workspace_name} están actualmente restringidas"

@Gonals - are you able to confirm if that is the correct formatting to say, "Actions on the {workspace_name} workspace are currently restricted" ? I think we'd also need to change the English file for this as well? As initially the design doc had "Expenses to {workspace_name} are currently restricted."

Copy link
Contributor

Choose a reason for hiding this comment

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

English file is correct in the PR it seems:

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah coming back here - the copy for this has an additional change that was made in the design doc reviews --

Instead of "Los gastos para el espacio de trabajo {workspace_name} están actualmente restringidos", we want to change the copy to "Las acciones en el espacio de trabajo {workspace_name} están actualmente restringidas"

@Gonals - are you able to confirm if that is the correct formatting to say, "Actions on the {workspace_name} workspace are currently restricted" ? I think we'd also need to change the English file for this as well? As initially the design doc had "Expenses to {workspace_name} are currently restricted."

Yep! All good!

workspaceOwnerWillNeedToAddOrUpdatePaymentCard: ({workspaceOwnerName}) => `El propietario del espacio de trabajo, ${workspaceOwnerName} tendrá que añadir o actualizar la tarjeta de pago registrada para desbloquear nueva actividad en el espacio de trabajo.`,
youWillNeedToAddOrUpdatePaymentCard: 'Debes añadir o actualizar la tarjeta de pago registrada para desbloquear nueva actividad en el espacio de trabajo.',
addPaymentCardToUnlock: 'Añade una tarjeta de pago para desbloquearlo!',
addPaymentCardToContinueUsingWorkspace: 'Añade una tarjeta de pago para seguir utilizando este espacio de trabajo',
pleaseReachOutToYourWorkspaceAdmin: 'Si tienes alguna pregunta, ponte en contacto con el administrador de su espacio de trabajo.',
chatWithYourAdmin: 'Chatea con tu administrador',
chatInAdmins: 'Chatea en #admins',
addPaymentCard: 'Agregar tarjeta de pago'
}
},
getAssistancePage: {
title: 'Obtener ayuda',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ const SearchReportModalStackNavigator = createModalStackNavigator<SearchReportPa
[SCREENS.SEARCH.REPORT_RHP]: () => require('../../../../pages/home/ReportScreen').default as React.ComponentType,
});

const RestrictedActionModalStackNavigator = createModalStackNavigator<SearchReportParamList>({
[SCREENS.RESTRICTED_ACTION_ROOT]: () => require('../../../../pages/RestrictedAction/Workspace/WorkspaceRestrictedActionPage').default as React.ComponentType,
});

export {
AddPersonalBankAccountModalStackNavigator,
EditRequestStackNavigator,
Expand Down Expand Up @@ -400,4 +404,5 @@ export {
TaskModalStackNavigator,
WalletStatementStackNavigator,
SearchReportModalStackNavigator,
RestrictedActionModalStackNavigator,
};
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ function RightModalNavigator({navigation}: RightModalNavigatorProps) {
name={SCREENS.RIGHT_MODAL.SEARCH_REPORT}
component={ModalStackNavigators.SearchReportModalStackNavigator}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.RESTRICTED_ACTION}
component={ModalStackNavigators.RestrictedActionModalStackNavigator}
/>
</Stack.Navigator>
</View>
</NoDropZone>
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.SEARCH.REPORT_RHP]: ROUTES.SEARCH_REPORT.route,
},
},
[SCREENS.RIGHT_MODAL.RESTRICTED_ACTION]: {
screens: {
[SCREENS.RESTRICTED_ACTION_ROOT]: ROUTES.RESTRICTED_ACTION.route,
},
},
},
},

Expand Down
8 changes: 8 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ type RightModalNavigatorParamList = {
[SCREENS.RIGHT_MODAL.PRIVATE_NOTES]: NavigatorScreenParams<PrivateNotesNavigatorParamList>;
[SCREENS.RIGHT_MODAL.TRAVEL]: NavigatorScreenParams<TravelNavigatorParamList>;
[SCREENS.RIGHT_MODAL.SEARCH_REPORT]: NavigatorScreenParams<SearchReportParamList>;
[SCREENS.RIGHT_MODAL.RESTRICTED_ACTION]: NavigatorScreenParams<RestrictedActionParamList>;
};

type TravelNavigatorParamList = {
Expand Down Expand Up @@ -943,6 +944,12 @@ type SearchReportParamList = {
};
};

type RestrictedActionParamList = {
[SCREENS.RESTRICTED_ACTION_ROOT]: {
policyID: string;
};
};

type RootStackParamList = PublicScreensParamList & AuthScreensParamList & LeftModalNavigatorParamList;

type BottomTabName = keyof BottomTabNavigatorParamList;
Expand Down Expand Up @@ -1007,4 +1014,5 @@ export type {
WalletStatementNavigatorParamList,
WelcomeVideoModalNavigatorParamList,
SearchReportParamList,
RestrictedActionParamList,
};
5 changes: 5 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6964,6 +6964,10 @@ function shouldShowMerchantColumn(transactions: Transaction[]) {
return transactions.some((transaction) => isExpenseReport(allReports?.[transaction.reportID] ?? {}));
}

function findPolicyExpenseChatByPolicyID(policyID: string): OnyxEntry<Report> {
return Object.values(allReports ?? {}).find((report) => isPolicyExpenseChat(report) && report?.policyID === policyID);
}

pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
export {
addDomainToShortMention,
areAllRequestsBeingSmartScanned,
Expand Down Expand Up @@ -7236,6 +7240,7 @@ export {
isDraftReport,
changeMoneyRequestHoldStatus,
createDraftWorkspaceAndNavigateToConfirmationScreen,
findPolicyExpenseChatByPolicyID,
};

export type {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React, {useCallback} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Illustrations from '@components/Icon/Illustrations';
import ImageSVG from '@components/ImageSVG';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as Report from '@libs/actions/Report';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

type WorkspaceAdminRestrictedActionProps = {
policyID: string;
};

function WorkspaceAdminRestrictedAction({policyID}: WorkspaceAdminRestrictedActionProps) {
const {translate} = useLocalize();
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const styles = useThemeStyles();

const openAdminsReport = useCallback(() => {
const reportID = `${PolicyUtils.getPolicy(policyID)?.chatReportIDAdmins}` ?? '-1';
Report.openReport(reportID);
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID));
}, [policyID]);

return (
<ScreenWrapper
includeSafeAreaPaddingBottom
testID={WorkspaceAdminRestrictedAction.displayName}
>
<HeaderWithBackButton
title={translate('workspace.restrictedAction.restricted')}
onBackButtonPress={Navigation.goBack}
/>
<ScrollView
style={[styles.p5, styles.pt0]}
contentContainerStyle={styles.flexGrow1}
>
<View style={[styles.flex1, styles.alignItemsCenter, styles.justifyContentCenter, styles.mb15]}>
<ImageSVG
src={Illustrations.LockClosedOrange}
width={136}
height={136}
/>
<Text style={[styles.textHeadlineH1, styles.textAlignCenter]}>
{translate('workspace.restrictedAction.actionsAreCurrentlyRestricted', {workspaceName: policy?.name})}
</Text>
<Text style={[styles.textLabelSupportingEmptyValue, styles.textAlignCenter, styles.lh20, styles.mt2]}>
{translate('workspace.restrictedAction.workspaceOwnerWillNeedToAddOrUpdatePaymentCard', {workspaceOwnerName: policy?.owner})}
</Text>
</View>
<Button
text={translate('workspace.restrictedAction.chatInAdmins')}
onPress={openAdminsReport}
success
/>
</ScrollView>
</ScreenWrapper>
);
}

WorkspaceAdminRestrictedAction.displayName = 'WorkspaceAdminRestrictedAction';

export default WorkspaceAdminRestrictedAction;
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react';
import {View} from 'react-native';
import Badge from '@components/Badge';
import Button from '@components/Button';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as Illustrations from '@components/Icon/Illustrations';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import ROUTES from '@src/ROUTES';

function WorkspaceOwnerRestrictedAction() {
const {translate} = useLocalize();
const styles = useThemeStyles();

const addPaymentCard = () => {
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION);
}

return (
<ScreenWrapper
includeSafeAreaPaddingBottom
testID={WorkspaceOwnerRestrictedAction.displayName}
>
<HeaderWithBackButton
title={translate('workspace.restrictedAction.restricted')}
onBackButtonPress={Navigation.goBack}
/>
<ScrollView>
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
<View style={[styles.cardSectionContainer, styles.p5]}>
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsStart, styles.mb3]}>
<Icon
src={Illustrations.LockClosedOrange}
height={48}
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
width={48}
/>
<Badge
icon={Expensicons.Unlock}
success
text={translate('workspace.restrictedAction.addPaymentCardToUnlock')}
badgeStyles={styles.alignSelfStart}
/>
</View>
<Text style={[styles.textHeadlineH1, styles.mb4]}>{translate('workspace.restrictedAction.addPaymentCardToContinueUsingWorkspace')}</Text>
<Text style={[styles.textLabelSupportingEmptyValue, styles.mb5]}>{translate('workspace.restrictedAction.youWillNeedToAddOrUpdatePaymentCard')}</Text>
<Button
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
text={translate('workspace.restrictedAction.addPaymentCard')}
onPress={addPaymentCard}
success
/>
</View>
</ScrollView>
</ScreenWrapper>
);
}

WorkspaceOwnerRestrictedAction.displayName = 'WorkspaceOwnerRestrictedAction';

export default WorkspaceOwnerRestrictedAction;
Loading
Loading