From 037a2e0f8a2351635aca3cadebe674b70de16a99 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 16 Nov 2023 15:01:51 -0500 Subject: [PATCH 01/12] feat: add NotImplementedModal and story --- .../not-implemented/NotImplementedModal.tsx | 24 ++++++++++++++ .../NotImplementedModal.module.scss | 5 +++ .../NotImplementedModal.stories.tsx | 32 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/sections/not-implemented/NotImplementedModal.tsx create mode 100644 src/stories/not-implemented/NotImplementedModal.module.scss create mode 100644 src/stories/not-implemented/NotImplementedModal.stories.tsx diff --git a/src/sections/not-implemented/NotImplementedModal.tsx b/src/sections/not-implemented/NotImplementedModal.tsx new file mode 100644 index 000000000..3be551cec --- /dev/null +++ b/src/sections/not-implemented/NotImplementedModal.tsx @@ -0,0 +1,24 @@ +import { Button, Modal } from '@iqss/dataverse-design-system' + +interface NotImplementedModalProps { + show: boolean + handleClose: () => void +} + +export function NotImplementedModal({ show, handleClose }: NotImplementedModalProps) { + return ( + + + Not Implemented + + +

This feature is not implemented yet.

+
+ + + +
+ ) +} diff --git a/src/stories/not-implemented/NotImplementedModal.module.scss b/src/stories/not-implemented/NotImplementedModal.module.scss new file mode 100644 index 000000000..97f799fbe --- /dev/null +++ b/src/stories/not-implemented/NotImplementedModal.module.scss @@ -0,0 +1,5 @@ +@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; + +.paragraph { + color: $dv-danger-color; +} \ No newline at end of file diff --git a/src/stories/not-implemented/NotImplementedModal.stories.tsx b/src/stories/not-implemented/NotImplementedModal.stories.tsx new file mode 100644 index 000000000..559d300c0 --- /dev/null +++ b/src/stories/not-implemented/NotImplementedModal.stories.tsx @@ -0,0 +1,32 @@ +import { Meta, StoryObj } from '@storybook/react' +import { NotImplementedModal } from '../../sections/not-implemented/NotImplementedModal' + +import { useState } from 'react' +import { Button } from '@iqss/dataverse-design-system' + +const meta: Meta = { + title: 'Sections/NotImplementedModal', + component: NotImplementedModal +} + +export default meta + +type Story = StoryObj + +function DefaultExample() { + const [show, setShow] = useState(false) + + const handleClose = () => setShow(false) + const handleShow = () => setShow(true) + return ( + <> + + + + + ) +} + +export const Default: Story = { + render: () => DefaultExample() +} From b6bdefc3c4dc8804a3e43c1647069702baa8a1ed Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 16 Nov 2023 16:25:09 -0500 Subject: [PATCH 02/12] fix: remove unused file --- src/stories/not-implemented/NotImplementedModal.module.scss | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/stories/not-implemented/NotImplementedModal.module.scss diff --git a/src/stories/not-implemented/NotImplementedModal.module.scss b/src/stories/not-implemented/NotImplementedModal.module.scss deleted file mode 100644 index 97f799fbe..000000000 --- a/src/stories/not-implemented/NotImplementedModal.module.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; - -.paragraph { - color: $dv-danger-color; -} \ No newline at end of file From b50f5292703b542aff0317045a7c8fb0603c5a47 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 16 Nov 2023 16:26:22 -0500 Subject: [PATCH 03/12] feat: add NotImplementedModalContext --- .../edit-dataset-menu/EditDatasetMenu.tsx | 4 +++- .../NotImplementedModalContext.ts | 15 +++++++++++++++ .../NotImplementedModalProvider.tsx | 14 ++++++++++++++ src/stories/WIthNotImplementedModal.tsx | 10 ++++++++++ .../NotImplementedModal.stories.tsx | 16 +++++++--------- 5 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 src/sections/not-implemented/NotImplementedModalContext.ts create mode 100644 src/sections/not-implemented/NotImplementedModalProvider.tsx create mode 100644 src/stories/WIthNotImplementedModal.tsx diff --git a/src/sections/dataset/dataset-action-buttons/edit-dataset-menu/EditDatasetMenu.tsx b/src/sections/dataset/dataset-action-buttons/edit-dataset-menu/EditDatasetMenu.tsx index 326518a5e..58b7f684d 100644 --- a/src/sections/dataset/dataset-action-buttons/edit-dataset-menu/EditDatasetMenu.tsx +++ b/src/sections/dataset/dataset-action-buttons/edit-dataset-menu/EditDatasetMenu.tsx @@ -4,6 +4,7 @@ import { EditDatasetPermissionsMenu } from './EditDatasetPermissionsMenu' import { DeleteDatasetButton } from './DeleteDatasetButton' import { DeaccessionDatasetButton } from './DeaccessionDatasetButton' import { useTranslation } from 'react-i18next' +import { useNotImplementedModal } from '../../../not-implemented/NotImplementedModalContext' interface EditDatasetMenuProps { dataset: Dataset @@ -13,10 +14,11 @@ export function EditDatasetMenu({ dataset }: EditDatasetMenuProps) { if (!dataset.permissions.canUpdateDataset) { return <> } - + const { showModal } = useNotImplementedModal() const { t } = useTranslation('dataset') return ( void + hideModal: () => void + isModalOpen: boolean +} + +export const NotImplementedModal = createContext({ + isModalOpen: false, + showModal: /* istanbul ignore next */ () => {}, + hideModal: /* istanbul ignore next */ () => {} +}) + +export const useNotImplementedModal = () => useContext(NotImplementedModal) diff --git a/src/sections/not-implemented/NotImplementedModalProvider.tsx b/src/sections/not-implemented/NotImplementedModalProvider.tsx new file mode 100644 index 000000000..3a18ce32e --- /dev/null +++ b/src/sections/not-implemented/NotImplementedModalProvider.tsx @@ -0,0 +1,14 @@ +import { useState, PropsWithChildren } from 'react' +import { NotImplementedModal } from './NotImplementedModalContext' + +export function NotImplementedModalProvider({ children }: PropsWithChildren) { + const [isModalOpen, setIsModalOpen] = useState(false) + const showModal = () => setIsModalOpen(true) + const hideModal = () => setIsModalOpen(false) + + return ( + + {children} + + ) +} diff --git a/src/stories/WIthNotImplementedModal.tsx b/src/stories/WIthNotImplementedModal.tsx new file mode 100644 index 000000000..701fa83c7 --- /dev/null +++ b/src/stories/WIthNotImplementedModal.tsx @@ -0,0 +1,10 @@ +import { StoryFn } from '@storybook/react' +import { NotImplementedModalProvider } from '../sections/not-implemented/NotImplementedModalProvider' + +export const WIthNotImplementedModal = (Story: StoryFn) => { + return ( + + + + ) +} diff --git a/src/stories/not-implemented/NotImplementedModal.stories.tsx b/src/stories/not-implemented/NotImplementedModal.stories.tsx index 559d300c0..952c1a2ed 100644 --- a/src/stories/not-implemented/NotImplementedModal.stories.tsx +++ b/src/stories/not-implemented/NotImplementedModal.stories.tsx @@ -1,12 +1,13 @@ import { Meta, StoryObj } from '@storybook/react' import { NotImplementedModal } from '../../sections/not-implemented/NotImplementedModal' - -import { useState } from 'react' import { Button } from '@iqss/dataverse-design-system' +import { useNotImplementedModal } from '../../sections/not-implemented/NotImplementedModalContext' +import { WIthNotImplementedModal } from '../WIthNotImplementedModal' const meta: Meta = { title: 'Sections/NotImplementedModal', - component: NotImplementedModal + component: NotImplementedModal, + decorators: [WIthNotImplementedModal] } export default meta @@ -14,15 +15,12 @@ export default meta type Story = StoryObj function DefaultExample() { - const [show, setShow] = useState(false) - - const handleClose = () => setShow(false) - const handleShow = () => setShow(true) + const { showModal, hideModal, isModalOpen } = useNotImplementedModal() return ( <> - + - + ) } From a5cedd75e5efe02e3abd5575bf55f4af80e886af Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 16 Nov 2023 16:33:09 -0500 Subject: [PATCH 04/12] feat: add NotImplementedModal to Dataset.tsx --- src/sections/dataset/Dataset.tsx | 4 ++++ src/stories/dataset/Dataset.stories.tsx | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/sections/dataset/Dataset.tsx b/src/sections/dataset/Dataset.tsx index c5444efb3..54e2d76c7 100644 --- a/src/sections/dataset/Dataset.tsx +++ b/src/sections/dataset/Dataset.tsx @@ -14,6 +14,8 @@ import { DatasetActionButtons } from './dataset-action-buttons/DatasetActionButt import { useDataset } from './DatasetContext' import { useEffect } from 'react' import { DatasetAlerts } from './dataset-alerts/DatasetAlerts' +import { useNotImplementedModal } from '../not-implemented/NotImplementedModalContext' +import { NotImplementedModal } from '../not-implemented/NotImplementedModal' interface DatasetProps { fileRepository: FileRepository @@ -23,6 +25,7 @@ export function Dataset({ fileRepository }: DatasetProps) { const { setIsLoading } = useLoading() const { dataset, isLoading } = useDataset() const { t } = useTranslation('dataset') + const { showModal, hideModal, isModalOpen } = useNotImplementedModal() useEffect(() => { setIsLoading(isLoading) @@ -34,6 +37,7 @@ export function Dataset({ fileRepository }: DatasetProps) { return ( <> + {!dataset ? ( ) : ( diff --git a/src/stories/dataset/Dataset.stories.tsx b/src/stories/dataset/Dataset.stories.tsx index ab3c7e26e..935433515 100644 --- a/src/stories/dataset/Dataset.stories.tsx +++ b/src/stories/dataset/Dataset.stories.tsx @@ -15,6 +15,7 @@ import { WithDatasetDraftAsOwner } from './WithDatasetDraftAsOwner' import { WithDatasetNotFound } from './WithDatasetNotFound' import { WithDatasetLoading } from './WithDatasetLoading' import { WithLoggedInUser } from '../WithLoggedInUser' +import { WIthNotImplementedModal } from '../WIthNotImplementedModal' const meta: Meta = { title: 'Pages/Dataset', @@ -35,11 +36,23 @@ export const Default: Story = { } export const DraftWithAllDatasetPermissions: Story = { - decorators: [WithLayout, WithDatasetDraftAsOwner, WithLoggedInUser, WithFilePermissionsGranted], + decorators: [ + WithLayout, + WithDatasetDraftAsOwner, + WithLoggedInUser, + WithFilePermissionsGranted, + WIthNotImplementedModal + ], render: () => } export const LoggedInAsOwner: Story = { - decorators: [WithDataset, WithLayout, WithLoggedInUser, WithFilePermissionsGranted], + decorators: [ + WithDataset, + WithLayout, + WithLoggedInUser, + WithFilePermissionsGranted, + WIthNotImplementedModal + ], render: () => } From 844c741f47bbd44ac8effae2017bf0b40d8bc854 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 16 Nov 2023 16:34:04 -0500 Subject: [PATCH 05/12] fix: remove unused constant --- src/sections/dataset/Dataset.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sections/dataset/Dataset.tsx b/src/sections/dataset/Dataset.tsx index 54e2d76c7..8095e0ae8 100644 --- a/src/sections/dataset/Dataset.tsx +++ b/src/sections/dataset/Dataset.tsx @@ -25,7 +25,7 @@ export function Dataset({ fileRepository }: DatasetProps) { const { setIsLoading } = useLoading() const { dataset, isLoading } = useDataset() const { t } = useTranslation('dataset') - const { showModal, hideModal, isModalOpen } = useNotImplementedModal() + const { hideModal, isModalOpen } = useNotImplementedModal() useEffect(() => { setIsLoading(isLoading) From 3fc6e143a0f6affe79b0a8e9ff7eba33a169204a Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 17 Nov 2023 09:40:13 -0500 Subject: [PATCH 06/12] feat: add modal to EditFilesOptions.tsx --- .../file-actions/edit-files-menu/EditFilesOptions.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesOptions.tsx b/src/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesOptions.tsx index 1377303f5..4f21ec3a2 100644 --- a/src/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesOptions.tsx +++ b/src/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesOptions.tsx @@ -4,21 +4,27 @@ import { useTranslation } from 'react-i18next' import { useState } from 'react' import { FileSelection } from '../../row-selection/useFileSelection' import { NoSelectedFilesModal } from '../no-selected-files-modal/NoSelectedFilesModal' +import { useNotImplementedModal } from '../../../../../not-implemented/NotImplementedModalContext' interface EditFileOptionsProps { files: File[] fileSelection: FileSelection } + const SELECTED_FILES_EMPTY = 0 + export function EditFilesOptions({ files, fileSelection }: EditFileOptionsProps) { const { t } = useTranslation('files') const [showNoFilesSelectedModal, setShowNoFilesSelectedModal] = useState(false) const settingsEmbargoAllowed = false // TODO - Ask Guillermo if this is included in the settings endpoint const provenanceEnabledByConfig = false // TODO - Ask Guillermo if this is included in the MVP and from which endpoint is coming from - + const { showModal } = useNotImplementedModal() const onClick = () => { if (Object.keys(fileSelection).length === SELECTED_FILES_EMPTY) { setShowNoFilesSelectedModal(true) + } else { + // TODO - Implement edit files + showModal() } } From a56fce73fcee48ac652fc3121d481a394594c008 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 17 Nov 2023 17:41:28 -0500 Subject: [PATCH 07/12] feat: add Modal to DatasetFactory.tsx, update modal text --- src/sections/dataset/DatasetFactory.tsx | 13 ++++++++----- .../DatasetUploadFilesButton.tsx | 4 +++- .../not-implemented/NotImplementedModal.tsx | 12 ++++++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/sections/dataset/DatasetFactory.tsx b/src/sections/dataset/DatasetFactory.tsx index 1ac3e1e15..4a071df25 100644 --- a/src/sections/dataset/DatasetFactory.tsx +++ b/src/sections/dataset/DatasetFactory.tsx @@ -11,6 +11,7 @@ import { SettingJSDataverseRepository } from '../../settings/infrastructure/Sett import { FilePermissionsProvider } from '../file/file-permissions/FilePermissionsProvider' import { SettingsProvider } from '../settings/SettingsProvider' import { DatasetProvider } from './DatasetProvider' +import { NotImplementedModalProvider } from '../not-implemented/NotImplementedModalProvider' const datasetRepository = new DatasetJSDataverseRepository() const fileRepository = new FileJSDataverseRepository() @@ -22,11 +23,13 @@ export class DatasetFactory { return ( - - - - - + + + + + + + ) diff --git a/src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx b/src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx index 3f33cc8fb..e32d08fe6 100644 --- a/src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx +++ b/src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx @@ -4,6 +4,7 @@ import { useSession } from '../../../session/SessionContext' import styles from './DatasetUploadFilesButton.module.scss' import { useTranslation } from 'react-i18next' import { useDataset } from '../../DatasetContext' +import { useNotImplementedModal } from '../../../not-implemented/NotImplementedModalContext' export function DatasetUploadFilesButton() { const { t } = useTranslation('dataset') @@ -11,8 +12,9 @@ export function DatasetUploadFilesButton() { const { dataset } = useDataset() const handleClick = () => { // TODO - Implement upload files + showModal() } - + const { showModal } = useNotImplementedModal() if (!user || !dataset?.permissions.canUpdateDataset) { return <> } diff --git a/src/sections/not-implemented/NotImplementedModal.tsx b/src/sections/not-implemented/NotImplementedModal.tsx index 3be551cec..6b691e611 100644 --- a/src/sections/not-implemented/NotImplementedModal.tsx +++ b/src/sections/not-implemented/NotImplementedModal.tsx @@ -6,13 +6,21 @@ interface NotImplementedModalProps { } export function NotImplementedModal({ show, handleClose }: NotImplementedModalProps) { + const protocol = window.location.protocol + const host = window.location.host + const baseUrl = `${protocol}//${host}` + return ( - + Not Implemented -

This feature is not implemented yet.

+

This feature is not implemented yet in SPA.

+

+ If you want to use this feature you can go to the original{' '} + Dataverse page. +

+ ) } diff --git a/src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx b/src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx index 58ec23cd8..c89a54210 100644 --- a/src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx +++ b/src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx @@ -2,6 +2,7 @@ import { Dataset, DatasetPublishingStatus } from '../../../../dataset/domain/mod import { DropdownButton, DropdownButtonItem } from '@iqss/dataverse-design-system' import { ChangeCurationStatusMenu } from './ChangeCurationStatusMenu' import { useTranslation } from 'react-i18next' +import { useNotImplementedModal } from '../../../not-implemented/NotImplementedModalContext' interface PublishDatasetMenuProps { dataset: Dataset @@ -17,10 +18,17 @@ export function PublishDatasetMenu({ dataset }: PublishDatasetMenuProps) { } const { t } = useTranslation('dataset') + const handleSelect = () => { + // TODO - Implement upload files + showModal() + } + const { showModal } = useNotImplementedModal() + return ( { + // TODO - Implement upload files + showModal() + } + const { showModal } = useNotImplementedModal() if ( files.length < MINIMUM_FILES_COUNT_TO_SHOW_DOWNLOAD_FILES_BUTTON || !dataset?.permissions.canDownloadFiles @@ -30,6 +36,8 @@ export function DownloadFilesButton({ files, fileSelection }: DownloadFilesButto const onClick = () => { if (Object.keys(fileSelection).length === SELECTED_FILES_EMPTY) { setShowNoFilesSelectedModal(true) + } else { + handleClick() } } From 1f2fd8682b786d0b2cccce33d5906a2503d62f85 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Mon, 27 Nov 2023 19:40:27 -0500 Subject: [PATCH 10/12] fix: add unit test --- .../not-implemented/NotImplemented.spec.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/component/sections/not-implemented/NotImplemented.spec.tsx diff --git a/tests/component/sections/not-implemented/NotImplemented.spec.tsx b/tests/component/sections/not-implemented/NotImplemented.spec.tsx new file mode 100644 index 000000000..d7bc17c8c --- /dev/null +++ b/tests/component/sections/not-implemented/NotImplemented.spec.tsx @@ -0,0 +1,29 @@ +import { NotImplementedModal } from '../../../../src/sections/not-implemented/NotImplementedModal' +import { mount } from 'cypress/react18' + +describe('NotImplementedModal Component', () => { + it('renders the modal when show is true', () => { + // Mount the component with show set to true + mount( {}} />) + + // Check if the modal title is present + cy.findByText('Not Implemented').should('exist') + + // Check if the modal body has specific content + cy.findByText('This feature is not implemented yet in SPA.').should('exist') + }) + + it('closes the modal when the Close button is clicked', () => { + // A spy to check if handleClose is called + const handleClose = cy.spy().as('handleClose') + + // Mount the component with the spy as the handleClose prop + mount() + + // Click the Close button + cy.findByText('Close').click() + + // Check if handleClose was called + cy.get('@handleClose').should('have.been.calledOnce') + }) +}) From 530eb54aff032c642c4af79ec49cd13cc8787b15 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 28 Nov 2023 16:37:30 -0500 Subject: [PATCH 11/12] fix: lint errors --- src/sections/dataset/DatasetFactory.tsx | 4 ++-- .../publish-dataset-menu/PublishDatasetMenu.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sections/dataset/DatasetFactory.tsx b/src/sections/dataset/DatasetFactory.tsx index 55184eea5..7cbdecc0b 100644 --- a/src/sections/dataset/DatasetFactory.tsx +++ b/src/sections/dataset/DatasetFactory.tsx @@ -28,8 +28,8 @@ export class DatasetFactory { - - + + diff --git a/src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx b/src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx index 1b4cdb68b..6ea678467 100644 --- a/src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx +++ b/src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx @@ -35,8 +35,8 @@ export function PublishDatasetMenu({ dataset }: PublishDatasetMenuProps) { asButtonGroup variant="secondary" disabled={ - dataset.checkIsLockedFromPublishing(user.persistentId) || - !dataset.hasValidTermsOfAccess || + dataset.checkIsLockedFromPublishing(user.persistentId) || + !dataset.hasValidTermsOfAccess || !dataset.isValid }> {t('datasetActionButtons.publish.publish')} From db076476503de09c311e9293df20c6f9b3c1cbb9 Mon Sep 17 00:00:00 2001 From: MellyGray Date: Wed, 29 Nov 2023 10:37:16 +0100 Subject: [PATCH 12/12] fix: upload files button acting as submit --- .../dataset-upload-files-button/DatasetUploadFilesButton.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx b/src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx index f8cfedcb5..995904c6a 100644 --- a/src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx +++ b/src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx @@ -21,6 +21,7 @@ export function DatasetUploadFilesButton() { return (