diff --git a/components/dashboard/package.json b/components/dashboard/package.json index d435735020e08a..654f61951752d2 100644 --- a/components/dashboard/package.json +++ b/components/dashboard/package.json @@ -10,6 +10,7 @@ "@stripe/react-stripe-js": "^1.7.2", "@stripe/stripe-js": "^1.29.0", "@types/react-datepicker": "^4.8.0", + "classnames": "^2.3.1", "configcat-js": "^6.0.0", "countries-list": "^2.6.1", "dayjs": "^1.11.5", @@ -43,7 +44,6 @@ "@typescript-eslint/eslint-plugin": "^4.21.0", "@typescript-eslint/parser": "^4.21.0", "autoprefixer": "^9.8.6", - "classnames": "^2.3.1", "cypress": "^9.2.1", "eslint": "^7.24.0", "eslint-config-react-app": "^6.0.0", diff --git a/components/dashboard/src/components/Modal.tsx b/components/dashboard/src/components/Modal.tsx index c65e7bcbd039fe..3ef0fc831c643e 100644 --- a/components/dashboard/src/components/Modal.tsx +++ b/components/dashboard/src/components/Modal.tsx @@ -4,7 +4,8 @@ * See License-AGPL.txt in the project root for license information. */ -import { useEffect } from "react"; +import { ReactNode, useEffect } from "react"; +import cn from "classnames"; import { getGitpodService } from "../service/service"; type CloseModalManner = "esc" | "enter" | "x"; @@ -14,8 +15,8 @@ export default function Modal(props: { specify?: string; title?: string; hideDivider?: boolean; - buttons?: React.ReactChild[] | React.ReactChild; - children: React.ReactChild[] | React.ReactChild; + buttons?: ReactNode; + children: ReactNode; visible: boolean; closeable?: boolean; className?: string; @@ -75,10 +76,10 @@ export default function Modal(props: {
{props.closeable !== false && (
-

{props.title}

-
- {props.children} -
-
{props.buttons}
+ {props.title} + {props.children} + {props.buttons} ) : ( props.children @@ -112,3 +106,35 @@ export default function Modal(props: {
); } + +type ModalHeaderProps = { + children: ReactNode; +}; + +export const ModalHeader = ({ children }: ModalHeaderProps) => { + return

{children}

; +}; + +type ModalBodyProps = { + children: ReactNode; + hideDivider?: boolean; +}; + +export const ModalBody = ({ children, hideDivider = false }: ModalBodyProps) => { + return ( +
+ {children} +
+ ); +}; + +type ModalFooterProps = { + children: ReactNode; +}; +export const ModalFooter = ({ children }: ModalFooterProps) => { + return
{children}
; +}; diff --git a/components/dashboard/src/settings/EnvironmentVariables.tsx b/components/dashboard/src/settings/EnvironmentVariables.tsx index b52e33e3feba1a..c5056fe3e8fbc0 100644 --- a/components/dashboard/src/settings/EnvironmentVariables.tsx +++ b/components/dashboard/src/settings/EnvironmentVariables.tsx @@ -8,7 +8,7 @@ import { UserEnvVar, UserEnvVarValue } from "@gitpod/gitpod-protocol"; import { useEffect, useRef, useState } from "react"; import ConfirmationModal from "../components/ConfirmationModal"; import { Item, ItemField, ItemFieldContextMenu, ItemsList } from "../components/ItemsList"; -import Modal from "../components/Modal"; +import Modal, { ModalBody, ModalFooter, ModalHeader } from "../components/Modal"; import { getGitpodService } from "../service/service"; import { PageWithSettingsSubMenu } from "./PageWithSettingsSubMenu"; @@ -52,8 +52,8 @@ function AddEnvVarModal(p: EnvVarModalProps) { return ( // TODO: Use title and buttons props -

{isNew ? "New" : "Edit"} Variable

-
+ {isNew ? "New" : "Edit"} Variable + {error ? (
{error}
) : null} @@ -98,15 +98,15 @@ function AddEnvVarModal(p: EnvVarModalProps) { make it available in more projects.

-
-
+ + -
+ ); } diff --git a/components/dashboard/src/settings/Integrations.tsx b/components/dashboard/src/settings/Integrations.tsx index 054e3abc2880fb..a1158eb5fb4fd6 100644 --- a/components/dashboard/src/settings/Integrations.tsx +++ b/components/dashboard/src/settings/Integrations.tsx @@ -13,7 +13,7 @@ import ConfirmationModal from "../components/ConfirmationModal"; import { ContextMenuEntry } from "../components/ContextMenu"; import InfoBox from "../components/InfoBox"; import { Item, ItemField, ItemFieldContextMenu, ItemFieldIcon, ItemsList } from "../components/ItemsList"; -import Modal from "../components/Modal"; +import Modal, { ModalBody, ModalHeader, ModalFooter } from "../components/Modal"; import copy from "../images/copy.svg"; import exclamation from "../images/exclamation.svg"; import { openAuthorizeWindow } from "../provider-utils"; @@ -291,8 +291,8 @@ function GitProviders() { {editModal && ( // TODO: Use title and buttons props setEditModal(undefined)}> -

Edit Permissions

-
+ Edit Permissions +
Configure provider permissions.
{(editModal.provider.scopes || []).map((scope) => (
@@ -307,15 +307,15 @@ function GitProviders() { >
))} -
-
+ + -
+
)}