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

Add support for demotion from workspace action report #56288

Merged
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 @@ -1141,6 +1141,7 @@ const CONST = {
REIMBURSEMENT_SETUP_REQUESTED: 'REIMBURSEMENTSETUPREQUESTED', // Deprecated OldDot Action
REJECTED: 'REJECTED',
REMOVED_FROM_APPROVAL_CHAIN: 'REMOVEDFROMAPPROVALCHAIN',
DEMOTED_FROM_WORKSPACE: 'DEMOTEDFROMWORKSPACE',
RENAMED: 'RENAMED',
REPORT_PREVIEW: 'REPORTPREVIEW',
SELECTED_FOR_RANDOM_AUDIT: 'SELECTEDFORRANDOMAUDIT', // OldDot Action
Expand Down
3 changes: 3 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import type {
DeleteActionParams,
DeleteConfirmationParams,
DeleteTransactionParams,
DemotedFromWorkspaceParams,
DidSplitAmountMessageParams,
EarlyDiscountSubtitleParams,
EarlyDiscountTitleParams,
Expand Down Expand Up @@ -4866,6 +4867,8 @@ const translations = {
other: `removed you from ${joinedNames}'s approval workflows and workspace chats. Previously submitted reports will remain available for approval in your Inbox.`,
};
},
demotedFromWorkspace: ({policyName, oldRole}: DemotedFromWorkspaceParams) =>
`updated your role in ${policyName} from ${oldRole} to user. You have been removed from all submitter workspace chats except for you own.`,
heekinho marked this conversation as resolved.
Show resolved Hide resolved
updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `updated the default currency to ${newCurrency} (previously ${oldCurrency})`,
updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) =>
`updated the auto-reporting frequency to "${newFrequency}" (previously "${oldFrequency}")`,
Expand Down
3 changes: 3 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import type {
DeleteActionParams,
DeleteConfirmationParams,
DeleteTransactionParams,
DemotedFromWorkspaceParams,
DidSplitAmountMessageParams,
EarlyDiscountSubtitleParams,
EarlyDiscountTitleParams,
Expand Down Expand Up @@ -4920,6 +4921,8 @@ const translations = {
other: `te eliminó de los flujos de trabajo de aprobaciones y de los chats del espacio de trabajo de ${joinedNames}. Los informes enviados anteriormente seguirán estando disponibles para su aprobación en tu bandeja de entrada.`,
};
},
demotedFromWorkspace: ({policyName, oldRole}: DemotedFromWorkspaceParams) =>
`cambió tu rol en ${policyName} de ${oldRole} a miembro. Te eliminamos de todos los chats del espacio de trabajo, excepto el suyo.`,
updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `actualizó la moneda predeterminada a ${newCurrency} (previamente ${oldCurrency})`,
updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) =>
`actualizó la frecuencia de generación automática de informes a "${newFrequency}" (previamente "${oldFrequency}")`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ type RemovedFromApprovalWorkflowParams = {
submittersNames: string[];
};

type DemotedFromWorkspaceParams = {
policyName: string;
oldRole: string;
};

type IntegrationExportParams = {
integration: string;
type?: string;
Expand Down Expand Up @@ -654,6 +659,7 @@ export type {
ConnectionParams,
IntegrationExportParams,
RemovedFromApprovalWorkflowParams,
DemotedFromWorkspaceParams,
DefaultAmountParams,
AutoPayApprovedReportsLimitErrorParams,
FeatureNameParams,
Expand Down
8 changes: 8 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,13 @@ function getRemovedFromApprovalChainMessage(reportAction: OnyxEntry<ReportAction
return translateLocal('workspaceActions.removedFromApprovalWorkflow', {submittersNames, count: submittersNames.length});
}

function getDemotedFromWorkspaceMessage(reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DEMOTED_FROM_WORKSPACE>>) {
const originalMessage = getOriginalMessage(reportAction);
const policyName = originalMessage?.policyName ?? translateLocal('workspace.common.workspace');
const oldRole = translateLocal('workspace.common.roleName', {role: originalMessage?.oldRole}).toLowerCase();
heekinho marked this conversation as resolved.
Show resolved Hide resolved
return translateLocal('workspaceActions.demotedFromWorkspace', {policyName, oldRole});
}

function isCardIssuedAction(reportAction: OnyxEntry<ReportAction>) {
return isActionOfType(
reportAction,
Expand Down Expand Up @@ -2226,6 +2233,7 @@ export {
getOneTransactionThreadReportID,
getOriginalMessage,
getRemovedFromApprovalChainMessage,
getDemotedFromWorkspaceMessage,
getReportAction,
getReportActionHtml,
getReportActionMessage,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {getCleanedTagName} from '@libs/PolicyUtils';
import {
extractLinksFromMessageHtml,
getAllReportActions,
getDemotedFromWorkspaceMessage,
getDismissedViolationMessageText,
getIOUReportIDFromReportActionPreview,
getOriginalMessage,
Expand Down Expand Up @@ -924,6 +925,8 @@ function PureReportActionItem({
children = <ReportActionItemBasicMessage message={getPolicyChangeLogDeleteMemberMessage(action)} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) {
children = <ReportActionItemBasicMessage message={getRemovedFromApprovalChainMessage(action)} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DEMOTED_FROM_WORKSPACE)) {
children = <ReportActionItemBasicMessage message={getDemotedFromWorkspaceMessage(action)} />;
} else if (
isActionOfType(
action,
Expand Down
13 changes: 13 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,18 @@ type OriginalMessageRemovedFromApprovalChain = {
whisperedTo: number[];
};

/** Model of `Demoted From Workspace` report action */
type OriginalMessageDemotedFromWorkspace = {
/** The policy name */
policyName: string;

/** The old role of the employee that is being demoted */
oldRole: string;

/** The accountID of the member who was demoted from workspace */
whisperedTo: number[];
};

/**
* Model of `Add payment card` report action
*/
Expand Down Expand Up @@ -745,6 +757,7 @@ type OriginalMessageMap = {
[CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED]: OriginalMessageReimbursementQueued;
[CONST.REPORT.ACTIONS.TYPE.REJECTED]: never;
[CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN]: OriginalMessageRemovedFromApprovalChain;
[CONST.REPORT.ACTIONS.TYPE.DEMOTED_FROM_WORKSPACE]: OriginalMessageDemotedFromWorkspace;
[CONST.REPORT.ACTIONS.TYPE.RENAMED]: OriginalMessageRenamed;
[CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW]: OriginalMessageReportPreview;
[CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT]: never;
Expand Down