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

fix: show correct message when disconnecting quickbooks desktop #49834

Merged
merged 14 commits into from
Oct 1, 2024
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4270,6 +4270,7 @@ const translations = {
addEmployee: ({email, role}: AddEmployeeParams) => `added ${email} as ${role === 'user' ? 'member' : 'admin'}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `updated the role of ${email} from ${currentRole} to ${newRole}`,
removeMember: ({email, role}: AddEmployeeParams) => `removed ${role} ${email}`,
removedConnection: ({connectionName}: ConnectionNameParams) => `Removed connection to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}.`,
daledah marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4316,6 +4316,7 @@ const translations = {
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) =>
`actualicé el rol ${email} de ${currentRole === 'user' ? 'miembro' : 'administrador'} a ${newRole === 'user' ? 'miembro' : 'administrador'}`,
removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role === 'user' ? 'miembro' : 'administrador'} ${email}`,
removedConnection: ({connectionName}: ConnectionNameParams) => `Conexión eliminada a ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}.`,
daledah marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {OnyxInputOrEntry, ReportAction} from '@src/types/onyx';
import type {DelegateRole} from '@src/types/onyx/Account';
import type {ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy';
import type {AllConnectionName, ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy';
import type {ViolationDataType} from '@src/types/onyx/TransactionViolation';

type AddressLineParams = {
Expand Down Expand Up @@ -338,7 +338,7 @@ type ApprovalWorkflowErrorParams = {
};

type ConnectionNameParams = {
connectionName: ConnectionName;
connectionName: AllConnectionName;
};

type LastSyncDateParams = {
Expand Down
10 changes: 10 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,15 @@ function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry<Re
return Localize.translateLocal('report.actions.type.removeMember', {email, role});
}

function getRemovedConnectionMessage(reportAction: OnyxEntry<ReportAction>): string {
if (!isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
daledah marked this conversation as resolved.
Show resolved Hide resolved
return '';
}
const originalMessage = getOriginalMessage(reportAction);
const connectionName = originalMessage?.connectionName;
return connectionName ? Localize.translateLocal('report.actions.type.removedConnection', {connectionName}) : '';
}

function getRenamedAction(reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.RENAMED>>) {
const originalMessage = getOriginalMessage(reportAction);
return Localize.translateLocal('newRoomPage.renamedRoomAction', {
Expand Down Expand Up @@ -1882,6 +1891,7 @@ export {
isCardIssuedAction,
getCardIssuedMessage,
hasSameActorForAllTransactions,
getRemovedConnectionMessage,
};

export type {LastVisibleMessage};
2 changes: 2 additions & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ function getOptionData({
result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) {
result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? '';
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) {
daledah marked this conversation as resolved.
Show resolved Hide resolved
result.alternateText = ReportActionsUtils.getRemovedConnectionMessage(lastAction);
} else {
result.alternateText =
lastMessageTextFromReport.length > 0
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ const ContextMenuActions: ContextMenuAction[] = [
setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage}));
} else if (ReportActionsUtils.isCardIssuedAction(reportAction)) {
setClipboardMessage(ReportActionsUtils.getCardIssuedMessage(reportAction, true));
} else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
setClipboardMessage(ReportActionsUtils.getRemovedConnectionMessage(reportAction));
} else if (content) {
setClipboardMessage(
content.replace(/(<mention-user>)(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => {
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 @@ -683,6 +683,8 @@ function ReportActionItem({
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) {
const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(action) ?? {label: '', errorMessage: ''};
children = <ReportActionItemBasicMessage message={translate('report.actions.type.integrationSyncFailed', {label, errorMessage})} />;
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getRemovedConnectionMessage(action)} />;
} else {
const hasBeenFlagged =
![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) &&
Expand Down
4 changes: 4 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type {OldDotOriginalMessageMap} from './OldDotAction';
import type {AllConnectionName} from './Policy';
import type ReportActionName from './ReportActionName';

/** Types of join workspace resolutions */
Expand Down Expand Up @@ -271,6 +272,9 @@ type OriginalMessageChangeLog = {

/** Old role of user */
oldValue?: string;

/** Name of connection */
connectionName?: AllConnectionName;
};

/** Model of `join policy changelog` report action */
Expand Down
11 changes: 11 additions & 0 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1232,9 +1232,19 @@ type Connections = {
[CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT]: Connection<SageIntacctConnectionData, SageIntacctConnectionsConfig>;
};

/** All integration connections, including unsupported ones */
type AllConnections = Connections & {
/** Quickbooks Desktop integration connection */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
quickbooksDesktop: any;
};

/** Names of integration connections */
type ConnectionName = keyof Connections;

/** Names of all integration connections */
type AllConnectionName = keyof AllConnections;

/** Merchant Category Code. This is a way to identify the type of merchant (and type of spend) when a credit card is swiped. */
type MccGroup = {
/** Default category for provided MCC Group */
Expand Down Expand Up @@ -1728,6 +1738,7 @@ export type {
Connections,
SageIntacctOfflineStateKeys,
ConnectionName,
AllConnectionName,
Tenant,
Account,
QBONonReimbursableExportAccountType,
Expand Down
Loading