Skip to content
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
2 changes: 1 addition & 1 deletion src/components/ExportDownloadStatusModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function ExportDownloadStatusModal({exportID, isVisible, onClose, failedBody}: E
const isCSV = fileName.endsWith('.csv');
const secureType = isCSV ? CONST.SECURE_DOWNLOAD_TYPE.CSV_EXPORT : CONST.SECURE_DOWNLOAD_TYPE.PDF_REPORT;
const url = buildSecureDownloadURL({baseURL, secureType, fileName, downloadName: fileName, email: currentUserLogin});
fileDownload(translate, addEncryptedAuthTokenToURL(url, encryptedAuthToken ?? '', true), fileName, '', isMobileSafari());
fileDownload(translate, addEncryptedAuthTokenToURL(url, encryptedAuthToken ?? '', true), fileName, '', isMobileSafari(), undefined, undefined, undefined, undefined, false);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function SelectionToolbar({reportID, transactions, reportActions}: SelectionTool

const transactionsWithoutPendingDelete = transactions.filter((t) => !isTransactionPendingDelete(t));

const beginExportWithTemplate = (templateName: string, templateType: string, transactionIDList: string[]) => {
const beginExportWithTemplate = (templateName: string, templateType: string, transactionIDList: string[], exportName: string) => {
if (isOffline) {
setOfflineModalVisible(true);
return;
Expand All @@ -101,6 +101,7 @@ function SelectionToolbar({reportID, transactions, reportActions}: SelectionTool
reportIDList: [report.reportID],
transactionIDList,
policyID: policy?.id,
exportName,
},
true,
);
Expand Down Expand Up @@ -147,7 +148,7 @@ function SelectionToolbar({reportID, transactions, reportActions}: SelectionTool
onExportFailed: () => setIsDownloadErrorModalVisible(true),
onExportOffline: () => setOfflineModalVisible(true),
policy,
beginExportWithTemplate: (templateName, templateType, transactionIDList) => beginExportWithTemplate(templateName, templateType, transactionIDList),
beginExportWithTemplate: (templateName, templateType, transactionIDList, exportName) => beginExportWithTemplate(templateName, templateType, transactionIDList, exportName),
onDeleteSelected,
});

Expand Down
7 changes: 4 additions & 3 deletions src/hooks/useExportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type UseExportActionsParams = {
type UseExportActionsReturn = {
exportActionEntries: Record<string, DropdownOption<ValueOf<typeof CONST.REPORT.SECONDARY_ACTIONS>> & Pick<PopoverMenuItem, 'backButtonText' | 'rightIcon'>>;
secondaryExportActions: Array<ValueOf<string>>;
beginExportWithTemplate: (templateName: string, templateType: string, transactionIDList: string[], policyID?: string) => void;
beginExportWithTemplate: (templateName: string, templateType: string, transactionIDList: string[], exportName: string, policyID?: string) => void;
showOfflineModal: () => void;
showDownloadErrorModal: () => void;

Expand Down Expand Up @@ -104,7 +104,7 @@ function useExportActions({reportID, policy, onPDFModalOpen}: UseExportActionsPa
});
};

const beginExportWithTemplate = (templateName: string, templateType: string, transactionIDList: string[], policyID?: string) => {
const beginExportWithTemplate = (templateName: string, templateType: string, transactionIDList: string[], exportName: string, policyID?: string) => {
if (isOffline) {
showOfflineModal();
return;
Expand All @@ -122,6 +122,7 @@ function useExportActions({reportID, policy, onPDFModalOpen}: UseExportActionsPa
reportIDList: [moneyRequestReport.reportID],
transactionIDList,
policyID,
exportName,
},
true,
);
Expand Down Expand Up @@ -203,7 +204,7 @@ function useExportActions({reportID, policy, onPDFModalOpen}: UseExportActionsPa
value: template.templateName,
description: template.description,
sentryLabel: CONST.SENTRY_LABEL.MORE_MENU.EXPORT_FILE,
onSelected: () => beginExportWithTemplate(template.templateName, template.type, transactionIDs, template.policyID),
onSelected: () => beginExportWithTemplate(template.templateName, template.type, transactionIDs, template.name, template.policyID),
};
}

Expand Down
17 changes: 13 additions & 4 deletions src/hooks/useSearchBulkActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
const {duplicateTransactions, duplicateTransactionViolations} = useDuplicateTransactionsAndViolations(selectedTransactionsKeys);

const beginExportWithTemplate = useCallback(
(templateName: string, templateType: string, policyID: string | undefined) => {
(templateName: string, templateType: string, policyID: string | undefined, exportName: string) => {
const emptyReports =
selectedReports?.filter((selectedReport) => {
if (!selectedReport) {
Expand Down Expand Up @@ -611,6 +611,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
reportIDList: [],
transactionIDList: [],
policyID,
exportName,
},
true,
);
Expand All @@ -624,6 +625,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
reportIDList: isGroupExport ? [] : selectedTransactionReportIDs,
transactionIDList: isGroupExport ? [] : selectedTransactionsKeys,
policyID,
exportName,
},
true,
);
Expand Down Expand Up @@ -699,6 +701,8 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
return;
}

const exportName = translate(isBasicExport ? 'export.basicExport' : 'export.currentView');

if (areAllMatchingItemsSelected) {
if (selectedTransactionsKeys.length === 0 || status == null || !hash) {
return;
Expand All @@ -712,6 +716,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
transactionIDList: selectedTransactionsKeys,
isBasicExport: exportParameters.isBasicExport,
exportColumnLabels: exportParameters.exportColumnLabels,
exportName,
});
trackExport(exportID);
return;
Expand All @@ -730,6 +735,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
transactionIDList: isGroupExport ? [] : selectedTransactionsKeys,
isBasicExport: exportParameters.isBasicExport,
exportColumnLabels: exportParameters.exportColumnLabels,
exportName,
},
() => {
didFail = true;
Expand Down Expand Up @@ -1548,8 +1554,12 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
}
}

const isGroupedSearch = !!getValidGroupBy(queryJSON?.groupBy);

exportOptions.push({
text: translate('export.basicExport'),
// Group by exports dont have a basicExport, at the same time the backend expects isBasicExport to be true for grouped exports, so we just rename the option here
// Fixing here https://github.com/Expensify/Expensify/issues/652978
text: translate(isGroupedSearch ? 'export.currentView' : 'export.basicExport'),
icon: expensifyIcons.Table,
onSelected: () => {
handleBasicExport();
Expand All @@ -1558,7 +1568,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
shouldCallAfterModalHide: true,
});

const isGroupedSearch = !!getValidGroupBy(queryJSON?.groupBy);
if (!isGroupedSearch) {
exportOptions.push({
text: translate('export.currentView'),
Expand All @@ -1580,7 +1589,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
icon: isStandardTemplate ? expensifyIcons.Table : expensifyIcons.TablePencil,
description: template.description,
onSelected: () => {
beginExportWithTemplate(template.templateName, template.type, template.policyID);
beginExportWithTemplate(template.templateName, template.type, template.policyID, template.name);
},
shouldCloseModalOnSelect: true,
shouldCallAfterModalHide: true,
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useSelectedTransactionsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function useSelectedTransactionsActions({
onExportFailed?: () => void;
onExportOffline?: () => void;
policy?: Policy;
beginExportWithTemplate: (templateName: string, templateType: string, transactionIDList: string[], policyID?: string) => void;
beginExportWithTemplate: (templateName: string, templateType: string, transactionIDList: string[], exportName: string, policyID?: string) => void;
isOnSearch?: boolean;
onDeleteSelected?: (handleDeleteTransactions: () => void, handleDeleteTransactionsWithNavigation: (backToRoute?: Route) => void) => void | Promise<void>;
}) {
Expand Down Expand Up @@ -415,7 +415,7 @@ function useSelectedTransactionsActions({
text: template.name,
icon: isStandardTemplate ? expensifyIcons.Table : expensifyIcons.TablePencil,
description: template.description,
onSelected: () => beginExportWithTemplate(template.templateName, template.type, selectedTransactionIDs, template.policyID),
onSelected: () => beginExportWithTemplate(template.templateName, template.type, selectedTransactionIDs, template.name, template.policyID),
});
}
return exportOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9817,7 +9817,7 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`,
expenseLevelExport: 'Alle Daten – Ausgabenebene',
exportInProgress: 'Export wird ausgeführt',
conciergeWillSend: 'Concierge wird dir die Datei in Kürze senden.',
currentView: 'Aktuelle Ansicht exportieren',
currentView: 'Aktuelle Ansicht',
},
exportDownload: {
preparingTitle: 'Preparing download...',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9886,7 +9886,7 @@ const translations = {
},
export: {
basicExport: 'Basic export',
currentView: 'Export current view',
currentView: 'Current view',
reportLevelExport: 'All Data - report level',
expenseLevelExport: 'All Data - expense level',
exportInProgress: 'Export in progress',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9970,7 +9970,7 @@ ${amount} para ${merchant} - ${date}`,
expenseLevelExport: 'Todos los datos - a nivel de gasto',
exportInProgress: 'Exportación en curso',
conciergeWillSend: 'Concierge te enviará el archivo en breve.',
currentView: 'Exportar vista actual',
currentView: 'Vista actual',
},
exportDownload: {
preparingTitle: 'Preparando descarga...',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9849,7 +9849,7 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`,
expenseLevelExport: 'Toutes les données - niveau dépense',
exportInProgress: 'Export en cours',
conciergeWillSend: 'Concierge vous enverra le fichier sous peu.',
currentView: 'Exporter la vue actuelle',
currentView: 'Vue actuelle',
},
exportDownload: {
preparingTitle: 'Preparing download...',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9805,7 +9805,7 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`,
expenseLevelExport: 'Tutti i dati - livello spesa',
exportInProgress: 'Esportazione in corso',
conciergeWillSend: 'Concierge ti invierà il file a breve.',
currentView: 'Esporta vista corrente',
currentView: 'Vista corrente',
},
exportDownload: {
preparingTitle: 'Preparing download...',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9680,7 +9680,7 @@ ${reportName}`,
expenseLevelExport: 'すべてのデータ - 経費レベル',
exportInProgress: 'エクスポート処理中',
conciergeWillSend: 'Conciergeがまもなくファイルを送信します。',
currentView: '現在のビューをエクスポート',
currentView: '現在のビュー',
},
exportDownload: {
preparingTitle: 'Preparing download...',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9775,7 +9775,7 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`,
expenseLevelExport: 'Alle gegevens - uitgaveniveau',
exportInProgress: 'Export bezig',
conciergeWillSend: 'Concierge stuurt je het bestand zo meteen.',
currentView: 'Huidige weergave exporteren',
currentView: 'Huidige weergave',
},
exportDownload: {
preparingTitle: 'Preparing download...',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9756,7 +9756,7 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`,
expenseLevelExport: 'Wszystkie dane – poziom wydatku',
exportInProgress: 'Trwa eksport',
conciergeWillSend: 'Concierge wkrótce wyśle Ci plik.',
currentView: 'Eksportuj bieżący widok',
currentView: 'Bieżący widok',
},
exportDownload: {
preparingTitle: 'Preparing download...',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9760,7 +9760,7 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`,
expenseLevelExport: 'Todos os dados - nível de despesa',
exportInProgress: 'Exportação em andamento',
conciergeWillSend: 'O Concierge enviará o arquivo para você em breve.',
currentView: 'Exportar visão atual',
currentView: 'Visualização atual',
},
exportDownload: {
preparingTitle: 'Preparing download...',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9497,7 +9497,7 @@ ${reportName}`,
expenseLevelExport: '所有数据 - 报销级别',
exportInProgress: '导出进行中',
conciergeWillSend: 'Concierge 将很快把文件发送给你。',
currentView: '导出当前视图',
currentView: '当前视图',
},
exportDownload: {
preparingTitle: 'Preparing download...',
Expand Down
1 change: 1 addition & 0 deletions src/libs/API/parameters/ExportSearchItemsToCSVParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ExportSearchItemsToCSVParams = {
transactionIDList: string[];
isBasicExport: boolean;
exportColumnLabels: string;
exportName: string;
};

export default ExportSearchItemsToCSVParams;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ExportSearchWithTemplateParams = {
reportIDList: string[];
transactionIDList: string[];
policyID: string | undefined;
exportName: string;
};

export default ExportSearchWithTemplateParams;
14 changes: 13 additions & 1 deletion src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import getEnvironment from '@libs/Environment/getEnvironment';
import type EnvironmentType from '@libs/Environment/getEnvironment/types';
import {getMicroSecondOnyxErrorWithTranslationKey, getMicroSecondTranslationErrorWithTranslationKey} from '@libs/ErrorUtils';
import fileDownload from '@libs/fileDownload';
import {getExportFileName} from '@libs/fileDownload/FileUtils';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import HttpUtils from '@libs/HttpUtils';
import Log from '@libs/Log';
Expand Down Expand Up @@ -6108,7 +6109,18 @@ function exportReportToCSV({reportID, transactionIDList}: ExportReportCSVParams,
}
}

fileDownload(translate, ApiUtils.getCommandURL({command: WRITE_COMMANDS.EXPORT_REPORT_TO_CSV}), 'Expensify.csv', '', false, formData, CONST.NETWORK.METHOD.POST, onDownloadFailed);
fileDownload(
translate,
ApiUtils.getCommandURL({command: WRITE_COMMANDS.EXPORT_REPORT_TO_CSV}),
getExportFileName(translate('export.basicExport'), rand64()),
'',
false,
formData,
CONST.NETWORK.METHOD.POST,
onDownloadFailed,
undefined,
false,
);
}

async function exportReportToPDF({reportID}: ExportReportPDFParams) {
Expand Down
22 changes: 18 additions & 4 deletions src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import {getCommandURL} from '@libs/ApiUtils';
import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
import fileDownload from '@libs/fileDownload';
import {getExportFileName} from '@libs/fileDownload/FileUtils';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
Expand Down Expand Up @@ -1231,7 +1232,7 @@ function rejectMoneyRequestsOnSearch(
type Params = Record<string, ExportSearchItemsToCSVParams>;

function exportSearchItemsToCSV(
{query, jsonQuery, reportIDList, transactionIDList, isBasicExport, exportColumnLabels}: ExportSearchItemsToCSVParams,
{query, jsonQuery, reportIDList, transactionIDList, isBasicExport, exportColumnLabels, exportName}: ExportSearchItemsToCSVParams,
onDownloadFailed: () => void,
translate: LocalizedTranslate,
) {
Expand Down Expand Up @@ -1278,10 +1279,21 @@ function exportSearchItemsToCSV(
}
}

return fileDownload(translate, getCommandURL({command: WRITE_COMMANDS.EXPORT_SEARCH_ITEMS_TO_CSV}), 'Expensify.csv', '', false, formData, CONST.NETWORK.METHOD.POST, onDownloadFailed);
return fileDownload(
translate,
getCommandURL({command: WRITE_COMMANDS.EXPORT_SEARCH_ITEMS_TO_CSV}),
getExportFileName(exportName, rand64()),
'',
false,
formData,
CONST.NETWORK.METHOD.POST,
onDownloadFailed,
undefined,
false,
);
}

function queueExportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDList, isBasicExport, exportColumnLabels}: ExportSearchItemsToCSVParams): string {
function queueExportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDList, isBasicExport, exportColumnLabels, exportName}: ExportSearchItemsToCSVParams): string {
const exportID = rand64();
const onyxKey = `${ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD}${exportID}` as const;

Expand All @@ -1307,6 +1319,7 @@ function queueExportSearchItemsToCSV({query, jsonQuery, reportIDList, transactio
transactionIDList,
isBasicExport,
exportColumnLabels,
exportName,
exportID,
}) as QueueExportSearchItemsToCSVParams;

Expand All @@ -1316,7 +1329,7 @@ function queueExportSearchItemsToCSV({query, jsonQuery, reportIDList, transactio
}

function queueExportSearchWithTemplate(
{templateName, templateType, jsonQuery, reportIDList, transactionIDList, policyID}: ExportSearchWithTemplateParams,
{templateName, templateType, jsonQuery, reportIDList, transactionIDList, policyID, exportName}: ExportSearchWithTemplateParams,
shouldTrackExportProgress = false,
): string {
const exportID = rand64();
Expand Down Expand Up @@ -1348,6 +1361,7 @@ function queueExportSearchWithTemplate(
reportIDList,
transactionIDList,
policyID,
exportName,
...(shouldTrackExportProgress ? {exportID} : {}),
}) as QueueExportSearchWithTemplateParams;

Expand Down
7 changes: 6 additions & 1 deletion src/libs/fileDownload/DownloadUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const fetchFileDownload: FileDownload = (
formData = undefined,
requestType = 'get',
onDownloadFailed?: () => void,
// `shouldUnlink` is part of the cross-platform FileDownload signature but has no meaning on web, so it is intentionally unused here.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Comment thread
rlinoz marked this conversation as resolved.
shouldUnlink = false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we need this if it is not used?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see that it is part of the signature. Can you add a comment here for this disabled rule

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

appendTimestamp = true,
) => {
const resolvedUrl = tryResolveUrlFromApiRoot(url);

Expand Down Expand Up @@ -72,7 +76,8 @@ const fetchFileDownload: FileDownload = (
.then((blob) => {
// Create blob link to download
const href = URL.createObjectURL(new Blob([blob]));
const completeFileName = appendTimeToFileName(fileName ?? getFileName(url));
const resolvedFileName = fileName ?? getFileName(url);
const completeFileName = appendTimestamp ? appendTimeToFileName(resolvedFileName) : resolvedFileName;
createDownloadLink(href, completeFileName);
})
.catch(() => {
Expand Down
Loading
Loading