Skip to content

Commit

Permalink
Merge pull request #36432 from rayane-djouah/Update-archive-messages-…
Browse files Browse the repository at this point in the history
…for-threads

Update archive messages for threads
  • Loading branch information
neil-marcellini authored Mar 11, 2024
2 parents abaf874 + 6099996 commit 5f520f1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/components/ArchivedReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import {getCurrentUserAccountID} from '@libs/actions/Report';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
Expand Down Expand Up @@ -31,7 +32,8 @@ function ArchivedReportFooter({report, reportClosedAction, personalDetails = {}}

const originalMessage = reportClosedAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED ? reportClosedAction.originalMessage : null;
const archiveReason = originalMessage?.reason ?? CONST.REPORT.ARCHIVE_REASON.DEFAULT;
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[report?.ownerAccountID ?? 0]);
const actorPersonalDetails = personalDetails?.[reportClosedAction?.actorAccountID ?? 0];
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(actorPersonalDetails);

let oldDisplayName: string | undefined;
if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED) {
Expand All @@ -56,6 +58,7 @@ function ArchivedReportFooter({report, reportClosedAction, personalDetails = {}}
displayName: `<strong>${displayName}</strong>`,
oldDisplayName: `<strong>${oldDisplayName}</strong>`,
policyName: `<strong>${policyName}</strong>`,
shouldUseYou: actorPersonalDetails?.accountID === getCurrentUserAccountID(),
})
: translate(`reportArchiveReasons.${archiveReason}`);

