-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DatasetActionButtons): add LinkDatasetButton component
- Loading branch information
Showing
6 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/sections/dataset/dataset-action-buttons/link-dataset-button/LinkDatasetButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Button } from '@iqss/dataverse-design-system' | ||
import { Dataset, DatasetStatus } from '../../../../dataset/domain/models/Dataset' | ||
|
||
interface LinkDatasetButtonProps { | ||
dataset: Dataset | ||
} | ||
export function LinkDatasetButton({ dataset }: LinkDatasetButtonProps) { | ||
// TODO - get session context | ||
if (!dataset.isReleased || dataset.version.status === DatasetStatus.DEACCESSIONED) { | ||
return <></> | ||
} | ||
return <Button variant="secondary">Link Dataset</Button> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...nt/sections/dataset/dataset-action-buttons/link-dataset-button/LinkDatasetButton.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { | ||
DatasetMother, | ||
DatasetVersionMother | ||
} from '../../../../dataset/domain/models/DatasetMother' | ||
import { LinkDatasetButton } from '../../../../../../src/sections/dataset/dataset-action-buttons/link-dataset-button/LinkDatasetButton' | ||
|
||
describe('LinkDatasetButton', () => { | ||
it('renders the LinkDatasetButton if the user is authenticated and the dataset version is not deaccessioned and the dataset is released', () => { | ||
const dataset = DatasetMother.create({ | ||
version: DatasetVersionMother.createDraft(), | ||
isReleased: true | ||
}) | ||
|
||
cy.customMount(<LinkDatasetButton dataset={dataset} />) | ||
|
||
cy.findByRole('button', { name: 'Link Dataset' }).should('exist') | ||
}) | ||
|
||
it('does not render the LinkDatasetButton if the user is not authenticated', () => { | ||
// TODO - Add session context | ||
const dataset = DatasetMother.create({ | ||
version: DatasetVersionMother.createDraft(), | ||
isReleased: true | ||
}) | ||
|
||
cy.customMount(<LinkDatasetButton dataset={dataset} />) | ||
|
||
cy.findByRole('button', { name: 'Link Dataset' }).should('not.exist') | ||
}) | ||
|
||
it('does not render the LinkDatasetButton if the dataset version is deaccessioned', () => { | ||
const dataset = DatasetMother.create({ | ||
version: DatasetVersionMother.createDeaccessioned(), | ||
isReleased: true | ||
}) | ||
|
||
cy.customMount(<LinkDatasetButton dataset={dataset} />) | ||
|
||
cy.findByRole('button', { name: 'Link Dataset' }).should('not.exist') | ||
}) | ||
|
||
it('does not render the LinkDatasetButton if the dataset is not released', () => { | ||
const dataset = DatasetMother.create({ | ||
version: DatasetVersionMother.createDraft(), | ||
isReleased: false | ||
}) | ||
|
||
cy.customMount(<LinkDatasetButton dataset={dataset} />) | ||
|
||
cy.findByRole('button', { name: 'Link Dataset' }).should('not.exist') | ||
}) | ||
}) |