Skip to content

Commit

Permalink
add copy onyx data option for reports in LHP
Browse files Browse the repository at this point in the history
  • Loading branch information
cdOut committed Jul 9, 2024
1 parent 9c32293 commit 9807c47
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ export default {
replyInThread: 'Reply in thread',
joinThread: 'Join thread',
leaveThread: 'Leave thread',
copyOnyxData: 'Copy Onyx data',
flagAsOffensive: 'Flag as offensive',
menu: 'Menu',
},
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ export default {
replyInThread: 'Responder en el hilo',
joinThread: 'Unirse al hilo',
leaveThread: 'Dejar hilo',
copyOnyxData: 'Copiar datos de Onyx',
flagAsOffensive: 'Marcar como ofensivo',
menu: 'Menú',
},
Expand Down
9 changes: 8 additions & 1 deletion src/libs/Environment/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ function isDevelopment(): boolean {
return (Config?.ENVIRONMENT ?? CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.DEV;
}

/**
* Are we running the app in staging?
*/
function isStaging(): boolean {
return (Config?.ENVIRONMENT ?? CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.STAGING;
}

/**
* Are we running the app in production?
*/
Expand Down Expand Up @@ -76,4 +83,4 @@ function getSpotnanaEnvironmentTMCID(): Promise<string> {
return getEnvironment().then((environment) => SPOTNANA_ENVIRONMENT_TMC_ID[environment]);
}

export {getEnvironment, isInternalTestBuild, isDevelopment, isProduction, getEnvironmentURL, getOldDotEnvironmentURL, getTravelDotEnvironmentURL, getSpotnanaEnvironmentTMCID};
export {getEnvironment, isInternalTestBuild, isDevelopment, isStaging, isProduction, getEnvironmentURL, getOldDotEnvironmentURL, getTravelDotEnvironmentURL, getSpotnanaEnvironmentTMCID};
16 changes: 16 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import Navigation from '@libs/Navigation/Navigation';
import Parser from '@libs/Parser';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportConnection from '@libs/ReportConnection';
import * as ReportUtils from '@libs/ReportUtils';
import * as TaskUtils from '@libs/TaskUtils';
import * as Download from '@userActions/Download';
import * as Report from '@userActions/Report';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Beta, OnyxInputOrEntry, ReportAction, ReportActionReactions, Transaction} from '@src/types/onyx';
import type IconAsset from '@src/types/utils/IconAsset';
Expand Down Expand Up @@ -524,6 +526,20 @@ const ContextMenuActions: ContextMenuAction[] = [
},
getDescription: () => {},
},
{
isAnonymousAction: true,
textTranslateKey: 'reportActionContextMenu.copyOnyxData',
icon: Expensicons.Copy,
successTextTranslateKey: 'reportActionContextMenu.copied',
successIcon: Expensicons.Checkmark,
shouldShow: (type) => type === CONST.CONTEXT_MENU_TYPES.REPORT && (Environment.isDevelopment() || Environment.isStaging() || Environment.isInternalTestBuild()),
onPress: (closePopover, {reportID}) => {
const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
Clipboard.setString(JSON.stringify(report, null, 4));
hideContextMenu(true, ReportActionComposeFocusManager.focus);
},
getDescription: () => {},
},
{
isAnonymousAction: false,
textTranslateKey: 'reportActionContextMenu.deleteAction',
Expand Down

0 comments on commit 9807c47

Please sign in to comment.