Skip to content

Commit

Permalink
feat: CQDG-861 fix allow custom filename to dataset filemanifest
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulous committed Oct 1, 2024
1 parent 1d3bdde commit b5a73b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/components/reports/DownloadFileManifestModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ const DownloadFileManifestModal = ({
setIsModalVisible(false);
};

const _fileName =
fileName || (isFamilyChecked ? ReportType.FILE_MANIFEST_FAMILY : ReportType.FILE_MANIFEST);

const Content = () => (
<Text>
<p>
Expand Down Expand Up @@ -95,7 +92,8 @@ const DownloadFileManifestModal = ({
dispatch(
fetchReport({
data: {
name: _fileName,
fileName,
name: ReportType.FILE_MANIFEST,
sqon,
withFamily: isFamilyChecked,
},
Expand Down
10 changes: 6 additions & 4 deletions src/services/api/reports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const headers = (): AxiosRequestHeaders => ({
});

const generateReport = (config: ReportConfig) => {
const name = config.name;
const name = config.name as ReportType;
const url = REPORTS_ROUTES[name];

let reportSqon;
if (!config.sqon || isEmpty(config.sqon)) {
Expand All @@ -43,13 +44,14 @@ const generateReport = (config: ReportConfig) => {
reportSqon = config.sqon;
}

const fileNameToUse = config.fileName || name;

/** the quotes in string are required by format function, else it throws an error */
const fileName = `'cqdg_${name}'_yyyyMMdd`;
const fileName = `'cqdg_${fileNameToUse}'_yyyyMMdd`;
const fileNameFormatted = format(new Date(), fileName);
const route = config.withFamily ? ReportType.FILE_MANIFEST_FAMILY : ReportType.FILE_MANIFEST;

return downloader({
url: REPORTS_ROUTES[route],
url,
method: 'POST',
responseType: 'blob',
data: {
Expand Down
1 change: 1 addition & 0 deletions src/services/api/reports/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ISyntheticSqon } from '@ferlab/ui/core/data/sqon/types';
export type ReportConfig = {
sqon: ISyntheticSqon;
name: string;
fileName?: string;
withFamily?: boolean;
withoutFiles?: boolean;
};
Expand Down

0 comments on commit b5a73b0

Please sign in to comment.