Expand Down
13 changes: 7 additions & 6 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,15 @@ export default {
},
reportArchiveReasons: {
[CONST.REPORT.ARCHIVE_REASON.DEFAULT]: 'This chat room has been archived.',
[CONST.REPORT.ARCHIVE_REASON.ACCOUNT_CLOSED]: ({displayName}: ReportArchiveReasonsClosedParams) =>
`This workspace chat is no longer active because ${displayName} closed their account.`,
[CONST.REPORT.ARCHIVE_REASON.ACCOUNT_CLOSED]: ({displayName}: ReportArchiveReasonsClosedParams) => `This chat is no longer active because ${displayName} closed their account.`,
[CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED]: ({displayName, oldDisplayName}: ReportArchiveReasonsMergedParams) =>
`This workspace chat is no longer active because ${oldDisplayName} has merged their account with ${displayName}.`,
[CONST.REPORT.ARCHIVE_REASON.REMOVED_FROM_POLICY]: ({displayName, policyName}: ReportArchiveReasonsRemovedFromPolicyParams) =>
`This workspace chat is no longer active because ${displayName} is no longer a member of the ${policyName} workspace.`,
`This chat is no longer active because ${oldDisplayName} has merged their account with ${displayName}.`,
[CONST.REPORT.ARCHIVE_REASON.REMOVED_FROM_POLICY]: ({displayName, policyName, shouldUseYou = false}: ReportArchiveReasonsRemovedFromPolicyParams) =>
shouldUseYou
? `This chat is no longer active because <strong>you</strong> are no longer a member of the ${policyName} workspace.`
: `This chat is no longer active because ${displayName} is no longer a member of the ${policyName} workspace.`,
[CONST.REPORT.ARCHIVE_REASON.POLICY_DELETED]: ({policyName}: ReportArchiveReasonsPolicyDeletedParams) =>
`This workspace chat is no longer active because ${policyName} is no longer an active workspace.`,
`This chat is no longer active because ${policyName} is no longer an active workspace.`,
},
writeCapabilityPage: {
label: 'Who can post',
Expand Down
13 changes: 7 additions & 6 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,15 @@ export default {
},
reportArchiveReasons: {
[CONST.REPORT.ARCHIVE_REASON.DEFAULT]: 'Esta sala de chat ha sido eliminada.',
[CONST.REPORT.ARCHIVE_REASON.ACCOUNT_CLOSED]: ({displayName}: ReportArchiveReasonsClosedParams) =>
`Este chat de espacio de trabajo esta desactivado porque ${displayName} ha cerrado su cuenta.`,
[CONST.REPORT.ARCHIVE_REASON.ACCOUNT_CLOSED]: ({displayName}: ReportArchiveReasonsClosedParams) => `Este chat está desactivado porque ${displayName} ha cerrado su cuenta.`,
[CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED]: ({displayName, oldDisplayName}: ReportArchiveReasonsMergedParams) =>
`Este chat de espacio de trabajo esta desactivado porque ${oldDisplayName} ha combinado su cuenta con ${displayName}.`,
[CONST.REPORT.ARCHIVE_REASON.REMOVED_FROM_POLICY]: ({displayName, policyName}: ReportArchiveReasonsRemovedFromPolicyParams) =>
`Este chat de espacio de trabajo esta desactivado porque ${displayName} ha dejado de ser miembro del espacio de trabajo ${policyName}.`,
`Este chat está desactivado porque ${oldDisplayName} ha combinado su cuenta con ${displayName}`,
[CONST.REPORT.ARCHIVE_REASON.REMOVED_FROM_POLICY]: ({displayName, policyName, shouldUseYou = false}: ReportArchiveReasonsRemovedFromPolicyParams) =>
shouldUseYou
? `Este chat ya no está activo porque <strong>tu</strong> ya no eres miembro del espacio de trabajo ${policyName}.`
: `Este chat está desactivado porque ${displayName} ha dejado de ser miembro del espacio de trabajo ${policyName}.`,
[CONST.REPORT.ARCHIVE_REASON.POLICY_DELETED]: ({policyName}: ReportArchiveReasonsPolicyDeletedParams) =>
`Este chat de espacio de trabajo esta desactivado porque el espacio de trabajo ${policyName} se ha eliminado.`,
`Este chat está desactivado porque el espacio de trabajo ${policyName} se ha eliminado.`,
},
writeCapabilityPage: {
label: 'Quién puede postear',
Expand Down
1 change: 1 addition & 0 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type ReportArchiveReasonsMergedParams = {
type ReportArchiveReasonsRemovedFromPolicyParams = {
displayName: string;
policyName: string;
shouldUseYou?: boolean;
};

type ReportArchiveReasonsPolicyDeletedParams = {
Expand Down
9 changes: 8 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,11 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
const parentReportAction = ReportActionsUtils.getParentReportAction(report);
if (isChatThread(report)) {
if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) {
return getTransactionReportName(parentReportAction);
formattedName = getTransactionReportName(parentReportAction);
if (isArchivedRoom(report)) {
formattedName += ` (${Localize.translateLocal('common.archived')})`;
}
return formattedName;
}

if (parentReportAction?.message?.[0]?.isDeletedParentAction) {
Expand All @@ -2632,6 +2636,9 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
if (isAdminRoom(report) || isUserCreatedPolicyRoom(report)) {
return getAdminRoomInvitedParticipants(parentReportAction, parentReportActionMessage);
}
if (parentReportActionMessage && isArchivedRoom(report)) {
return `${parentReportActionMessage} (${Localize.translateLocal('common.archived')})`;
}
return parentReportActionMessage;
}

Expand Down
4 changes: 1 addition & 3 deletions tests/unit/SidebarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ describe('Sidebar', () => {

const hintMessagePreviewText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview');
const messagePreviewTexts = screen.queryAllByLabelText(hintMessagePreviewText);
expect(lodashGet(messagePreviewTexts, [0, 'props', 'children'])).toBe(
'This workspace chat is no longer active because Vikings Policy is no longer an active workspace.',
);
expect(lodashGet(messagePreviewTexts, [0, 'props', 'children'])).toBe('This chat is no longer active because Vikings Policy is no longer an active workspace.');
})
);
});
Expand Down

0 comments on commit 5f520f1

Please sign in to comment.