From ec142def26746f010efda5f2d63821ee0ba99ce5 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Mon, 18 Mar 2024 17:56:00 +0200 Subject: [PATCH 1/5] Add default description for Workspace --- src/languages/en.ts | 4 ++-- src/languages/es.ts | 4 ++-- src/libs/actions/Policy.ts | 2 +- src/pages/workspace/WorkspaceInviteMessagePage.tsx | 5 +++-- .../workspace/WorkspaceProfileDescriptionPage.tsx | 9 ++++++++- src/pages/workspace/WorkspaceProfilePage.tsx | 11 ++++++++++- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index a80889ef7857..0ca50e506740 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1768,6 +1768,8 @@ export default { moreFeatures: 'More features', requested: 'Requested', distanceRates: 'Distance rates', + welcomeNote: ({workspaceName}: WelcomeNoteParams) => + `You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`, }, type: { free: 'Free', @@ -1977,8 +1979,6 @@ export default { personalMessagePrompt: 'Message', genericFailureMessage: 'An error occurred inviting the user to the workspace, please try again.', inviteNoMembersError: 'Please select at least one member to invite', - welcomeNote: ({workspaceName}: WelcomeNoteParams) => - `You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`, }, distanceRates: { oopsNotSoFast: 'Oops! Not so fast...', diff --git a/src/languages/es.ts b/src/languages/es.ts index 4660b57c9265..9cc94c125b5a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1792,6 +1792,8 @@ export default { moreFeatures: 'Más características', requested: 'Solicitado', distanceRates: 'Tasas de distancia', + welcomeNote: ({workspaceName}: WelcomeNoteParams) => + `¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`, }, type: { free: 'Gratis', @@ -2002,8 +2004,6 @@ export default { personalMessagePrompt: 'Mensaje', inviteNoMembersError: 'Por favor, selecciona al menos un miembro a invitar', genericFailureMessage: 'Se produjo un error al invitar al usuario al espacio de trabajo. Vuelva a intentarlo..', - welcomeNote: ({workspaceName}: WelcomeNoteParams) => - `¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`, }, distanceRates: { oopsNotSoFast: 'Ups! No tan rápido...', diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 6c1b53e21436..1dde6500aeb6 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2163,7 +2163,7 @@ function setWorkspaceInviteMembersDraft(policyID: string, invitedEmailsToAccount Onyx.set(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID}`, invitedEmailsToAccountIDs); } -function setWorkspaceInviteMessageDraft(policyID: string, message: string) { +function setWorkspaceInviteMessageDraft(policyID: string, message: string | null) { Onyx.set(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${policyID}`, message); } diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index df1d3cd63011..b83d8f4b72d0 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -64,7 +64,7 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT // workspaceInviteMessageDraft can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing workspaceInviteMessageDraft || - translate('workspace.inviteMessage.welcomeNote', { + translate('workspace.common.welcomeNote', { workspaceName: policy?.name ?? '', }); @@ -77,7 +77,7 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const debouncedSaveDraft = lodashDebounce((newDraft: string) => { + const debouncedSaveDraft = lodashDebounce((newDraft: string | null) => { Policy.setWorkspaceInviteMessageDraft(route.params.policyID, newDraft); }); @@ -85,6 +85,7 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT Keyboard.dismiss(); // Please see https://github.com/Expensify/App/blob/main/README.md#Security for more details Policy.addMembersToWorkspace(invitedEmailsToAccountIDsDraft ?? {}, welcomeNote ?? '', route.params.policyID); + debouncedSaveDraft(null); SearchInputManager.searchInput = ''; // Pop the invite message page before navigating to the members page. Navigation.goBack(); diff --git a/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx b/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx index 46a83dd2b166..98c67f194811 100644 --- a/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx +++ b/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx @@ -26,7 +26,14 @@ const parser = new ExpensiMark(); function WorkspaceProfileDescriptionPage({policy}: Props) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [description, setDescription] = useState(() => parser.htmlToMarkdown(policy?.description ?? '')); + const [description, setDescription] = useState(() => + parser.htmlToMarkdown( + policy?.description ?? + translate('workspace.common.welcomeNote', { + workspaceName: policy?.name ?? '', + }), + ), + ); /** * @param {Object} values - form input values passed by the Form component diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 59c66f0c06a7..22b84861c085 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -1,3 +1,4 @@ +import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import React, {useCallback, useState} from 'react'; import type {ImageStyle, StyleProp} from 'react-native'; import {Image, StyleSheet, View} from 'react-native'; @@ -41,6 +42,8 @@ type WorkSpaceProfilePageOnyxProps = { type WorkSpaceProfilePageProps = WithPolicyProps & WorkSpaceProfilePageOnyxProps; +const parser = new ExpensiMark(); + function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfilePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -58,7 +61,13 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi const onPressShare = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_SHARE.getRoute(policy?.id ?? '')), [policy?.id]); const policyName = policy?.name ?? ''; - const policyDescription = policy?.description ?? ''; + const policyDescription = + policy?.description ?? + parser.replace( + translate('workspace.common.welcomeNote', { + workspaceName: policy?.name ?? '', + }), + ); const readOnly = !PolicyUtils.isPolicyAdmin(policy); const imageStyle: StyleProp = isSmallScreenWidth ? [styles.mhv12, styles.mhn5, styles.mbn5] : [styles.mhv8, styles.mhn8, styles.mbn5]; From a635c748c6e2d745d485618f5b355fdb33ac70b2 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Mon, 18 Mar 2024 18:24:51 +0200 Subject: [PATCH 2/5] update optional checks and add description from policy to invite flow --- src/pages/workspace/WorkspaceInviteMessagePage.tsx | 3 +++ src/pages/workspace/WorkspaceProfilePage.tsx | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index b83d8f4b72d0..09a6528867f0 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -64,6 +64,9 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT // workspaceInviteMessageDraft can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing workspaceInviteMessageDraft || + // policy?.description can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + policy?.description || translate('workspace.common.welcomeNote', { workspaceName: policy?.name ?? '', }); diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 22b84861c085..d110a5752382 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -62,7 +62,9 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi const policyName = policy?.name ?? ''; const policyDescription = - policy?.description ?? + // policy?.description can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + policy?.description || parser.replace( translate('workspace.common.welcomeNote', { workspaceName: policy?.name ?? '', From 11916b569b4648c8ea1013d94dbaee36de4f3e44 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Mon, 18 Mar 2024 18:37:44 +0200 Subject: [PATCH 3/5] fix markdown --- src/pages/workspace/WorkspaceInviteMessagePage.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index 09a6528867f0..a9d8860ae12a 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -1,4 +1,5 @@ import type {StackScreenProps} from '@react-navigation/stack'; +import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import lodashDebounce from 'lodash/debounce'; import React, {useEffect, useState} from 'react'; import {Keyboard, View} from 'react-native'; @@ -52,6 +53,8 @@ type WorkspaceInviteMessagePageProps = WithPolicyAndFullscreenLoadingProps & WorkspaceInviteMessagePageOnyxProps & StackScreenProps; +const parser = new ExpensiMark(); + function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsToAccountIDsDraft, policy, route, allPersonalDetails}: WorkspaceInviteMessagePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -67,13 +70,15 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT // policy?.description can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing policy?.description || - translate('workspace.common.welcomeNote', { - workspaceName: policy?.name ?? '', - }); + parser.replace( + translate('workspace.common.welcomeNote', { + workspaceName: policy?.name ?? '', + }), + ); useEffect(() => { if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) { - setWelcomeNote(getDefaultWelcomeNote()); + setWelcomeNote(parser.htmlToMarkdown(getDefaultWelcomeNote())); return; } Navigation.goBack(ROUTES.WORKSPACE_INVITE.getRoute(route.params.policyID), true); From 30739acd78133422c694651bf54a931e69d89578 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 19 Mar 2024 12:15:14 +0200 Subject: [PATCH 4/5] update optional checks --- src/pages/workspace/WorkspaceProfileDescriptionPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx b/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx index 98c67f194811..f31ebfc85dcc 100644 --- a/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx +++ b/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx @@ -28,7 +28,9 @@ function WorkspaceProfileDescriptionPage({policy}: Props) { const {translate} = useLocalize(); const [description, setDescription] = useState(() => parser.htmlToMarkdown( - policy?.description ?? + // policy?.description can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + policy?.description || translate('workspace.common.welcomeNote', { workspaceName: policy?.name ?? '', }), From 2640d95269b5b0d0a37f9023c2a30686fe5180ae Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 19 Mar 2024 16:43:56 +0200 Subject: [PATCH 5/5] use markdown for default --- src/pages/workspace/WorkspaceProfileDescriptionPage.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx b/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx index f31ebfc85dcc..bd8ec5b03f05 100644 --- a/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx +++ b/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx @@ -31,9 +31,11 @@ function WorkspaceProfileDescriptionPage({policy}: Props) { // policy?.description can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing policy?.description || - translate('workspace.common.welcomeNote', { - workspaceName: policy?.name ?? '', - }), + parser.replace( + translate('workspace.common.welcomeNote', { + workspaceName: policy?.name ?? '', + }), + ), ), );