Skip to content

Commit

Permalink
feat: added check login required for hca export/download #4292
Browse files Browse the repository at this point in the history
  • Loading branch information
MillenniumFalconMechanic committed Feb 22, 2025
1 parent 3c7e64d commit 42527e7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -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";

Check failure on line 4 in app/components/Detail/components/GeneratedMatricesTables/components/FileLocationCopy/fileLocationCopy.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '@databiosphere/findable-ui/lib/providers/loginGuard/hook' or its corresponding type declarations.
import copy from "copy-to-clipboard";
import { useEffect } from "react";
import { ProjectMatrixView } from "../../../../../../viewModelBuilders/azul/hca-dcp/common/projectMatrixMapper/entities";
Expand All @@ -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);
Expand All @@ -26,7 +30,7 @@ export const FileLocationCopy = ({
action="Copy project matrix"
label={<ContentCopyIconSmall />}
loading={isLoading}
onClick={run}
onClick={() => requireLogin(run)}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Check failure on line 5 in app/components/Detail/components/GeneratedMatricesTables/components/FileLocationDownload/fileLocationDownload.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '@databiosphere/findable-ui/lib/providers/loginGuard/hook' or its corresponding type declarations.
import { ProjectMatrixView } from "../../../../../../viewModelBuilders/azul/hca-dcp/common/projectMatrixMapper/entities";

export interface FileLocationDownloadProps {
Expand All @@ -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 (
<>
<ButtonGroupButton
action="Download project matrix"
label={<DownloadIconSmall />}
loading={isLoading}
onClick={run}
onClick={() => requireLogin(run)}
/>
<FileDownloadButton fileName={fileName} fileUrl={fileUrl} />
</>
Expand Down
85 changes: 44 additions & 41 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Check failure on line 18 in pages/_app.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '@databiosphere/findable-ui/lib/providers/loginGuard/provider' or its corresponding type declarations.
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";
Expand Down Expand Up @@ -75,47 +76,49 @@ function MyApp({ Component, pageProps }: AppPropsWithComponent): JSX.Element {
SessionController={TerraProfileProvider}
timeout={SESSION_TIMEOUT}
>
<LayoutStateProvider>
<AppLayout>
<ThemeProvider
theme={(theme: Theme): Theme =>
createTheme(
deepmerge(theme, {
breakpoints: createBreakpoints(BREAKPOINTS),
})
)
}
>
<Header {...header} />
</ThemeProvider>
<ExploreStateProvider entityListType={entityListType}>
<FileManifestStateProvider>
<Main>
<ErrorBoundary
fallbackRender={({
error,
reset,
}: {
error: DataExplorerError;
reset: () => void;
}): JSX.Element => (
<Error
errorMessage={error.message}
requestUrlMessage={error.requestUrlMessage}
rootPath={redirectRootToPath}
onReset={reset}
/>
)}
>
<Component {...pageProps} />
<Floating {...floating} />
</ErrorBoundary>
</Main>
</FileManifestStateProvider>
</ExploreStateProvider>
<Footer {...footer} />
</AppLayout>
</LayoutStateProvider>
<LoginGuardProvider>
<LayoutStateProvider>
<AppLayout>
<ThemeProvider
theme={(theme: Theme): Theme =>
createTheme(
deepmerge(theme, {
breakpoints: createBreakpoints(BREAKPOINTS),
})
)
}
>
<Header {...header} />
</ThemeProvider>
<ExploreStateProvider entityListType={entityListType}>
<FileManifestStateProvider>
<Main>
<ErrorBoundary
fallbackRender={({
error,
reset,
}: {
error: DataExplorerError;
reset: () => void;
}): JSX.Element => (
<Error
errorMessage={error.message}
requestUrlMessage={error.requestUrlMessage}
rootPath={redirectRootToPath}
onReset={reset}
/>
)}
>
<Component {...pageProps} />
<Floating {...floating} />
</ErrorBoundary>
</Main>
</FileManifestStateProvider>
</ExploreStateProvider>
<Footer {...footer} />
</AppLayout>
</LayoutStateProvider>
</LoginGuardProvider>
</GoogleSignInAuthenticationProvider>
</SystemStatusProvider>
</DXConfigProvider>
Expand Down
3 changes: 3 additions & 0 deletions site-config/hca-dcp/cc-ma-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export function makeManagedAccessConfig(config: SiteConfig): SiteConfig {
// Add authentication to the config.
cloneConfig.authentication = getAuthenticationConfig();

// Require authentication for exports
cloneConfig.exportsRequireAuth = true;

Check failure on line 37 in site-config/hca-dcp/cc-ma-dev/config.ts

View workflow job for this annotation

GitHub Actions / build

Property 'exportsRequireAuth' does not exist on type '{ portalURL?: string | undefined; analytics?: AnalyticsConfig | undefined; appTitle: string; authentication?: AuthenticationConfig | undefined; ... 16 more ...; trackingConfig?: TrackingConfig | undefined; }'.

// Update categoryGroupConfig.
cloneConfig.categoryGroupConfig = getMACategoryGroupConfig(
cloneConfig.categoryGroupConfig
Expand Down

0 comments on commit 42527e7

Please sign in to comment.