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

Adds support for mentions in room description #45352

Merged
merged 14 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Onyx.connect({
return;
}

accountIDToNameMap[personalDetails.accountID] = personalDetails.login ?? String(personalDetails.accountID);
accountIDToNameMap[personalDetails.accountID] = personalDetails.login ?? personalDetails.displayName ?? String(personalDetails.accountID);
});
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ function getReportActionMessageFragments(action: ReportAction): Message[] {
}

if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) {
const message = `${Localize.translateLocal('roomChangeLog.updateRoomDescription')} ${getOriginalMessage(action)?.description}`;
const message = getUpdateRoomDescriptionMessage(action);
return [{text: message, html: `<muted-text>${message}</muted-text>`, type: 'COMMENT'}];
}

Expand Down
8 changes: 8 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ type OutstandingChildRequest = {
type ParsingDetails = {
shouldEscapeText?: boolean;
reportID?: string;
policyID?: string;
};

let currentUserEmail: string | undefined;
Expand Down Expand Up @@ -3763,6 +3764,13 @@ function getParsedComment(text: string, parsingDetails?: ParsingDetails): string
isGroupPolicyReport = isReportInGroupPolicy(currentReport);
}

if (parsingDetails?.policyID) {
const policyType = getPolicy(parsingDetails?.policyID)?.type;
if (policyType) {
isGroupPolicyReport = isGroupPolicy(policyType);
}
}

const textWithMention = completeShortMention(text);

return text.length <= CONST.MAX_MARKUP_LENGTH
Expand Down
8 changes: 0 additions & 8 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,6 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={translate('iou.unheldExpense')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) {
children = <ReportActionItemBasicMessage message={translate('systemMessage.mergedWithCashTransaction')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
children = (
<ReportActionItemMessage
action={action}
reportID={report.reportID}
displayAsGroup={false}
/>
);
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getDismissedViolationMessageText(ReportActionsUtils.getOriginalMessage(action))} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG) {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/workspace/WorkspaceNewRoomPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli
*/
const submit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_ROOM_FORM>) => {
const participants = [session?.accountID ?? -1];
const parsedDescription = ReportUtils.getParsedComment(values.reportDescription ?? '');
const parsedDescription = ReportUtils.getParsedComment(values.reportDescription ?? '', {policyID});
const policyReport = ReportUtils.buildOptimisticChatReport(
participants,
values.roomName,
Expand Down Expand Up @@ -183,7 +183,7 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli
ErrorUtils.addErrorMessage(errors, 'roomName', translate('common.error.characterLimitExceedCounter', {length: values.roomName.length, limit: CONST.TITLE_CHARACTER_LIMIT}));
}

const descriptionLength = ReportUtils.getCommentLength(values.reportDescription);
const descriptionLength = ReportUtils.getCommentLength(values.reportDescription, {policyID});
if (descriptionLength > CONST.REPORT_DESCRIPTION.MAX_LENGTH) {
ErrorUtils.addErrorMessage(
errors,
Expand All @@ -198,7 +198,7 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli

return errors;
},
[reports, translate],
[reports, policyID, translate],
);

const writeCapabilityOptions = useMemo(
Expand Down
Loading