From 15f1aee4c1a64709572b77fb0e3a7f3485eafd5a Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 8 Feb 2024 00:09:56 +0530 Subject: [PATCH 01/21] Add workspace description --- src/ONYXKEYS.ts | 4 + src/ROUTES.ts | 4 + src/SCREENS.ts | 1 + src/components/ReportWelcomeText.tsx | 32 +++++-- src/languages/en.ts | 2 + .../UpdateWorkspaceDescriptionParams.ts | 6 ++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 + .../AppNavigator/ModalStackNavigators.tsx | 1 + .../CENTRAL_PANE_TO_RHP_MAPPING.ts | 2 +- src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 1 + src/libs/ReportUtils.ts | 15 ++++ src/libs/actions/Policy.ts | 60 +++++++++++++ src/pages/home/HeaderView.js | 31 ++++++- .../workspace/WorkspaceDescriptionPage.tsx | 87 +++++++++++++++++++ src/pages/workspace/WorkspaceOverviewPage.js | 11 +++ src/types/onyx/Form.ts | 5 ++ src/types/onyx/index.ts | 2 + 19 files changed, 256 insertions(+), 12 deletions(-) create mode 100644 src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts create mode 100644 src/pages/workspace/WorkspaceDescriptionPage.tsx diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 9fed8b69db79..303a8fe50f73 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -303,6 +303,8 @@ const ONYXKEYS = { ADD_DEBIT_CARD_FORM_DRAFT: 'addDebitCardFormDraft', WORKSPACE_SETTINGS_FORM: 'workspaceSettingsForm', WORKSPACE_SETTINGS_FORM_DRAFT: 'workspaceSettingsFormDraft', + WORKSPACE_DESCRIPTION_FORM: 'workspaceDescriptionForm', + WORKSPACE_DESCRIPTION_FORM_DRAFT: 'workspaceDescriptionFormDraft', WORKSPACE_RATE_AND_UNIT_FORM: 'workspaceRateAndUnitForm', WORKSPACE_RATE_AND_UNIT_FORM_DRAFT: 'workspaceRateAndUnitFormDraft', CLOSE_ACCOUNT_FORM: 'closeAccount', @@ -491,6 +493,8 @@ type OnyxValues = { [ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM_DRAFT]: OnyxTypes.AddDebitCardForm; [ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM]: OnyxTypes.WorkspaceSettingsForm; [ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM_DRAFT]: OnyxTypes.WorkspaceSettingsForm; + [ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM]: OnyxTypes.WorkspaceDescriptionForm; + [ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM_DRAFT]: OnyxTypes.WorkspaceDescriptionForm; [ONYXKEYS.FORMS.WORKSPACE_RATE_AND_UNIT_FORM]: OnyxTypes.Form; [ONYXKEYS.FORMS.WORKSPACE_RATE_AND_UNIT_FORM_DRAFT]: OnyxTypes.Form; [ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM]: OnyxTypes.CloseAccountForm; diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 5617c063bb57..7857ce14c586 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -445,6 +445,10 @@ const ROUTES = { route: 'workspace/:policyID/overview/name', getRoute: (policyID: string) => `workspace/${policyID}/overview/name` as const, }, + WORKSPACE_DESCRIPTION: { + route: 'workspace/:policyID/description', + getRoute: (policyID: string) => `workspace/${policyID}/description` as const, + }, WORKSPACE_AVATAR: { route: 'workspace/:policyID/avatar', getRoute: (policyID: string) => `workspace/${policyID}/avatar` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 538c72addc9a..eaf1e025cded 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -209,6 +209,7 @@ const SCREENS = { INVITE_MESSAGE: 'Workspace_Invite_Message', CURRENCY: 'Workspace_Overview_Currency', NAME: 'Workspace_Overview_Name', + DESCRIPTION: 'Workspace_Description', }, EDIT_REQUEST: { diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 5e39e0adb93d..eb02dc0ed1cb 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -61,13 +61,31 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP {isPolicyExpenseChat && ( - - {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')} - {ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)} - {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo')} - {ReportUtils.getPolicyName(report)} - {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree')} - + <> + {policy?.description ? ( + { + if (ReportUtils.canEditPolicyDescription(policy)) { + Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(policy.id)); + return; + } + Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policy.id)); + }} + style={styles.renderHTML} + accessibilityLabel={translate('reportDescriptionPage.roomDescription')} + > + + + ): ( + + {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')} + {ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)} + {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo')} + {ReportUtils.getPolicyName(report)} + {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree')} + + )} + )} {isChatRoom && ( <> diff --git a/src/languages/en.ts b/src/languages/en.ts index fd5d7d0e7b78..783586a36ec7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1667,6 +1667,8 @@ export default { `You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`, }, editor: { + descriptionInputLabel: 'Workspace description', + descriptionInputHelpText: 'This is a brief description of your workspace.', nameInputLabel: 'Name', nameInputHelpText: 'This is the name you will see on your workspace.', nameIsRequiredError: 'You need to define a name for your workspace.', diff --git a/src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts b/src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts new file mode 100644 index 000000000000..a130ddadf16d --- /dev/null +++ b/src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts @@ -0,0 +1,6 @@ +type UpdateWorkspaceDescriptionParams = { + policyID: string; + description: string; +}; + +export default UpdateWorkspaceDescriptionParams; \ No newline at end of file diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 4d784463c2f8..bcb39ab73195 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -139,3 +139,4 @@ export type {default as ReplaceReceiptParams} from './ReplaceReceiptParams'; export type {default as SubmitReportParams} from './SubmitReportParams'; export type {default as DetachReceiptParams} from './DetachReceiptParams'; export type {default as PayMoneyRequestParams} from './PayMoneyRequestParams'; +export type {default as UpdateWorkspaceDescriptionParams} from './UpdateWorkspaceDescriptionParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index a4ab3db9a7cd..d825b1acf41c 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -141,6 +141,7 @@ const WRITE_COMMANDS = { DETACH_RECEIPT: 'DetachReceipt', PAY_MONEY_REQUEST_WITH_WALLET: 'PayMoneyRequestWithWallet', PAY_MONEY_REQUEST: 'PayMoneyRequest', + UPDATE_WORKSPACE_DESCRIPTION: 'UpdateWorkspaceDescription', } as const; type WriteCommand = ValueOf; @@ -279,6 +280,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.DETACH_RECEIPT]: Parameters.DetachReceiptParams; [WRITE_COMMANDS.PAY_MONEY_REQUEST_WITH_WALLET]: Parameters.PayMoneyRequestParams; [WRITE_COMMANDS.PAY_MONEY_REQUEST]: Parameters.PayMoneyRequestParams; + [WRITE_COMMANDS.UPDATE_WORKSPACE_DESCRIPTION]: Parameters.UpdateWorkspaceDescriptionParams; }; const READ_COMMANDS = { diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 0e2863fed5f1..07a527035ce3 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -236,6 +236,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../pages/workspace/WorkspaceInvitePage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE_MESSAGE]: () => require('../../../pages/workspace/WorkspaceInviteMessagePage').default as React.ComponentType, [SCREENS.WORKSPACE.NAME]: () => require('../../../pages/workspace/WorkspaceNamePage').default as React.ComponentType, + [SCREENS.WORKSPACE.DESCRIPTION]: () => require('../../../pages/workspace/WorkspaceDescriptionPage').default as React.ComponentType, [SCREENS.WORKSPACE.CURRENCY]: () => require('../../../pages/workspace/WorkspaceOverviewCurrencyPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../pages/GetAssistancePage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index d61b36871434..786331644b68 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -2,7 +2,7 @@ import type {CentralPaneName} from '@libs/Navigation/types'; import SCREENS from '@src/SCREENS'; const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = { - [SCREENS.WORKSPACE.OVERVIEW]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY], + [SCREENS.WORKSPACE.OVERVIEW]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY, SCREENS.WORKSPACE.DESCRIPTION], [SCREENS.WORKSPACE.REIMBURSE]: [SCREENS.WORKSPACE.RATE_AND_UNIT], [SCREENS.WORKSPACE.MEMBERS]: [SCREENS.WORKSPACE.INVITE, SCREENS.WORKSPACE.INVITE_MESSAGE], }; diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 1eeede4506cc..74cc77b6df41 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -250,6 +250,7 @@ const config: LinkingOptions['config'] = { path: ROUTES.KEYBOARD_SHORTCUTS, }, [SCREENS.WORKSPACE.NAME]: ROUTES.WORKSPACE_OVERVIEW_NAME.route, + [SCREENS.WORKSPACE.DESCRIPTION]: ROUTES.WORKSPACE_DESCRIPTION.route, }, }, [SCREENS.RIGHT_MODAL.PRIVATE_NOTES]: { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 0abe267bdaa3..72136e766bc4 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -125,6 +125,7 @@ type SettingsNavigatorParamList = { [SCREENS.SETTINGS.PROFILE.STATUS_CLEAR_AFTER_TIME]: undefined; [SCREENS.WORKSPACE.CURRENCY]: undefined; [SCREENS.WORKSPACE.NAME]: undefined; + [SCREENS.WORKSPACE.DESCRIPTION]: undefined; [SCREENS.WORKSPACE.RATE_AND_UNIT]: undefined; [SCREENS.WORKSPACE.INVITE]: { policyID: string; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 64d79a3cd812..83fc4e35f78e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2608,6 +2608,15 @@ function getReportDescriptionText(report: Report): string { return parser.htmlToText(report.description); } +function getPolicyDescriptionText(policy: Policy): string { + if (!policy.description) { + return ''; + } + + const parser = new ExpensiMark(); + return parser.htmlToText(policy.description); +} + function buildOptimisticAddCommentReportAction(text?: string, file?: File, actorAccountID?: number): OptimisticReportAction { const parser = new ExpensiMark(); const commentText = getParsedComment(text ?? ''); @@ -4590,6 +4599,10 @@ function canEditReportDescription(report: OnyxEntry, policy: OnyxEntry

): boolean { + return PolicyUtils.isPolicyAdmin(policy); +} + /** * Checks if report action has error when smart scanning */ @@ -4967,6 +4980,8 @@ export { isReportFieldDisabled, getAvailableReportFields, getAllAncestorReportActionIDs, + canEditPolicyDescription, + getPolicyDescriptionText, }; export type { diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 866206895d5e..cf9d74c14bb2 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -22,6 +22,7 @@ import type { UpdateWorkspaceAvatarParams, UpdateWorkspaceCustomUnitAndRateParams, UpdateWorkspaceGeneralSettingsParams, + UpdateWorkspaceDescriptionParams, } from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; @@ -891,6 +892,64 @@ function updateGeneralSettings(policyID: string, name: string, currency: string) }); } +function updateDescription(policyID: string, description: string, currentDescription: string) { + if (description === currentDescription) { + return; + } + const parsedDescription = ReportUtils.getParsedComment(description); + + console.log(parsedDescription); + + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + description: parsedDescription, + pendingFields: { + description: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + errorFields: { + description: null, + }, + }, + }, + ]; + const finallyData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + description: null, + }, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + errorFields: { + description: ErrorUtils.getMicroSecondOnyxError('workspace.editor.genericFailureMessage'), + }, + }, + }, + ]; + + const params: UpdateWorkspaceDescriptionParams = { + policyID, + description: parsedDescription, + }; + + API.write(WRITE_COMMANDS.UPDATE_WORKSPACE_DESCRIPTION, params, { + optimisticData, + finallyData, + failureData, + }); +} + function clearWorkspaceGeneralSettingsErrors(policyID: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { errorFields: { @@ -2018,4 +2077,5 @@ export { buildOptimisticPolicyRecentlyUsedTags, createDraftInitialWorkspace, setWorkspaceInviteMessageDraft, + updateDescription, }; diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index f6f14d01889d..29db858b7eb8 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -40,6 +40,7 @@ import * as Task from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import { is } from 'date-fns/locale'; const propTypes = { /** Toggles the navigationMenu open and closed */ @@ -116,6 +117,8 @@ function HeaderView(props) { const isArchivedRoom = ReportUtils.isArchivedRoom(props.report); const reportDescription = ReportUtils.getReportDescriptionText(props.report); const policyName = ReportUtils.getPolicyName(props.report); + const policyDescription = ReportUtils.getPolicyDescriptionText(props.policy); + const shouldShowSubtitle = !_.isEmpty(subtitle) && (isChatRoom ? _.isEmpty(reportDescription) : isPolicyExpenseChat ? _.isEmpty(policyDescription) : true); // We hide the button when we are chatting with an automated Expensify account since it's not possible to contact // these users via alternative means. It is possible to request a call with Concierge so we leave the option for them. @@ -181,7 +184,7 @@ function HeaderView(props) { ); const renderAdditionalText = () => { - if (_.isEmpty(policyName) || _.isEmpty(reportDescription) || !_.isEmpty(parentNavigationSubtitleData)) { + if (shouldShowSubtitle || _.isEmpty(policyName) || !_.isEmpty(parentNavigationSubtitleData)) { return null; } return ( @@ -299,7 +302,7 @@ function HeaderView(props) { pressableStyles={[styles.alignSelfStart, styles.mw100]} /> )} - {!_.isEmpty(subtitle) && _.isEmpty(reportDescription) && ( + {shouldShowSubtitle && ( )} - {!_.isEmpty(reportDescription) && _.isEmpty(parentNavigationSubtitleData) && ( + {isChatRoom && !_.isEmpty(reportDescription) && _.isEmpty(parentNavigationSubtitleData) && ( { if (ReportUtils.canEditReportDescription(props.report, props.policy)) { @@ -327,6 +330,26 @@ function HeaderView(props) { )} + {isPolicyExpenseChat && !_.isEmpty(policyDescription) && _.isEmpty(parentNavigationSubtitleData) && ( + { + if (ReportUtils.canEditPolicyDescription(props.policy)) { + Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(props.report.policyID)); + return; + } + Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(props.policy.id)); + }} + style={[styles.alignSelfStart, styles.mw100]} + accessibilityLabel={translate('workspace.editor.descriptionInputLabel')} + > + + {policyDescription} + + + )} {brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR && ( @@ -390,7 +413,7 @@ export default memo( }, policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, - selector: (policy) => _.pick(policy, ['name', 'avatar', 'pendingAction']), + // selector: (policy) => _.pick(policy, ['name', 'avatar', 'pendingAction, description']), }, personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, diff --git a/src/pages/workspace/WorkspaceDescriptionPage.tsx b/src/pages/workspace/WorkspaceDescriptionPage.tsx new file mode 100644 index 000000000000..807909168ca7 --- /dev/null +++ b/src/pages/workspace/WorkspaceDescriptionPage.tsx @@ -0,0 +1,87 @@ +import React, {useCallback, useState} from 'react'; +import {Keyboard, View} from 'react-native'; +import FormProvider from '@components/Form/FormProvider'; +import InputWrapper from '@components/Form/InputWrapper'; +import type {OnyxFormValuesFields} from '@components/Form/types'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import TextInput from '@components/TextInput'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; +import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; +import * as Policy from '@userActions/Policy'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import withPolicy from './withPolicy'; +import type {WithPolicyProps} from './withPolicy'; +import ExpensiMark from 'expensify-common/lib/ExpensiMark'; +import updateMultilineInputRange from '@libs/updateMultilineInputRange'; + +type Props = WithPolicyProps; + +function WorkspaceDescriptionPage({policy}: Props) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const parser = new ExpensiMark(); + const [description, setDescription] = useState(() => parser.htmlToMarkdown(policy?.description ?? '')); + + const submit = useCallback( + (values: OnyxFormValuesFields) => { + if (!policy || policy.isPolicyUpdating) { + return; + } + + Policy.updateDescription(policy.id, values.description.trim(), policy.description ?? ''); + Keyboard.dismiss(); + Navigation.goBack(); + }, + [policy], + ); + + return ( + + Navigation.goBack()} + /> + + + + { + updateMultilineInputRange(el); + }} + containerStyles={[styles.autoGrowHeightMultilineInput]} + /> + + + + ); +} + +WorkspaceDescriptionPage.displayName = 'WorkspaceDescriptionPage'; + +export default withPolicy(WorkspaceDescriptionPage); diff --git a/src/pages/workspace/WorkspaceOverviewPage.js b/src/pages/workspace/WorkspaceOverviewPage.js index dd3945136c47..cbd0a0bf6001 100644 --- a/src/pages/workspace/WorkspaceOverviewPage.js +++ b/src/pages/workspace/WorkspaceOverviewPage.js @@ -117,6 +117,17 @@ function WorkspaceOverviewPage({policy, currencyList, route}) { shouldUseDefaultCursorWhenDisabled /> + Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(policy.id))} + shouldGreyOutWhenDisabled={false} + shouldUseDefaultCursorWhenDisabled + shouldRenderAsHTML + /> + ; +type WorkspaceDescriptionForm = Form<{ + description: string; +}>; + type ReportFieldEditForm = Form>; type CloseAccountForm = Form<{ @@ -89,4 +93,5 @@ export type { ReportFieldEditForm, CloseAccountForm, RoomNameForm, + WorkspaceDescriptionForm, }; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 4728c8872e75..4f954cc5681d 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -21,6 +21,7 @@ import type { ReportFieldEditForm, RoomNameForm, WorkspaceSettingsForm, + WorkspaceDescriptionForm, } from './Form'; import type Form from './Form'; import type FrequentlyUsedEmoji from './FrequentlyUsedEmoji'; @@ -158,6 +159,7 @@ export type { WalletTerms, WalletTransfer, WorkspaceSettingsForm, + WorkspaceDescriptionForm, ReportUserIsTyping, PolicyReportField, PolicyReportFields, From 841d2bf923c4a3ecc8f55655e4ee066c1c5b9546 Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 8 Feb 2024 18:59:19 +0530 Subject: [PATCH 02/21] Fix lint --- src/components/ReportWelcomeText.tsx | 2 +- src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts | 2 +- src/libs/actions/Policy.ts | 4 +--- src/pages/home/HeaderView.js | 4 +++- src/pages/workspace/WorkspaceDescriptionPage.tsx | 6 +++--- src/types/onyx/index.ts | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index eb02dc0ed1cb..23c6afeb1768 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -76,7 +76,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP > - ): ( + ) : ( {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')} {ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)} diff --git a/src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts b/src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts index a130ddadf16d..7fc6c2a4f952 100644 --- a/src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts +++ b/src/libs/API/parameters/UpdateWorkspaceDescriptionParams.ts @@ -3,4 +3,4 @@ type UpdateWorkspaceDescriptionParams = { description: string; }; -export default UpdateWorkspaceDescriptionParams; \ No newline at end of file +export default UpdateWorkspaceDescriptionParams; diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index cf9d74c14bb2..57972d92955e 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -21,8 +21,8 @@ import type { OpenWorkspaceReimburseViewParams, UpdateWorkspaceAvatarParams, UpdateWorkspaceCustomUnitAndRateParams, - UpdateWorkspaceGeneralSettingsParams, UpdateWorkspaceDescriptionParams, + UpdateWorkspaceGeneralSettingsParams, } from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; @@ -898,8 +898,6 @@ function updateDescription(policyID: string, description: string, currentDescrip } const parsedDescription = ReportUtils.getParsedComment(description); - console.log(parsedDescription); - const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 29db858b7eb8..53311833a6d4 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -40,7 +40,6 @@ import * as Task from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import { is } from 'date-fns/locale'; const propTypes = { /** Toggles the navigationMenu open and closed */ @@ -70,6 +69,9 @@ const propTypes = { /** The URL for the policy avatar */ avatar: PropTypes.string, + + /** The id of the policy */ + id: PropTypes.number, }), /** The reportID of the request */ diff --git a/src/pages/workspace/WorkspaceDescriptionPage.tsx b/src/pages/workspace/WorkspaceDescriptionPage.tsx index 807909168ca7..ada0e05fe2f3 100644 --- a/src/pages/workspace/WorkspaceDescriptionPage.tsx +++ b/src/pages/workspace/WorkspaceDescriptionPage.tsx @@ -1,3 +1,4 @@ +import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import React, {useCallback, useState} from 'react'; import {Keyboard, View} from 'react-native'; import FormProvider from '@components/Form/FormProvider'; @@ -6,17 +7,16 @@ import type {OnyxFormValuesFields} from '@components/Form/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import TextInput from '@components/TextInput'; +import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; -import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; +import updateMultilineInputRange from '@libs/updateMultilineInputRange'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import withPolicy from './withPolicy'; import type {WithPolicyProps} from './withPolicy'; -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; -import updateMultilineInputRange from '@libs/updateMultilineInputRange'; type Props = WithPolicyProps; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 4f954cc5681d..6b47985b583e 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -20,8 +20,8 @@ import type { PrivateNotesForm, ReportFieldEditForm, RoomNameForm, - WorkspaceSettingsForm, WorkspaceDescriptionForm, + WorkspaceSettingsForm, } from './Form'; import type Form from './Form'; import type FrequentlyUsedEmoji from './FrequentlyUsedEmoji'; From 8a0ca16f8cf681d7a09ae1e77c37b0355b49a09d Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 8 Feb 2024 19:11:17 +0530 Subject: [PATCH 03/21] Fix translations --- src/languages/es.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/languages/es.ts b/src/languages/es.ts index 3675d4b25eab..bc2081a7f0d0 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1690,6 +1690,8 @@ export default { `¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`, }, editor: { + descriptionInputLabel: 'Descripción del espacio de trabajo', + descriptionInputHelpText: 'Esta es una breve descripción de su espacio de trabajo.', nameInputLabel: 'Nombre', nameInputHelpText: 'Este es el nombre que verás en tu espacio de trabajo.', nameIsRequiredError: 'Debes definir un nombre para tu espacio de trabajo.', From 13e0c3e68b77588c77ad8cf9da909919fc753bc1 Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 8 Feb 2024 19:25:03 +0530 Subject: [PATCH 04/21] Fix subtitle expression --- src/pages/home/HeaderView.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 53311833a6d4..a815a2649c1f 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -120,7 +120,18 @@ function HeaderView(props) { const reportDescription = ReportUtils.getReportDescriptionText(props.report); const policyName = ReportUtils.getPolicyName(props.report); const policyDescription = ReportUtils.getPolicyDescriptionText(props.policy); - const shouldShowSubtitle = !_.isEmpty(subtitle) && (isChatRoom ? _.isEmpty(reportDescription) : isPolicyExpenseChat ? _.isEmpty(policyDescription) : true); + const shouldShowSubtitle = () => { + if (_.isEmpty(subtitle)) { + return false; + } + if (isChatRoom) { + return _.isEmpty(reportDescription); + } + if (isPolicyExpenseChat) { + return _.isEmpty(policyDescription); + } + return true; + }; // We hide the button when we are chatting with an automated Expensify account since it's not possible to contact // these users via alternative means. It is possible to request a call with Concierge so we leave the option for them. @@ -186,7 +197,7 @@ function HeaderView(props) { ); const renderAdditionalText = () => { - if (shouldShowSubtitle || _.isEmpty(policyName) || !_.isEmpty(parentNavigationSubtitleData)) { + if (shouldShowSubtitle() || _.isEmpty(policyName) || !_.isEmpty(parentNavigationSubtitleData)) { return null; } return ( @@ -304,7 +315,7 @@ function HeaderView(props) { pressableStyles={[styles.alignSelfStart, styles.mw100]} /> )} - {shouldShowSubtitle && ( + {shouldShowSubtitle() && ( Date: Thu, 8 Feb 2024 19:32:32 +0530 Subject: [PATCH 05/21] Fix memo --- src/pages/home/report/ReportActionItemCreated.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItemCreated.tsx b/src/pages/home/report/ReportActionItemCreated.tsx index afe97b2b95c1..476644aa5cc7 100644 --- a/src/pages/home/report/ReportActionItemCreated.tsx +++ b/src/pages/home/report/ReportActionItemCreated.tsx @@ -117,6 +117,7 @@ export default withOnyx Date: Thu, 8 Feb 2024 19:41:26 +0530 Subject: [PATCH 06/21] Update description report action --- src/CONST.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.ts b/src/CONST.ts index 6c726cde12f7..de216b121f3d 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -604,6 +604,7 @@ const CONST = { UPDATE_MAX_EXPENSE_AMOUNT: 'POLICYCHANGELOG_UPDATE_MAX_EXPENSE_AMOUNT', UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT: 'POLICYCHANGELOG_UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT', UPDATE_NAME: 'POLICYCHANGELOG_UPDATE_NAME', + UPDATE_DESCRIPTION: 'POLICYCHANGELOG_UPDATE_DESCRIPTION', UPDATE_OWNERSHIP: 'POLICYCHANGELOG_UPDATE_OWNERSHIP', UPDATE_REIMBURSEMENT_CHOICE: 'POLICYCHANGELOG_UPDATE_REIMBURSEMENT_CHOICE', UPDATE_REPORT_FIELD: 'POLICYCHANGELOG_UPDATE_REPORT_FIELD', From 2cd6b396d5616db1702068b22715775ae5a42dce Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 8 Feb 2024 21:40:52 +0530 Subject: [PATCH 07/21] Offline and personal expense header --- src/pages/home/HeaderView.js | 3 ++- src/pages/workspace/WorkspaceOverviewPage.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index a815a2649c1f..19553dec43f7 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -120,6 +120,7 @@ function HeaderView(props) { const reportDescription = ReportUtils.getReportDescriptionText(props.report); const policyName = ReportUtils.getPolicyName(props.report); const policyDescription = ReportUtils.getPolicyDescriptionText(props.policy); + const isPersonalExpenseChat = isPolicyExpenseChat && ReportUtils.isCurrentUserSubmitter(props.report.reportID); const shouldShowSubtitle = () => { if (_.isEmpty(subtitle)) { return false; @@ -197,7 +198,7 @@ function HeaderView(props) { ); const renderAdditionalText = () => { - if (shouldShowSubtitle() || _.isEmpty(policyName) || !_.isEmpty(parentNavigationSubtitleData)) { + if (shouldShowSubtitle() || isPersonalExpenseChat || _.isEmpty(policyName) || !_.isEmpty(parentNavigationSubtitleData)) { return null; } return ( diff --git a/src/pages/workspace/WorkspaceOverviewPage.js b/src/pages/workspace/WorkspaceOverviewPage.js index cbd0a0bf6001..0f784103d9c5 100644 --- a/src/pages/workspace/WorkspaceOverviewPage.js +++ b/src/pages/workspace/WorkspaceOverviewPage.js @@ -61,6 +61,7 @@ function WorkspaceOverviewPage({policy, currencyList, route}) { const policyName = lodashGet(policy, 'name', ''); const readOnly = !PolicyUtils.isPolicyAdmin(policy); + const pendingAction = lodashGet(policy, 'pendingFields.generalSettings') || lodashGet(policy, 'pendingFields.description'); return ( - + Date: Fri, 9 Feb 2024 22:29:45 +0530 Subject: [PATCH 08/21] Fix header for DMs and non Policy chats --- src/pages/home/HeaderView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 19553dec43f7..39d4c9e2699d 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -118,7 +118,7 @@ function HeaderView(props) { const canLeaveRoom = ReportUtils.canLeaveRoom(props.report, isPolicyMember); const isArchivedRoom = ReportUtils.isArchivedRoom(props.report); const reportDescription = ReportUtils.getReportDescriptionText(props.report); - const policyName = ReportUtils.getPolicyName(props.report); + const policyName = ReportUtils.getPolicyName(props.report, true); const policyDescription = ReportUtils.getPolicyDescriptionText(props.policy); const isPersonalExpenseChat = isPolicyExpenseChat && ReportUtils.isCurrentUserSubmitter(props.report.reportID); const shouldShowSubtitle = () => { From ea1d39f44d3c4db08845b26fd2dd6f9ff6bc3c98 Mon Sep 17 00:00:00 2001 From: someone-here Date: Fri, 9 Feb 2024 22:53:53 +0530 Subject: [PATCH 09/21] Fix proptypes and translations --- src/languages/en.ts | 1 - src/languages/es.ts | 1 - src/pages/home/HeaderView.js | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 783586a36ec7..6f281d877df3 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1668,7 +1668,6 @@ export default { }, editor: { descriptionInputLabel: 'Workspace description', - descriptionInputHelpText: 'This is a brief description of your workspace.', nameInputLabel: 'Name', nameInputHelpText: 'This is the name you will see on your workspace.', nameIsRequiredError: 'You need to define a name for your workspace.', diff --git a/src/languages/es.ts b/src/languages/es.ts index bc2081a7f0d0..5b23e1b37168 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1691,7 +1691,6 @@ export default { }, editor: { descriptionInputLabel: 'Descripción del espacio de trabajo', - descriptionInputHelpText: 'Esta es una breve descripción de su espacio de trabajo.', nameInputLabel: 'Nombre', nameInputHelpText: 'Este es el nombre que verás en tu espacio de trabajo.', nameIsRequiredError: 'Debes definir un nombre para tu espacio de trabajo.', diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 39d4c9e2699d..e59f69dcda7f 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -71,7 +71,7 @@ const propTypes = { avatar: PropTypes.string, /** The id of the policy */ - id: PropTypes.number, + id: PropTypes.string, }), /** The reportID of the request */ @@ -427,7 +427,7 @@ export default memo( }, policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, - // selector: (policy) => _.pick(policy, ['name', 'avatar', 'pendingAction, description']), + selector: (policy) => _.pick(policy, ['name', 'avatar', 'pendingAction', 'description']), }, personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, From 50611e805b77534f663f4de5a775964c24289622 Mon Sep 17 00:00:00 2001 From: someone-here Date: Fri, 9 Feb 2024 22:56:53 +0530 Subject: [PATCH 10/21] Fix policy --- src/pages/home/HeaderView.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index e59f69dcda7f..ae516bf73cd5 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -351,7 +351,7 @@ function HeaderView(props) { Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(props.report.policyID)); return; } - Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(props.policy.id)); + Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(props.report.policyID)); }} style={[styles.alignSelfStart, styles.mw100]} accessibilityLabel={translate('workspace.editor.descriptionInputLabel')} @@ -427,7 +427,6 @@ export default memo( }, policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, - selector: (policy) => _.pick(policy, ['name', 'avatar', 'pendingAction', 'description']), }, personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, From 5cf38eb08da0f2ce50dc939b8ad79f2a45a742be Mon Sep 17 00:00:00 2001 From: someone-here Date: Fri, 9 Feb 2024 23:02:37 +0530 Subject: [PATCH 11/21] Unlink workspace description from central pane --- .../Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 786331644b68..d61b36871434 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -2,7 +2,7 @@ import type {CentralPaneName} from '@libs/Navigation/types'; import SCREENS from '@src/SCREENS'; const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = { - [SCREENS.WORKSPACE.OVERVIEW]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY, SCREENS.WORKSPACE.DESCRIPTION], + [SCREENS.WORKSPACE.OVERVIEW]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY], [SCREENS.WORKSPACE.REIMBURSE]: [SCREENS.WORKSPACE.RATE_AND_UNIT], [SCREENS.WORKSPACE.MEMBERS]: [SCREENS.WORKSPACE.INVITE, SCREENS.WORKSPACE.INVITE_MESSAGE], }; From af8ccfe20e194c64e4354f3377ae6f403b84ac59 Mon Sep 17 00:00:00 2001 From: someone-here Date: Sun, 11 Feb 2024 17:57:09 +0530 Subject: [PATCH 12/21] Fix permission --- src/components/ReportWelcomeText.tsx | 5 ++--- src/pages/home/HeaderView.js | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 23c6afeb1768..0568cb383030 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -65,11 +65,10 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP {policy?.description ? ( { - if (ReportUtils.canEditPolicyDescription(policy)) { - Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(policy.id)); + if (!ReportUtils.canEditPolicyDescription(policy)) { return; } - Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policy.id)); + Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(policy.id)); }} style={styles.renderHTML} accessibilityLabel={translate('reportDescriptionPage.roomDescription')} diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 251aa73df4e3..9b60797bdd2c 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -328,11 +328,10 @@ function HeaderView(props) { {isPolicyExpenseChat && !_.isEmpty(policyDescription) && _.isEmpty(parentNavigationSubtitleData) && ( { - if (ReportUtils.canEditPolicyDescription(props.policy)) { - Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(props.report.policyID)); + if (!ReportUtils.canEditPolicyDescription(props.policy)) { return; } - Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(props.report.policyID)); + Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(props.report.policyID)); }} style={[styles.alignSelfStart, styles.mw100]} accessibilityLabel={translate('workspace.editor.descriptionInputLabel')} From 0c19017684c591f96c95e2ca76a9eaa2d0af2edb Mon Sep 17 00:00:00 2001 From: someone-here Date: Mon, 12 Feb 2024 18:57:19 +0530 Subject: [PATCH 13/21] Fix offline --- src/pages/workspace/WorkspaceProfilePage.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/WorkspaceProfilePage.js b/src/pages/workspace/WorkspaceProfilePage.js index da9884864c23..465fe90ef619 100644 --- a/src/pages/workspace/WorkspaceProfilePage.js +++ b/src/pages/workspace/WorkspaceProfilePage.js @@ -61,7 +61,6 @@ function WorkspaceProfilePage({policy, currencyList, route}) { const policyName = lodashGet(policy, 'name', ''); const readOnly = !PolicyUtils.isPolicyAdmin(policy); - const pendingAction = lodashGet(policy, 'pendingFields.generalSettings') || lodashGet(policy, 'pendingFields.description'); return ( - + - + + - + + Date: Mon, 12 Feb 2024 18:58:14 +0530 Subject: [PATCH 14/21] Make multiline text input 200px height --- src/stories/TextInput.stories.js | 2 +- src/styles/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stories/TextInput.stories.js b/src/stories/TextInput.stories.js index dd2fcced68b0..b5ec6bd3d274 100644 --- a/src/stories/TextInput.stories.js +++ b/src/stories/TextInput.stories.js @@ -140,7 +140,7 @@ AutoGrowHeightInput.args = { autoGrowHeight: true, textInputContainerStyles: [ { - maxHeight: 115, + maxHeight: 200, }, ], }; diff --git a/src/styles/index.ts b/src/styles/index.ts index 1bea3d298cd4..2ad7d196691b 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -3050,7 +3050,7 @@ const styles = (theme: ThemeColors) => }, autoGrowHeightMultilineInput: { - maxHeight: 115, + maxHeight: 200, }, peopleRow: { From 72d33dfd579989ec0b3ee774519816e2ed055041 Mon Sep 17 00:00:00 2001 From: someone-here Date: Tue, 13 Feb 2024 17:32:01 +0530 Subject: [PATCH 15/21] Reverse mutiline input change --- src/stories/TextInput.stories.js | 2 +- src/styles/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stories/TextInput.stories.js b/src/stories/TextInput.stories.js index b5ec6bd3d274..dd2fcced68b0 100644 --- a/src/stories/TextInput.stories.js +++ b/src/stories/TextInput.stories.js @@ -140,7 +140,7 @@ AutoGrowHeightInput.args = { autoGrowHeight: true, textInputContainerStyles: [ { - maxHeight: 200, + maxHeight: 115, }, ], }; diff --git a/src/styles/index.ts b/src/styles/index.ts index 9c3563bb5ab5..1d3e323d6bd1 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -3061,7 +3061,7 @@ const styles = (theme: ThemeColors) => }, autoGrowHeightMultilineInput: { - maxHeight: 200, + maxHeight: 115, }, peopleRow: { From 6d320d82e7720789a7e5064750f3a30925a4a531 Mon Sep 17 00:00:00 2001 From: someone-here Date: Tue, 13 Feb 2024 19:04:32 +0530 Subject: [PATCH 16/21] Fix cursor --- src/components/ReportWelcomeText.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 0568cb383030..2bfc43853899 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -43,6 +43,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(report, isUserPolicyAdmin); const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, policy, participantAccountIDs); const additionalText = moneyRequestOptions.map((item) => translate(`reportActionsView.iouTypes.${item}`)).join(', '); + const canEditPolicyDescription = ReportUtils.canEditPolicyDescription(policy); const navigateToReport = () => { if (!report?.reportID) { @@ -65,12 +66,12 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP {policy?.description ? ( { - if (!ReportUtils.canEditPolicyDescription(policy)) { + if (!canEditPolicyDescription) { return; } Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(policy.id)); }} - style={styles.renderHTML} + style={[styles.renderHTML, canEditPolicyDescription ? styles.cursorPointer : styles.cursorText]} accessibilityLabel={translate('reportDescriptionPage.roomDescription')} > From 1282d658f7d087bc57d06e6443ea2186c1819cc8 Mon Sep 17 00:00:00 2001 From: someone-here Date: Tue, 13 Feb 2024 19:09:56 +0530 Subject: [PATCH 17/21] Hide description if empty and non editable --- src/pages/workspace/WorkspaceProfilePage.js | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/pages/workspace/WorkspaceProfilePage.js b/src/pages/workspace/WorkspaceProfilePage.js index 465fe90ef619..887358cdf0a4 100644 --- a/src/pages/workspace/WorkspaceProfilePage.js +++ b/src/pages/workspace/WorkspaceProfilePage.js @@ -117,18 +117,20 @@ function WorkspaceProfilePage({policy, currencyList, route}) { shouldUseDefaultCursorWhenDisabled /> - - Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(policy.id))} - shouldGreyOutWhenDisabled={false} - shouldUseDefaultCursorWhenDisabled - shouldRenderAsHTML - /> - + {(!_.isEmpty(policy.description) || !readOnly) && ( + + Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(policy.id))} + shouldGreyOutWhenDisabled={false} + shouldUseDefaultCursorWhenDisabled + shouldRenderAsHTML + /> + + )} Date: Tue, 13 Feb 2024 19:27:10 +0530 Subject: [PATCH 18/21] Update src/pages/home/HeaderView.js Co-authored-by: Joel Davies --- src/pages/home/HeaderView.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 9b60797bdd2c..86b2d59c3898 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -328,10 +328,11 @@ function HeaderView(props) { {isPolicyExpenseChat && !_.isEmpty(policyDescription) && _.isEmpty(parentNavigationSubtitleData) && ( { - if (!ReportUtils.canEditPolicyDescription(props.policy)) { + if (ReportUtils.canEditPolicyDescription(props.policy)) { + Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(props.report.policyID)); return; } - Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(props.report.policyID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(props.reportID)); }} style={[styles.alignSelfStart, styles.mw100]} accessibilityLabel={translate('workspace.editor.descriptionInputLabel')} From 534fe747a7ce769ae7c076a69c53643b183395f2 Mon Sep 17 00:00:00 2001 From: someone-here Date: Tue, 13 Feb 2024 19:32:36 +0530 Subject: [PATCH 19/21] =?UTF-8?q?Prettify=20=F0=9F=92=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/home/HeaderView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 86b2d59c3898..d89eace9170d 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -329,7 +329,7 @@ function HeaderView(props) { { if (ReportUtils.canEditPolicyDescription(props.policy)) { - Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(props.report.policyID)); + Navigation.navigate(ROUTES.WORKSPACE_DESCRIPTION.getRoute(props.report.policyID)); return; } Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(props.reportID)); From 2f60134401f90c41fbc75433d6d1fad73696198a Mon Sep 17 00:00:00 2001 From: someone-here Date: Wed, 14 Feb 2024 19:46:56 +0530 Subject: [PATCH 20/21] Fix forms --- src/ONYXKEYS.ts | 4 ++-- src/pages/workspace/WorkspaceDescriptionPage.tsx | 8 ++++---- src/types/form/WorkspaceDescriptionForm.ts | 12 ++++++++++++ src/types/form/index.ts | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 src/types/form/WorkspaceDescriptionForm.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 11ec7efe0e2b..52bdc5658a9b 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -417,8 +417,8 @@ type OnyxFormValuesMapping = { [ONYXKEYS.FORMS.REPORT_FIELD_EDIT_FORM]: FormTypes.ReportFieldEditForm; [ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM]: FormTypes.ReimbursementAccountForm; [ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT]: FormTypes.PersonalBankAccountForm; - [ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM]: OnyxTypes.WorkspaceDescriptionForm; - [ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM_DRAFT]: OnyxTypes.WorkspaceDescriptionForm; + [ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM]: FormTypes.WorkspaceDescriptionForm; + [ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM_DRAFT]: FormTypes.WorkspaceDescriptionForm; }; type OnyxFormDraftValuesMapping = { diff --git a/src/pages/workspace/WorkspaceDescriptionPage.tsx b/src/pages/workspace/WorkspaceDescriptionPage.tsx index ada0e05fe2f3..327454fe9c3c 100644 --- a/src/pages/workspace/WorkspaceDescriptionPage.tsx +++ b/src/pages/workspace/WorkspaceDescriptionPage.tsx @@ -3,7 +3,7 @@ import React, {useCallback, useState} from 'react'; import {Keyboard, View} from 'react-native'; import FormProvider from '@components/Form/FormProvider'; import InputWrapper from '@components/Form/InputWrapper'; -import type {OnyxFormValuesFields} from '@components/Form/types'; +import type {FormOnyxValues} from '@components/Form/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import TextInput from '@components/TextInput'; @@ -18,16 +18,16 @@ import ONYXKEYS from '@src/ONYXKEYS'; import withPolicy from './withPolicy'; import type {WithPolicyProps} from './withPolicy'; -type Props = WithPolicyProps; +type WorkspaceDescriptionProps = WithPolicyProps; -function WorkspaceDescriptionPage({policy}: Props) { +function WorkspaceDescriptionPage({policy}: WorkspaceDescriptionProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const parser = new ExpensiMark(); const [description, setDescription] = useState(() => parser.htmlToMarkdown(policy?.description ?? '')); const submit = useCallback( - (values: OnyxFormValuesFields) => { + (values: FormOnyxValues) => { if (!policy || policy.isPolicyUpdating) { return; } diff --git a/src/types/form/WorkspaceDescriptionForm.ts b/src/types/form/WorkspaceDescriptionForm.ts new file mode 100644 index 000000000000..b06a37abf36b --- /dev/null +++ b/src/types/form/WorkspaceDescriptionForm.ts @@ -0,0 +1,12 @@ +import type Form from './Form'; + +const INPUT_IDS = { + DESCRIPTION: 'description', +} as const; + +type WorkspaceDescriptionForm = Form<{ + [INPUT_IDS.DESCRIPTION]: string; +}>; + +export type {WorkspaceDescriptionForm}; +export default INPUT_IDS; diff --git a/src/types/form/index.ts b/src/types/form/index.ts index eb691bcc8ca4..91fb14982293 100644 --- a/src/types/form/index.ts +++ b/src/types/form/index.ts @@ -32,4 +32,5 @@ export type {WaypointForm} from './WaypointForm'; export type {WorkspaceInviteMessageForm} from './WorkspaceInviteMessageForm'; export type {WorkspaceRateAndUnitForm} from './WorkspaceRateAndUnitForm'; export type {WorkspaceSettingsForm} from './WorkspaceSettingsForm'; +export type {WorkspaceDescriptionForm} from './WorkspaceDescriptionForm'; export type {default as Form} from './Form'; From 283aefdbee798cb6e799e8e704a90c1d003b72c3 Mon Sep 17 00:00:00 2001 From: someone-here Date: Wed, 14 Feb 2024 20:01:58 +0530 Subject: [PATCH 21/21] Fix drafts --- src/ONYXKEYS.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 52bdc5658a9b..5e41e08d0c78 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -418,7 +418,6 @@ type OnyxFormValuesMapping = { [ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM]: FormTypes.ReimbursementAccountForm; [ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT]: FormTypes.PersonalBankAccountForm; [ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM]: FormTypes.WorkspaceDescriptionForm; - [ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM_DRAFT]: FormTypes.WorkspaceDescriptionForm; }; type OnyxFormDraftValuesMapping = {