Skip to content

Commit

Permalink
ENH: Disable derivatives tab if ToS not accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Feb 28, 2024
1 parent a5269a4 commit 1be2211
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const DatasetTools = ({
: `/datasets/${datasetId}/derivatives`}
icon="fa-cubes"
label="Derivatives"
disable={!agree}

Check warning on line 118 in packages/openneuro-app/src/scripts/dataset/components/DatasetTools.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/components/DatasetTools.tsx#L118

Added line #L118 was not covered by tests
/>
)}
<DatasetToolButton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from "react"
import { Navigate, useParams } from "react-router-dom"
import DownloadS3Derivative from "../download/download-derivative-s3"
import DownloadDataLadDerivative from "../download/download-derivative-datalad"
import { DatasetPageBorder } from "./styles/dataset-page-border"
import { HeaderRow3 } from "./styles/header-row"
import { useAgreement } from "../../components/agreement"

interface DerivativeElementProps {
name: string
Expand Down Expand Up @@ -38,6 +40,12 @@ interface DerivativesProps {
}

const Derivatives = ({ derivatives }: DerivativesProps): JSX.Element => {
const { datasetId, tag: snapshotTag } = useParams()
const [agreed] = useAgreement()
// If the derivatives page is directly visited without the agreement, return to the dataset page
if (!agreed) {
return <Navigate to={`/datasets/${datasetId}`} replace={true} />
}

Check warning on line 48 in packages/openneuro-app/src/scripts/dataset/routes/derivatives.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/routes/derivatives.tsx#L43-L48

Added lines #L43 - L48 were not covered by tests
return (
<DatasetPageBorder>
<HeaderRow3>Available Derivatives</HeaderRow3>
Expand Down

0 comments on commit 1be2211

Please sign in to comment.