forked from uncch-rdmc/dataverse-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request IQSS#233 from IQSS/feature/222-not-implemented-modal
Feature/222 not implemented modal
- Loading branch information
Showing
15 changed files
with
202 additions
and
15 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
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
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
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
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,32 @@ | ||
import { Button, Modal } from '@iqss/dataverse-design-system' | ||
|
||
interface NotImplementedModalProps { | ||
show: boolean | ||
handleClose: () => void | ||
} | ||
|
||
export function NotImplementedModal({ show, handleClose }: NotImplementedModalProps) { | ||
const protocol = window.location.protocol | ||
const host = window.location.host | ||
const baseUrl = `${protocol}//${host}` | ||
|
||
return ( | ||
<Modal show={show} onHide={handleClose} size="lg"> | ||
<Modal.Header> | ||
<Modal.Title>Not Implemented</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<p>This feature is not implemented yet in SPA.</p> | ||
<p> | ||
If you want to use this feature you can go to the original{' '} | ||
<a href={baseUrl}>Dataverse page</a>. | ||
</p> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button variant="secondary" onClick={handleClose}> | ||
Close | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/sections/not-implemented/NotImplementedModalContext.ts
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,15 @@ | ||
import { createContext, useContext } from 'react' | ||
|
||
interface NotImplementedModalContextProps { | ||
showModal: () => void | ||
hideModal: () => void | ||
isModalOpen: boolean | ||
} | ||
|
||
export const NotImplementedModal = createContext<NotImplementedModalContextProps>({ | ||
isModalOpen: false, | ||
showModal: /* istanbul ignore next */ () => {}, | ||
hideModal: /* istanbul ignore next */ () => {} | ||
}) | ||
|
||
export const useNotImplementedModal = () => useContext(NotImplementedModal) |
14 changes: 14 additions & 0 deletions
14
src/sections/not-implemented/NotImplementedModalProvider.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,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 ( | ||
<NotImplementedModal.Provider value={{ isModalOpen, showModal, hideModal }}> | ||
{children} | ||
</NotImplementedModal.Provider> | ||
) | ||
} |
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,10 @@ | ||
import { StoryFn } from '@storybook/react' | ||
import { NotImplementedModalProvider } from '../sections/not-implemented/NotImplementedModalProvider' | ||
|
||
export const WithNotImplementedModal = (Story: StoryFn) => { | ||
return ( | ||
<NotImplementedModalProvider> | ||
<Story /> | ||
</NotImplementedModalProvider> | ||
) | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/stories/not-implemented/NotImplementedModal.stories.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,30 @@ | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import { NotImplementedModal } from '../../sections/not-implemented/NotImplementedModal' | ||
import { Button } from '@iqss/dataverse-design-system' | ||
import { useNotImplementedModal } from '../../sections/not-implemented/NotImplementedModalContext' | ||
import { WithNotImplementedModal } from '../WithNotImplementedModal' | ||
|
||
const meta: Meta<typeof NotImplementedModal> = { | ||
title: 'Sections/NotImplementedModal', | ||
component: NotImplementedModal, | ||
decorators: [WithNotImplementedModal] | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof NotImplementedModal> | ||
|
||
function DefaultExample() { | ||
const { showModal, hideModal, isModalOpen } = useNotImplementedModal() | ||
return ( | ||
<> | ||
<Button onClick={showModal}>Launch demo modal</Button> | ||
|
||
<NotImplementedModal show={isModalOpen} handleClose={hideModal} /> | ||
</> | ||
) | ||
} | ||
|
||
export const Default: Story = { | ||
render: () => DefaultExample() | ||
} |
Oops, something went wrong.