Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c1774d1
labels
Gonals Feb 20, 2025
1cafa55
Add new params
Gonals Feb 20, 2025
9b5cd8c
new types and whatnot
Gonals Feb 20, 2025
c3cce3b
Add button
Gonals Feb 20, 2025
04807e6
typing changes
Gonals Feb 20, 2025
2be5e3e
Add generating modal
Gonals Feb 21, 2025
2ba5438
correctly display modal
Gonals Feb 21, 2025
aa05e50
Handle all three cases
Gonals Feb 21, 2025
5ceccea
call export command
Gonals Feb 21, 2025
8b0fda7
create download file
Gonals Feb 21, 2025
feafad9
Handle downloads
Gonals Feb 21, 2025
73c1aa6
onyxdata added
Gonals Feb 21, 2025
850cd1b
Correctly show popup
Gonals Feb 24, 2025
ac82821
strings
Gonals Feb 24, 2025
d56acb2
comments
Gonals Feb 26, 2025
b60173f
Add missing constant
Gonals Feb 26, 2025
aa83740
prettier
Gonals Feb 26, 2025
9c79870
conflicts
Gonals Feb 26, 2025
85982e1
Add beta
Gonals Feb 26, 2025
e0c51ed
hide behind beta
Gonals Feb 26, 2025
abb71bc
Merge branch 'main' into alberto-pdfExport
Gonals Feb 27, 2025
d637aad
prettier
Gonals Feb 27, 2025
5b33a2f
dependency
Gonals Feb 27, 2025
e404c0f
conflicts
Gonals Mar 3, 2025
b006893
External download
Gonals Mar 3, 2025
415d36c
prettier
Gonals Mar 3, 2025
55b62d5
beta not needed
Gonals Mar 3, 2025
5c1e043
prettier again
Gonals Mar 3, 2025
89a400d
Add spinner during download
Gonals Mar 4, 2025
1b5dd44
external for chrome too
Gonals Mar 4, 2025
898552d
prettier
Gonals Mar 4, 2025
f7583dd
lint
Gonals Mar 4, 2025
7364c43
import? maybe?
Gonals Mar 4, 2025
bfbc317
more import changes trying to get the linter happy
Gonals Mar 4, 2025
c118979
conflicts
Gonals Mar 5, 2025
ef526e3
readd beta just in case
Gonals Mar 5, 2025
29239bf
dependency
Gonals Mar 5, 2025
4b1326a
conflicts
Gonals Mar 6, 2025
9c4a44f
remove external
Gonals Mar 6, 2025
3055c4c
Merge branch 'main' into alberto-pdfExport
Gonals Mar 7, 2025
d9864eb
hardcode for testing
Gonals Mar 7, 2025
2264206
try prod
Gonals Mar 7, 2025
b2650bb
test with token
Gonals Mar 7, 2025
e51b3c8
undo test changes
Gonals Mar 7, 2025
b17849c
remove setDownload
Gonals Mar 7, 2025
a467244
lint
Gonals Mar 7, 2025
3365a19
test link
Gonals Mar 10, 2025
d73748f
undo last change
Gonals Mar 10, 2025
5fe3192
Merge branch 'main' into alberto-pdfExport
Gonals Mar 10, 2025
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
5 changes: 4 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ const CONST = {
PER_DIEM: 'newDotPerDiem',
NEWDOT_MERGE_ACCOUNTS: 'newDotMergeAccounts',
NEWDOT_MANAGER_MCTEST: 'newDotManagerMcTest',
NEWDOT_PDF_EXPORT: 'newDotPDFExport',
NEWDOT_INTERNATIONAL_DEPOSIT_BANK_ACCOUNT: 'newDotInternationalDepositBankAccount',
NSQS: 'nsqs',
CUSTOM_RULES: 'customRules',
Expand Down Expand Up @@ -3494,14 +3495,16 @@ const CONST = {
SETTINGS: 'settings',
LEAVE_ROOM: 'leaveRoom',
PRIVATE_NOTES: 'privateNotes',
DOWNLOAD: 'download',
DOWNLOAD_CSV: 'downloadCSV',
DOWNLOAD_PDF: 'downloadPDF',
EXPORT: 'export',
DELETE: 'delete',
MARK_AS_INCOMPLETE: 'markAsIncomplete',
CANCEL_PAYMENT: 'cancelPayment',
UNAPPROVE: 'unapprove',
DEBUG: 'debug',
GO_TO_WORKSPACE: 'goToWorkspace',
ERROR: 'error',
TRACK: {
SUBMIT: 'submit',
CATEGORIZE: 'categorize',
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ const ONYXKEYS = {
/** Whether the bank account chosen for Expensify Card in on verification waitlist */
NVP_EXPENSIFY_ON_CARD_WAITLIST: 'nvp_expensify_onCardWaitlist_',

NVP_EXPENSIFY_REPORT_PDFFILENAME: 'nvp_expensify_report_PDFFilename_',

/** Stores the information about the state of issuing a new card */
ISSUE_NEW_EXPENSIFY_CARD: 'issueNewExpensifyCard_',
},
Expand Down Expand Up @@ -906,6 +908,7 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.OLD_POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags;
[ONYXKEYS.COLLECTION.SELECTED_TAB]: OnyxTypes.SelectedTabRequest;
[ONYXKEYS.COLLECTION.PRIVATE_NOTES_DRAFT]: string;
[ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDFFILENAME]: string;
[ONYXKEYS.COLLECTION.NEXT_STEP]: OnyxTypes.ReportNextStep;
[ONYXKEYS.COLLECTION.POLICY_JOIN_MEMBER]: OnyxTypes.PolicyJoinMember;
[ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS]: OnyxTypes.PolicyConnectionSyncProgress;
Expand Down
6 changes: 6 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ const translations = {
subrate: 'Subrate',
perDiem: 'Per diem',
validate: 'Validate',
downloadAsPDF: 'Download as PDF',
downloadAsCSV: 'Download as CSV',
help: 'Help',
expenseReports: 'Expense Reports',
rateOutOfPolicy: 'Rate out of policy',
Expand Down Expand Up @@ -1745,6 +1747,10 @@ const translations = {
},
reportDetailsPage: {
inWorkspace: ({policyName}: ReportPolicyNameParams) => `in ${policyName}`,
generatingPDF: 'Generating PDF',
waitForPDF: 'Please wait while we generate the PDF',
errorPDF: 'There was an error when trying to generate your PDF.',
generatedPDF: 'Your report PDF has been generated!',
},
reportDescriptionPage: {
roomDescription: 'Room description',
Expand Down
6 changes: 6 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ const translations = {
subrate: 'Subtasa',
perDiem: 'Per diem',
validate: 'Validar',
downloadAsPDF: 'Descargar como PDF',
downloadAsCSV: 'Descargar como CSV',
help: 'Ayuda',
expenseReports: 'Informes de Gastos',
rateOutOfPolicy: 'Tasa fuera de póliza',
Expand Down Expand Up @@ -1747,6 +1749,10 @@ const translations = {
},
reportDetailsPage: {
inWorkspace: ({policyName}: ReportPolicyNameParams) => `en ${policyName}`,
generatingPDF: 'Creando PDF',
waitForPDF: 'Por favor, espera mientras creamos el PDF',
errorPDF: 'Ocurrió un error al crear el PDF.',
generatedPDF: 'Tu informe PDF ha sido creado!',
},
reportDescriptionPage: {
roomDescription: 'Descripción de la sala de chat',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/API/parameters/ExportReportPDFParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type ExportReportPDFParams = {
reportID: string;
};

export default ExportReportPDFParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ export type {default as BankAccountCreateCorpayParams} from './BankAccountCreate
export type {default as JoinAccessiblePolicyParams} from './JoinAccessiblePolicyParams';
export type {default as ImportPerDiemRatesParams} from './ImportPerDiemRatesParams';
export type {default as ExportPerDiemCSVParams} from './ExportPerDiemCSVParams';
export type {default as ExportReportPDFParams} from './ExportReportPDFParams';
export type {default as UpdateWorkspaceCustomUnitParams} from './UpdateWorkspaceCustomUnitParams';
export type {default as DismissProductTrainingParams} from './DismissProductTraining';
export type {default as OpenWorkspacePlanPageParams} from './OpenWorkspacePlanPage';
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const WRITE_COMMANDS = {
EXPORT_TAGS_CSV: 'ExportTagsCSV',
EXPORT_PER_DIEM_CSV: 'ExportPerDiemCSV',
EXPORT_REPORT_TO_CSV: 'ExportReportToCSV',
EXPORT_REPORT_TO_PDF: 'ExportReportToPDF',
RENAME_WORKSPACE_CATEGORY: 'RenameWorkspaceCategory',
CREATE_POLICY_TAG: 'CreatePolicyTag',
RENAME_POLICY_TAG: 'RenamePolicyTag',
Expand Down Expand Up @@ -599,6 +600,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.EXPORT_MEMBERS_CSV]: Parameters.ExportMembersSpreadsheetParams;
[WRITE_COMMANDS.EXPORT_TAGS_CSV]: Parameters.ExportTagsSpreadsheetParams;
[WRITE_COMMANDS.EXPORT_PER_DIEM_CSV]: Parameters.ExportPerDiemCSVParams;
[WRITE_COMMANDS.EXPORT_REPORT_TO_PDF]: Parameters.ExportReportPDFParams;
[WRITE_COMMANDS.RENAME_WORKSPACE_CATEGORY]: Parameters.RenameWorkspaceCategoriesParams;
[WRITE_COMMANDS.SET_WORKSPACE_REQUIRES_CATEGORY]: Parameters.SetWorkspaceRequiresCategoryParams;
[WRITE_COMMANDS.DELETE_WORKSPACE_CATEGORIES]: Parameters.DeleteWorkspaceCategoriesParams;
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ function canUseMergeAccounts(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NEWDOT_MERGE_ACCOUNTS) || canUseAllBetas(betas);
}

function canUsePDFExport(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NEWDOT_PDF_EXPORT) || canUseAllBetas(betas);
}

function canUseManagerMcTest(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NEWDOT_MANAGER_MCTEST) || canUseAllBetas(betas);
}
Expand All @@ -56,6 +60,7 @@ export default {
canUseSpotnanaTravel,
isBlockedFromSpotnanaTravel,
canUseNetSuiteUSATax,
canUsePDFExport,
canUseMergeAccounts,
canUseManagerMcTest,
canUseInternationalBankAccount,
Expand Down
36 changes: 36 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
CompleteGuidedSetupParams,
DeleteCommentParams,
ExpandURLPreviewParams,
ExportReportPDFParams,
FlagCommentParams,
GetNewerActionsParams,
GetOlderActionsParams,
Expand Down Expand Up @@ -52,12 +53,14 @@ import type ExportReportCSVParams from '@libs/API/parameters/ExportReportCSVPara
import type UpdateRoomVisibilityParams from '@libs/API/parameters/UpdateRoomVisibilityParams';
import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import * as ApiUtils from '@libs/ApiUtils';
import * as Browser from '@libs/Browser';
import * as CollectionUtils from '@libs/CollectionUtils';
import type {CustomRNImageManipulatorResult} from '@libs/cropOrRotateImage/types';
import DateUtils from '@libs/DateUtils';
import {prepareDraftComment} from '@libs/DraftCommentUtils';
import * as EmojiUtils from '@libs/EmojiUtils';
import * as Environment from '@libs/Environment/Environment';
import {getOldDotURLFromEnvironment} from '@libs/Environment/Environment';
import getEnvironment from '@libs/Environment/getEnvironment';
import type EnvironmentType from '@libs/Environment/getEnvironment/types';
import * as ErrorUtils from '@libs/ErrorUtils';
Expand Down Expand Up @@ -128,6 +131,7 @@ import {
} from '@libs/ReportUtils';
import shouldSkipDeepLinkNavigation from '@libs/shouldSkipDeepLinkNavigation';
import {getNavatticURL} from '@libs/TourUtils';
import {addTrailingForwardSlash} from '@libs/Url';
import {generateAccountID} from '@libs/UserUtils';
import Visibility from '@libs/Visibility';
import CONFIG from '@src/CONFIG';
Expand Down Expand Up @@ -4655,6 +4659,36 @@ function exportReportToCSV({reportID, transactionIDList}: ExportReportCSVParams,
fileDownload(ApiUtils.getCommandURL({command: WRITE_COMMANDS.EXPORT_REPORT_TO_CSV}), 'Expensify.csv', '', false, formData, CONST.NETWORK.METHOD.POST, onDownloadFailed);
}

function exportReportToPDF({reportID}: ExportReportPDFParams) {
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDFFILENAME}${reportID}`,
value: null,
},
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDFFILENAME}${reportID}`,
value: 'error',
},
];
const params = {
reportID,
} satisfies ExportReportPDFParams;

API.write(WRITE_COMMANDS.EXPORT_REPORT_TO_PDF, params, {optimisticData, failureData});
}

function downloadReportPDF(fileName: string, reportName: string) {
const baseURL = addTrailingForwardSlash(getOldDotURLFromEnvironment(environment));
const downloadFileName = `${reportName}.pdf`;
const pdfURL = `${baseURL}secure?secureType=pdfreport&filename=${fileName}&downloadName=${downloadFileName}`;
fileDownload(pdfURL, downloadFileName, '', Browser.isMobileSafari());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can explicitly pass true to the 3rd argument when calling this function to treat App downloads as an external link to avoid the CORS issue. More details here #61937 (comment)

}

function setDeleteTransactionNavigateBackUrl(url: string) {
Onyx.set(ONYXKEYS.NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL, url);
}
Expand Down Expand Up @@ -4686,9 +4720,11 @@ export {
deleteReportComment,
deleteReportField,
dismissTrackExpenseActionableWhisper,
downloadReportPDF,
editReportComment,
expandURLPreview,
exportReportToCSV,
exportReportToPDF,
exportToIntegration,
flagComment,
getCurrentUserAccountID,
Expand Down
Loading
Loading