From 42527e76c1d9ff4afb3c3a83a4d137b60ea8439a Mon Sep 17 00:00:00 2001 From: MillenniumFalconMechanic Date: Fri, 21 Feb 2025 16:48:38 -0800 Subject: [PATCH] feat: added check login required for hca export/download #4292 --- .../FileLocationCopy/fileLocationCopy.tsx | 6 +- .../fileLocationDownload.tsx | 7 +- pages/_app.tsx | 85 ++++++++++--------- site-config/hca-dcp/cc-ma-dev/config.ts | 3 + 4 files changed, 58 insertions(+), 43 deletions(-) diff --git a/app/components/Detail/components/GeneratedMatricesTables/components/FileLocationCopy/fileLocationCopy.tsx b/app/components/Detail/components/GeneratedMatricesTables/components/FileLocationCopy/fileLocationCopy.tsx index cccb0d3e0..614106f2e 100644 --- a/app/components/Detail/components/GeneratedMatricesTables/components/FileLocationCopy/fileLocationCopy.tsx +++ b/app/components/Detail/components/GeneratedMatricesTables/components/FileLocationCopy/fileLocationCopy.tsx @@ -1,6 +1,7 @@ import { ButtonGroupButton } from "@databiosphere/findable-ui/lib/components/common/ButtonGroup/components/ButtonGroupButton/buttonGroupButton"; import { ContentCopyIconSmall } from "@databiosphere/findable-ui/lib/components/common/CustomIcon/common/constants"; import { useFileLocation } from "@databiosphere/findable-ui/lib/hooks/useFileLocation"; +import { useLoginGuard } from "@databiosphere/findable-ui/lib/providers/loginGuard/hook"; import copy from "copy-to-clipboard"; import { useEffect } from "react"; import { ProjectMatrixView } from "../../../../../../viewModelBuilders/azul/hca-dcp/common/projectMatrixMapper/entities"; @@ -15,6 +16,9 @@ export const FileLocationCopy = ({ const { url } = projectMatrixView; const { fileUrl, isLoading, isSuccess, run } = useFileLocation(url); + // Prompt user for login before download, if required. + const { requireLogin } = useLoginGuard(); + useEffect(() => { if (fileUrl && isSuccess) { copy(fileUrl); @@ -26,7 +30,7 @@ export const FileLocationCopy = ({ action="Copy project matrix" label={} loading={isLoading} - onClick={run} + onClick={() => requireLogin(run)} /> ); }; diff --git a/app/components/Detail/components/GeneratedMatricesTables/components/FileLocationDownload/fileLocationDownload.tsx b/app/components/Detail/components/GeneratedMatricesTables/components/FileLocationDownload/fileLocationDownload.tsx index 556fee83b..e5a77863d 100644 --- a/app/components/Detail/components/GeneratedMatricesTables/components/FileLocationDownload/fileLocationDownload.tsx +++ b/app/components/Detail/components/GeneratedMatricesTables/components/FileLocationDownload/fileLocationDownload.tsx @@ -2,6 +2,7 @@ import { FileDownloadButton } from "@databiosphere/findable-ui/lib/components/co import { ButtonGroupButton } from "@databiosphere/findable-ui/lib/components/common/ButtonGroup/components/ButtonGroupButton/buttonGroupButton"; import { DownloadIconSmall } from "@databiosphere/findable-ui/lib/components/common/CustomIcon/common/constants"; import { useFileLocation } from "@databiosphere/findable-ui/lib/hooks/useFileLocation"; +import { useLoginGuard } from "@databiosphere/findable-ui/lib/providers/loginGuard/hook"; import { ProjectMatrixView } from "../../../../../../viewModelBuilders/azul/hca-dcp/common/projectMatrixMapper/entities"; export interface FileLocationDownloadProps { @@ -13,13 +14,17 @@ export const FileLocationDownload = ({ }: FileLocationDownloadProps): JSX.Element => { const { fileName, url } = projectMatrixView; const { fileUrl, isLoading, run } = useFileLocation(url); + + // Prompt user for login before download, if required. + const { requireLogin } = useLoginGuard(); + return ( <> } loading={isLoading} - onClick={run} + onClick={() => requireLogin(run)} /> diff --git a/pages/_app.tsx b/pages/_app.tsx index 961ed0bbf..9e5bdef1a 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -15,6 +15,7 @@ import { ExploreStateProvider } from "@databiosphere/findable-ui/lib/providers/e import { FileManifestStateProvider } from "@databiosphere/findable-ui/lib/providers/fileManifestState"; import { GoogleSignInAuthenticationProvider } from "@databiosphere/findable-ui/lib/providers/googleSignInAuthentication/provider"; import { LayoutStateProvider } from "@databiosphere/findable-ui/lib/providers/layoutState"; +import { LoginGuardProvider } from "@databiosphere/findable-ui/lib/providers/loginGuard/provider"; import { SystemStatusProvider } from "@databiosphere/findable-ui/lib/providers/systemStatus"; import { createAppTheme } from "@databiosphere/findable-ui/lib/theme/theme"; import { DataExplorerError } from "@databiosphere/findable-ui/lib/types/error"; @@ -75,47 +76,49 @@ function MyApp({ Component, pageProps }: AppPropsWithComponent): JSX.Element { SessionController={TerraProfileProvider} timeout={SESSION_TIMEOUT} > - - - - createTheme( - deepmerge(theme, { - breakpoints: createBreakpoints(BREAKPOINTS), - }) - ) - } - > -
- - - -
- void; - }): JSX.Element => ( - - )} - > - - - -
-
-
-