From 6633a600eac6e8b0984577ca3e297a14bd381ebb Mon Sep 17 00:00:00 2001 From: ibolton336 Date: Wed, 27 Sep 2023 12:58:36 -0400 Subject: [PATCH] :bug: FIx broken analysis report download --- .../application-detail-drawer-analysis.tsx | 8 ++------ .../components/download-button.tsx | 20 +++++++++---------- client/src/app/queries/applications.ts | 4 +++- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/client/src/app/pages/applications/components/application-detail-drawer/application-detail-drawer-analysis.tsx b/client/src/app/pages/applications/components/application-detail-drawer/application-detail-drawer-analysis.tsx index ba46c5629a..06d9928ac3 100644 --- a/client/src/app/pages/applications/components/application-detail-drawer/application-detail-drawer-analysis.tsx +++ b/client/src/app/pages/applications/components/application-detail-drawer/application-detail-drawer-analysis.tsx @@ -141,9 +141,7 @@ export const ApplicationDetailDrawerAnalysis: React.FC< - TAR - + /> {" | "} - YAML - + /> diff --git a/client/src/app/pages/applications/components/application-detail-drawer/components/download-button.tsx b/client/src/app/pages/applications/components/application-detail-drawer/components/download-button.tsx index 37143ad28a..78d43340dd 100644 --- a/client/src/app/pages/applications/components/application-detail-drawer/components/download-button.tsx +++ b/client/src/app/pages/applications/components/application-detail-drawer/components/download-button.tsx @@ -1,21 +1,21 @@ import React from "react"; import { Alert, Button } from "@patternfly/react-core"; import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing"; -import { Application } from "@app/api/models"; import { Spinner } from "@patternfly/react-core"; -import { useDownloadStaticReport } from "@app/queries/download"; +import { useDownloadStaticReport } from "@app/queries/applications"; export enum MimeType { TAR = "tar", YAML = "yaml", } -function DownloadButton({ - application, - mimeType, -}: { - application: Application; +interface IDownloadButtonProps { + id: number; mimeType: MimeType; -}) { +} +export const DownloadButton: React.FC = ({ + id, + mimeType, +}) => { const { mutate: downloadFile, isLoading, @@ -24,7 +24,7 @@ function DownloadButton({ const handleDownload = () => { downloadFile({ - applicationId: application.id, + applicationId: id, mimeType: mimeType, }); }; @@ -51,6 +51,6 @@ function DownloadButton({ )} ); -} +}; export default DownloadButton; diff --git a/client/src/app/queries/applications.ts b/client/src/app/queries/applications.ts index b892545094..9ed969f555 100644 --- a/client/src/app/queries/applications.ts +++ b/client/src/app/queries/applications.ts @@ -1,8 +1,9 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { AxiosError } from "axios"; +import axios, { AxiosError } from "axios"; import { MimeType } from "@app/api/models"; import { + APPLICATIONS, createApplication, deleteApplication, deleteBulkApplications, @@ -13,6 +14,7 @@ import { } from "@app/api/rest"; import { reviewsQueryKey } from "./reviews"; import { assessmentsQueryKey } from "./assessments"; +import saveAs from "file-saver"; export const ApplicationDependencyQueryKey = "applicationdependencies"; export const ApplicationsQueryKey = "applications";