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

Support new action REMOVED_FROM_APPROVAL_CHAIN #48508

Merged
merged 17 commits into from
Sep 10, 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
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ const CONST = {
REIMBURSEMENT_SETUP: 'REIMBURSEMENTSETUP', // Deprecated OldDot Action
REIMBURSEMENT_SETUP_REQUESTED: 'REIMBURSEMENTSETUPREQUESTED', // Deprecated OldDot Action
REJECTED: 'REJECTED',
REMOVED_FROM_APPROVAL_CHAIN: 'REMOVEDFROMAPPROVALCHAIN',
RENAMED: 'RENAMED',
REPORT_PREVIEW: 'REPORTPREVIEW',
SELECTED_FOR_RANDOM_AUDIT: 'SELECTEDFORRANDOMAUDIT', // OldDot Action
Expand Down
13 changes: 13 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3851,6 +3851,19 @@ export default {
},
workspaceActions: {
renamedWorkspaceNameAction: ({oldName, newName}) => `updated the name of this workspace from ${oldName} to ${newName}`,
removedFromApprovalWorkflow: ({submittersNames}: {submittersNames: string[]}) => {
let joinedNames = '';
if (submittersNames.length === 1) {
joinedNames = submittersNames[0];
} else if (submittersNames.length === 2) {
joinedNames = submittersNames.join(' and ');
} else if (submittersNames.length > 2) {
joinedNames = `${submittersNames.slice(0, submittersNames.length - 1).join(', ')} and ${submittersNames[submittersNames.length - 1]}`;
}
const workflowWord = Str.pluralize('workflow', 'workflows', submittersNames.length);
const chatWord = Str.pluralize('chat', 'chats', submittersNames.length);
return `removed you from ${joinedNames}'s approval ${workflowWord} and workspace ${chatWord}. Previously submitted reports will remain available for approval in your Inbox.`;
},
},
roomMembersPage: {
memberNotFound: 'Member not found.',
Expand Down
13 changes: 13 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3902,6 +3902,19 @@ export default {
},
workspaceActions: {
renamedWorkspaceNameAction: ({oldName, newName}) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`,
removedFromApprovalWorkflow: ({submittersNames}: {submittersNames: string[]}) => {
let joinedNames = '';
if (submittersNames.length === 1) {
joinedNames = submittersNames[0];
} else if (submittersNames.length === 2) {
joinedNames = submittersNames.join(' y ');
} else if (submittersNames.length > 2) {
joinedNames = `${submittersNames.slice(0, submittersNames.length - 1).join(', ')} y ${submittersNames[submittersNames.length - 1]}`;
}
const workflowWord = Str.pluralize('del flujo', 'de los flujos', submittersNames.length);
const chatWord = Str.pluralize('del chat', 'de los chats', submittersNames.length);
return `te eliminó ${workflowWord} de trabajo de aprobaciones y ${chatWord} del espacio de trabajo de ${joinedNames}. Los informes enviados anteriormente seguirán estando disponibles para su aprobación en tu bandeja de entrada.`;
},
},
roomMembersPage: {
memberNotFound: 'Miembro no encontrado.',
Expand Down
15 changes: 12 additions & 3 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1649,13 +1649,21 @@ function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry<Re
}

function getRenamedAction(reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.RENAMED>>) {
const initialMessage = getOriginalMessage(reportAction);
const originalMessage = getOriginalMessage(reportAction);
return Localize.translateLocal('newRoomPage.renamedRoomAction', {
oldName: initialMessage?.oldName ?? '',
newName: initialMessage?.newName ?? '',
oldName: originalMessage?.oldName ?? '',
newName: originalMessage?.newName ?? '',
});
}

function getRemovedFromApprovalChainMessage(reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN>>) {
const originalMessage = getOriginalMessage(reportAction);
const submittersNames = PersonalDetailsUtils.getPersonalDetailsByIDs(originalMessage?.submittersAccountIDs ?? [], currentUserAccountID ?? -1).map(
({displayName, login}) => displayName ?? login ?? 'Unknown Submitter',
);
return Localize.translateLocal('workspaceActions.removedFromApprovalWorkflow', {submittersNames});
}

export {
doesReportHaveVisibleActions,
extractLinksFromMessageHtml,
Expand All @@ -1682,6 +1690,7 @@ export {
getOneTransactionThreadReportID,
getOriginalMessage,
getParentReportAction,
getRemovedFromApprovalChainMessage,
getReportAction,
getReportActionHtml,
getReportActionMessage,
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,8 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(action)} />;
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getRemovedFromApprovalChainMessage(action)} />;
} else if (
ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL, CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS)
) {
Expand Down
12 changes: 11 additions & 1 deletion src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,15 @@ type OriginalMessageUnapproved = {
expenseReportID: string;
};

/** Model of `Removed From Approval Chain` report action */
type OriginalMessageRemovedFromApprovalChain = {
/** The submitter IDs whose approval chains changed such that the approver was removed from their approval chains */
submittersAccountIDs: number[];

/** The accountID of the approver who was removed from the submitter's approval chain */
whisperedTo: number[];
};

/**
* Model of `Add payment card` report action
*/
Expand Down Expand Up @@ -557,8 +566,9 @@ type OriginalMessageMap = {
[CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED]: OriginalMessageReimbursementDequeued;
[CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DELAYED]: never;
[CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED]: OriginalMessageReimbursementQueued;
[CONST.REPORT.ACTIONS.TYPE.RENAMED]: OriginalMessageRenamed;
[CONST.REPORT.ACTIONS.TYPE.REJECTED]: never;
[CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN]: OriginalMessageRemovedFromApprovalChain;
[CONST.REPORT.ACTIONS.TYPE.RENAMED]: OriginalMessageRenamed;
[CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW]: OriginalMessageReportPreview;
[CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT]: never;
[CONST.REPORT.ACTIONS.TYPE.SHARE]: never;
Expand Down
Loading