Skip to content

Commit

Permalink
Merge pull request #34150 from esh-g/room-description
Browse files Browse the repository at this point in the history
Migrate welcome message to room description for report
  • Loading branch information
puneetlath authored Feb 5, 2024
2 parents 5133c29 + 2df9043 commit 7511ec4
Show file tree
Hide file tree
Showing 44 changed files with 445 additions and 313 deletions.
5 changes: 4 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ const CONST = {
MAX_LENGTH: 40,
},

REPORT_DESCRIPTION: {
MAX_LENGTH: 1024,
},

PULL_REQUEST_NUMBER,

MERCHANT_NAME_MAX_LENGTH: 255,
Expand Down Expand Up @@ -1588,7 +1592,6 @@ const CONST = {
INVITE: 'invite',
SETTINGS: 'settings',
LEAVE_ROOM: 'leaveRoom',
WELCOME_MESSAGE: 'welcomeMessage',
PRIVATE_NOTES: 'privateNotes',
},
EDIT_REQUEST_FIELD: {
Expand Down
8 changes: 4 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ const ONYXKEYS = {
DISPLAY_NAME_FORM_DRAFT: 'displayNameFormDraft',
ROOM_NAME_FORM: 'roomNameForm',
ROOM_NAME_FORM_DRAFT: 'roomNameFormDraft',
WELCOME_MESSAGE_FORM: 'welcomeMessageForm',
WELCOME_MESSAGE_FORM_DRAFT: 'welcomeMessageFormDraft',
REPORT_DESCRIPTION_FORM: 'reportDescriptionForm',
REPORT_DESCRIPTION_FORM_DRAFT: 'reportDescriptionFormDraft',
LEGAL_NAME_FORM: 'legalNameForm',
LEGAL_NAME_FORM_DRAFT: 'legalNameFormDraft',
WORKSPACE_INVITE_MESSAGE_FORM: 'workspaceInviteMessageForm',
Expand Down Expand Up @@ -501,8 +501,8 @@ type OnyxValues = {
[ONYXKEYS.FORMS.DISPLAY_NAME_FORM_DRAFT]: OnyxTypes.DisplayNameForm;
[ONYXKEYS.FORMS.ROOM_NAME_FORM]: OnyxTypes.RoomNameForm;
[ONYXKEYS.FORMS.ROOM_NAME_FORM_DRAFT]: OnyxTypes.RoomNameForm;
[ONYXKEYS.FORMS.WELCOME_MESSAGE_FORM]: OnyxTypes.Form;
[ONYXKEYS.FORMS.WELCOME_MESSAGE_FORM_DRAFT]: OnyxTypes.Form;
[ONYXKEYS.FORMS.REPORT_DESCRIPTION_FORM]: OnyxTypes.Form;
[ONYXKEYS.FORMS.REPORT_DESCRIPTION_FORM_DRAFT]: OnyxTypes.Form;
[ONYXKEYS.FORMS.LEGAL_NAME_FORM]: OnyxTypes.Form;
[ONYXKEYS.FORMS.LEGAL_NAME_FORM_DRAFT]: OnyxTypes.Form;
[ONYXKEYS.FORMS.WORKSPACE_INVITE_MESSAGE_FORM]: OnyxTypes.Form;
Expand Down
6 changes: 1 addition & 5 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ const ROUTES = {
route: 'r/:reportID/settings/who-can-post',
getRoute: (reportID: string) => `r/${reportID}/settings/who-can-post` as const,
},
REPORT_WELCOME_MESSAGE: {
route: 'r/:reportID/welcomeMessage',
getRoute: (reportID: string) => `r/${reportID}/welcomeMessage` as const,
},
SPLIT_BILL_DETAILS: {
route: 'r/:reportID/split/:reportActionID',
getRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}` as const,
Expand All @@ -235,7 +231,7 @@ const ROUTES = {
route: 'r/:reportID/title',
getRoute: (reportID: string) => `r/${reportID}/title` as const,
},
TASK_DESCRIPTION: {
REPORT_DESCRIPTION: {
route: 'r/:reportID/description',
getRoute: (reportID: string) => `r/${reportID}/description` as const,
},
Expand Down
5 changes: 2 additions & 3 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const SCREENS = {
PROFILE: 'Profile',
REPORT_DETAILS: 'Report_Details',
REPORT_SETTINGS: 'Report_Settings',
REPORT_WELCOME_MESSAGE: 'Report_WelcomeMessage',
REPORT_DESCRIPTION: 'Report_Description',
PARTICIPANTS: 'Participants',
MONEY_REQUEST: 'MoneyRequest',
NEW_TASK: 'NewTask',
Expand Down Expand Up @@ -183,7 +183,6 @@ const SCREENS = {

TASK: {
TITLE: 'Task_Title',
DESCRIPTION: 'Task_Description',
ASSIGNEE: 'Task_Assignee',
},

Expand Down Expand Up @@ -242,7 +241,7 @@ const SCREENS = {
DETAILS_ROOT: 'Details_Root',
PROFILE_ROOT: 'Profile_Root',
PROCESS_MONEY_REQUEST_HOLD_ROOT: 'ProcessMoneyRequestHold_Root',
REPORT_WELCOME_MESSAGE_ROOT: 'Report_WelcomeMessage_Root',
REPORT_DESCRIPTION_ROOT: 'Report_Description_Root',
REPORT_PARTICIPANTS_ROOT: 'ReportParticipants_Root',
ROOM_MEMBERS_ROOT: 'RoomMembers_Root',
ROOM_INVITE_ROOT: 'RoomInvite_Root',
Expand Down
3 changes: 2 additions & 1 deletion src/components/DisplayNames/DisplayNamesWithTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type DisplayNamesProps from './types';

type HTMLElementWithText = HTMLElement & RNText;

function DisplayNamesWithToolTip({shouldUseFullTitle, fullTitle, displayNamesWithTooltips, textStyles = [], numberOfLines = 1}: DisplayNamesProps) {
function DisplayNamesWithToolTip({shouldUseFullTitle, fullTitle, displayNamesWithTooltips, textStyles = [], numberOfLines = 1, renderAdditionalText}: DisplayNamesProps) {
const styles = useThemeStyles();
const containerRef = useRef<HTMLElementWithText>(null);
const childRefs = useRef<HTMLElementWithText[]>([]);
Expand Down Expand Up @@ -72,6 +72,7 @@ function DisplayNamesWithToolTip({shouldUseFullTitle, fullTitle, displayNamesWit
{index < displayNamesWithTooltips.length - 1 && <Text style={textStyles}>,&nbsp;</Text>}
</Fragment>
))}
{renderAdditionalText?.()}
{Boolean(isEllipsisActive) && (
<View style={styles.displayNameTooltipEllipsis}>
<Tooltip text={fullTitle}>
Expand Down
6 changes: 5 additions & 1 deletion src/components/DisplayNames/DisplayNamesWithoutTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ type DisplayNamesWithoutTooltipProps = {

/** Number of lines before wrapping */
numberOfLines?: number;

/** Additional Text component to render after the displayNames */
renderAdditionalText?: () => React.ReactNode;
};

function DisplayNamesWithoutTooltip({textStyles = [], numberOfLines = 1, fullTitle = ''}: DisplayNamesWithoutTooltipProps) {
function DisplayNamesWithoutTooltip({textStyles = [], numberOfLines = 1, fullTitle = '', renderAdditionalText}: DisplayNamesWithoutTooltipProps) {
const styles = useThemeStyles();
return (
<Text
style={[textStyles, numberOfLines === 1 ? styles.pre : styles.preWrap]}
numberOfLines={numberOfLines}
>
{fullTitle}
{renderAdditionalText?.()}
</Text>
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/DisplayNames/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useLocalize from '@hooks/useLocalize';
import type DisplayNamesProps from './types';

// As we don't have to show tooltips of the Native platform so we simply render the full display names list.
function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfLines = 1}: DisplayNamesProps) {
function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfLines = 1, renderAdditionalText}: DisplayNamesProps) {
const {translate} = useLocalize();
return (
<Text
Expand All @@ -13,6 +13,7 @@ function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfL
numberOfLines={numberOfLines}
>
{fullTitle || translate('common.hidden')}
{renderAdditionalText?.()}
</Text>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/DisplayNames/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DisplayNamesWithoutTooltip from './DisplayNamesWithoutTooltip';
import DisplayNamesWithToolTip from './DisplayNamesWithTooltip';
import type DisplayNamesProps from './types';

function DisplayNames({fullTitle, tooltipEnabled, textStyles, numberOfLines, shouldUseFullTitle, displayNamesWithTooltips}: DisplayNamesProps) {
function DisplayNames({fullTitle, tooltipEnabled, textStyles, numberOfLines, shouldUseFullTitle, displayNamesWithTooltips, renderAdditionalText}: DisplayNamesProps) {
const {translate} = useLocalize();
const title = fullTitle || translate('common.hidden');

Expand All @@ -14,6 +14,7 @@ function DisplayNames({fullTitle, tooltipEnabled, textStyles, numberOfLines, sho
textStyles={textStyles}
numberOfLines={numberOfLines}
fullTitle={title}
renderAdditionalText={renderAdditionalText}
/>
);
}
Expand All @@ -35,6 +36,7 @@ function DisplayNames({fullTitle, tooltipEnabled, textStyles, numberOfLines, sho
displayNamesWithTooltips={displayNamesWithTooltips}
textStyles={textStyles}
numberOfLines={numberOfLines}
renderAdditionalText={renderAdditionalText}
/>
);
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/DisplayNames/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type DisplayNamesProps = {

/** If the full title needs to be displayed */
shouldUseFullTitle?: boolean;

/** Additional Text component to render after the displayNames */
renderAdditionalText?: () => React.ReactNode;
};

export default DisplayNamesProps;
Expand Down
4 changes: 3 additions & 1 deletion src/components/Form/FormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function FormWrapper({
formID,
scrollContextEnabled = false,
shouldHideFixErrorsAlert = false,
disablePressOnEnter = true,
}: FormWrapperProps) {
const styles = useThemeStyles();
const formRef = useRef<ScrollView>(null);
Expand Down Expand Up @@ -112,7 +113,7 @@ function FormWrapper({
containerStyles={[styles.mh0, styles.mt5, styles.flex1, submitButtonStyles]}
enabledWhenOffline={enabledWhenOffline}
isSubmitActionDangerous={isSubmitActionDangerous}
disablePressOnEnter
disablePressOnEnter={disablePressOnEnter}
/>
)}
</FormSubmit>
Expand All @@ -137,6 +138,7 @@ function FormWrapper({
submitButtonText,
shouldHideFixErrorsAlert,
onFixTheErrorsLinkPressed,
disablePressOnEnter,
],
);

Expand Down
3 changes: 3 additions & 0 deletions src/components/Form/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ type FormProps<TFormID extends OnyxFormKey = OnyxFormKey> = {

/** Custom content to display in the footer after submit button */
footerContent?: ReactNode;

/** Disable press on enter for submit button */
disablePressOnEnter?: boolean;
};

type RegisterInput = <TInputProps extends BaseInputProps>(inputID: keyof Form, inputProps: TInputProps) => TInputProps;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/TaskView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function TaskView({report, shouldShowHorizontalRule, ...props}: TaskViewProps) {
shouldParseTitle
description={translate('task.description')}
title={report.description ?? ''}
onPress={() => Navigation.navigate(ROUTES.TASK_DESCRIPTION.getRoute(report.reportID))}
onPress={() => Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report.reportID))}
shouldShowRightIcon={isOpen}
disabled={disableState}
wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]}
Expand Down
44 changes: 32 additions & 12 deletions src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {PersonalDetailsList, Policy, Report} from '@src/types/onyx';
import {PressableWithoutFeedback} from './Pressable';
import RenderHTML from './RenderHTML';
import Text from './Text';
import UserDetailsTooltip from './UserDetailsTooltip';

Expand Down Expand Up @@ -57,29 +59,47 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
{isChatRoom ? translate('reportActionsView.welcomeToRoom', {roomName: ReportUtils.getReportName(report)}) : translate('reportActionsView.sayHello')}
</Text>
</View>
<Text style={[styles.mt3, styles.mw100]}>
<View style={[styles.mt3, styles.mw100]}>
{isPolicyExpenseChat && (
<>
<Text>
<Text>{translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')}</Text>
<Text style={[styles.textStrong]}>{ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)}</Text>
<Text>{translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo')}</Text>
<Text style={[styles.textStrong]}>{ReportUtils.getPolicyName(report)}</Text>
<Text>{translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree')}</Text>
</>
</Text>
)}
{isChatRoom && (
<>
<Text>{roomWelcomeMessage.phrase1}</Text>
{roomWelcomeMessage.showReportName && (
<Text
style={[styles.textStrong]}
onPress={navigateToReport}
suppressHighlighting
{report?.description ? (
<PressableWithoutFeedback
onPress={() => {
if (ReportUtils.canEditReportDescription(report, policy)) {
Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report.reportID));
return;
}
Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID));
}}
style={styles.renderHTML}
accessibilityLabel={translate('reportDescriptionPage.roomDescription')}
>
{ReportUtils.getReportName(report)}
<RenderHTML html={report.description} />
</PressableWithoutFeedback>
) : (
<Text>
<Text>{roomWelcomeMessage.phrase1}</Text>
{roomWelcomeMessage.showReportName && (
<Text
style={[styles.textStrong]}
onPress={navigateToReport}
suppressHighlighting
>
{ReportUtils.getReportName(report)}
</Text>
)}
{roomWelcomeMessage.phrase2 !== undefined && <Text>{roomWelcomeMessage.phrase2}</Text>}
</Text>
)}
{roomWelcomeMessage.phrase2 !== undefined && <Text>{roomWelcomeMessage.phrase2}</Text>}
</>
)}
{isDefault && (
Expand Down Expand Up @@ -112,7 +132,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
{(moneyRequestOptions.includes(CONST.IOU.TYPE.SEND) || moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)) && (
<Text>{translate('reportActionsView.usePlusButton', {additionalText})}</Text>
)}
</Text>
</View>
</>
);
}
Expand Down
12 changes: 6 additions & 6 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export default {
chatWithAccountManager: 'Chat with your account manager here',
sayHello: 'Say hello!',
welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `Welcome to ${roomName}!`,
usePlusButton: ({additionalText}: UsePlusButtonParams) => `\n\nYou can also use the + button to ${additionalText}, or assign a task!`,
usePlusButton: ({additionalText}: UsePlusButtonParams) => `\nYou can also use the + button to ${additionalText}, or assign a task!`,
iouTypes: {
send: 'send money',
split: 'split a bill',
Expand Down Expand Up @@ -1054,10 +1054,10 @@ export default {
},
},
},
welcomeMessagePage: {
welcomeMessage: 'Welcome message',
welcomeMessageOptional: 'Welcome message (optional)',
explainerText: 'Set a custom welcome message that will be sent to users when they join this room.',
reportDescriptionPage: {
roomDescription: 'Room description',
roomDescriptionOptional: 'Room description (optional)',
explainerText: 'Set a custom decription for the room.',
},
languagePage: {
language: 'Language',
Expand Down Expand Up @@ -1970,7 +1970,7 @@ export default {
replies: 'Replies',
reply: 'Reply',
from: 'From',
in: 'In',
in: 'in',
parentNavigationSummary: ({rootReportName, workspaceName}: ParentNavigationSummaryParams) => `From ${rootReportName}${workspaceName ? ` in ${workspaceName}` : ''}`,
},
qrCodes: {
Expand Down
10 changes: 5 additions & 5 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export default {
chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí',
sayHello: '¡Saluda!',
welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `¡Bienvenido a ${roomName}!`,
usePlusButton: ({additionalText}: UsePlusButtonParams) => `\n\n¡También puedes usar el botón + de abajo para ${additionalText}, o asignar una tarea!`,
usePlusButton: ({additionalText}: UsePlusButtonParams) => `\n¡También puedes usar el botón + de abajo para ${additionalText}, o asignar una tarea!`,
iouTypes: {
send: 'enviar dinero',
split: 'dividir una factura',
Expand Down Expand Up @@ -1052,10 +1052,10 @@ export default {
},
},
},
welcomeMessagePage: {
welcomeMessage: 'Mensaje de bienvenida',
welcomeMessageOptional: 'Mensaje de bienvenida (opcional)',
explainerText: 'Configura un mensaje de bienvenida privado y personalizado que se enviará cuando los usuarios se unan a esta sala de chat.',
reportDescriptionPage: {
roomDescription: 'Descripción de la sala de chat',
roomDescriptionOptional: 'Descripción de la sala de chat (opcional)',
explainerText: 'Establece una descripción personalizada para la sala de chat.',
},
languagePage: {
language: 'Idioma',
Expand Down
2 changes: 1 addition & 1 deletion src/libs/API/parameters/AddWorkspaceRoomParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type AddWorkspaceRoomParams = {
reportName?: string;
visibility?: ValueOf<typeof CONST.REPORT.VISIBILITY>;
writeCapability?: WriteCapability;
welcomeMessage?: string;
description?: string;
};

export default AddWorkspaceRoomParams;
6 changes: 6 additions & 0 deletions src/libs/API/parameters/UpdateRoomDescriptionParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type UpdateRoomDescriptionParams = {
reportID: string;
description: string;
};

export default UpdateRoomDescriptionParams;
6 changes: 0 additions & 6 deletions src/libs/API/parameters/UpdateWelcomeMessageParams.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export type {default as TogglePinnedChatParams} from './TogglePinnedChatParams';
export type {default as DeleteCommentParams} from './DeleteCommentParams';
export type {default as UpdateCommentParams} from './UpdateCommentParams';
export type {default as UpdateReportNotificationPreferenceParams} from './UpdateReportNotificationPreferenceParams';
export type {default as UpdateWelcomeMessageParams} from './UpdateWelcomeMessageParams';
export type {default as UpdateRoomDescriptionParams} from './UpdateRoomDescriptionParams';
export type {default as UpdateReportWriteCapabilityParams} from './UpdateReportWriteCapabilityParams';
export type {default as AddWorkspaceRoomParams} from './AddWorkspaceRoomParams';
export type {default as UpdatePolicyRoomNameParams} from './UpdatePolicyRoomNameParams';
Expand Down
Loading

0 comments on commit 7511ec4

Please sign in to comment.