diff --git a/dashboard/src/components/modal/InstallModal.stories.tsx b/dashboard/src/components/modal/InstallModal.stories.tsx new file mode 100644 index 00000000..0e682360 --- /dev/null +++ b/dashboard/src/components/modal/InstallModal.stories.tsx @@ -0,0 +1,30 @@ +// Modal.stories.ts|tsx + +import { ComponentStory, ComponentMeta } from "@storybook/react"; +import InstallModal from "./InstallModal"; + +//๐Ÿ‘‡ This default export determines where your story goes in the story list +export default { + /* ๐Ÿ‘‡ The title prop is optional. + * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ + title: "InstallModal", + component: InstallModal, +} as ComponentMeta; + +//๐Ÿ‘‡ We create a โ€œtemplateโ€ of how args map to rendering +const Template: ComponentStory = (args) => ( + console.log("confirm clicked")} + > +); + +export const Default = Template.bind({}); + +Default.args = { + installTarget: "airflow", + isOpen: true, +}; diff --git a/dashboard/src/components/modal/InstallModal.tsx b/dashboard/src/components/modal/InstallModal.tsx new file mode 100644 index 00000000..996d4bc0 --- /dev/null +++ b/dashboard/src/components/modal/InstallModal.tsx @@ -0,0 +1,147 @@ +import { useEffect, useState } from "react"; +import Modal from "./Modal"; +import { ModalAction, ModalButtonStyle } from "./Modal"; + +interface InstallModalProps { + isOpen: boolean; + installTarget: string; + onConfirm: () => void; +} + +interface VersionToInstall { + id: string; + name: string; +} + +const versionsToInstall: VersionToInstall[] = [ + { id: "1", name: "bitnami @ 14.0.14" }, + { id: "2", name: "bitnami @ 15.0.15" }, + { id: "3", name: "bitnami @ 16.0.16" }, +]; + +const cluster = "kind-kind"; + +export default function InstallModal({ + isOpen, + onConfirm, + installTarget, +}: InstallModalProps) { + const uninstallTitle = ( +
+ Install {installTarget} +
+ ); + + const [confirmModalActions, setConfirmModalActions] = + useState(); + + useEffect(() => { + setConfirmModalActions([ + { + id: "1", + text: "Confirm", + callback: onConfirm, + variant: ModalButtonStyle.info, + }, + ]); + }, [onConfirm]); + + return ( + +
+
+ +
+ +
+ + + +
+
+
+
+
+ + +
+ +
+ + +
+
+ +
+
+
+ + +
+
+ +
+
+
+
+ +
+
+
+ ); +} diff --git a/dashboard/src/components/modal/Modal.tsx b/dashboard/src/components/modal/Modal.tsx index 16f090fe..dd0b086e 100644 --- a/dashboard/src/components/modal/Modal.tsx +++ b/dashboard/src/components/modal/Modal.tsx @@ -9,18 +9,18 @@ export enum ModalButtonStyle { } export interface ModalAction { - id: string, - callback: () => void, - text: string, - variant?: ModalButtonStyle, - className?: string + id: string; + callback: () => void; + text: string; + variant?: ModalButtonStyle; + className?: string; } export interface ModalProps extends PropsWithChildren { - title?: string | ReactNode, - isOpen: boolean, - onClose: () => void, - actions?: ModalAction[], + title?: string | ReactNode; + isOpen: boolean; + onClose: () => void; + actions?: ModalAction[]; } const Modal = ({ title, isOpen, onClose, children, actions }: ModalProps) => { @@ -70,56 +70,55 @@ const Modal = ({ title, isOpen, onClose, children, actions }: ModalProps) => { return ReactDom.createPortal( <> {isVisible && ( - <> -
-
- {title && ( -
- {getTitle(title)} - + + + + +
+ )} +
+ {children} +
+
+ {actions?.map((action) => ( + + ))}
- )} -
- {children} -
-
- {actions?.map((action) => ( - - ))}
- )} , - document.getElementById("portal") + document.getElementById("portal")! ); };