Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added check login required for hca export/download #4292 #4394

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
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 @@
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 @@
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 { 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 @@
}: 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 { 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 @@
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 @@
// 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
Loading