From 84d588a3b7eaf03045ac230d85a8e979c02b25e5 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Mon, 14 Oct 2024 23:37:13 +0100 Subject: [PATCH 1/2] Update auth admin design + add support for webhooks and openid connect providers --- shared/common/newui/button/index.tsx | 31 +- .../newui/checkbox/checkbox.module.scss | 8 + shared/common/newui/checkbox/index.tsx | 22 +- shared/common/newui/loadingSkeleton/index.tsx | 5 + .../loadingSkeleton.module.scss | 30 + shared/common/newui/panelTabs/index.tsx | 33 + .../newui/panelTabs/panelTabs.module.scss | 94 ++ shared/common/newui/select/index.tsx | 1 + shared/common/newui/textInput/index.tsx | 3 + .../databasePage/databasePage.module.scss | 4 +- shared/studio/tabs/ai/index.tsx | 32 +- shared/studio/tabs/ai/prompts.tsx | 2 +- shared/studio/tabs/ai/providers.tsx | 2 +- shared/studio/tabs/auth/authAdmin.module.scss | 924 ++++++------ shared/studio/tabs/auth/config.tsx | 400 ++++++ shared/studio/tabs/auth/index.tsx | 1264 +---------------- shared/studio/tabs/auth/loginUIPreview.tsx | 29 +- .../tabs/auth/loginuipreview.module.scss | 8 +- shared/studio/tabs/auth/providers.tsx | 647 +++++++++ shared/studio/tabs/auth/shared.tsx | 55 + shared/studio/tabs/auth/smtp.tsx | 253 ++++ shared/studio/tabs/auth/state/index.tsx | 332 ++++- shared/studio/tabs/auth/webhooks.tsx | 196 +++ web/src/app.module.scss | 2 +- web/src/app.tsx | 3 +- 25 files changed, 2595 insertions(+), 1785 deletions(-) create mode 100644 shared/common/newui/loadingSkeleton/index.tsx create mode 100644 shared/common/newui/loadingSkeleton/loadingSkeleton.module.scss create mode 100644 shared/common/newui/panelTabs/index.tsx create mode 100644 shared/common/newui/panelTabs/panelTabs.module.scss create mode 100644 shared/studio/tabs/auth/config.tsx create mode 100644 shared/studio/tabs/auth/providers.tsx create mode 100644 shared/studio/tabs/auth/shared.tsx create mode 100644 shared/studio/tabs/auth/smtp.tsx create mode 100644 shared/studio/tabs/auth/webhooks.tsx diff --git a/shared/common/newui/button/index.tsx b/shared/common/newui/button/index.tsx index ac00ab8b..6adc35cb 100644 --- a/shared/common/newui/button/index.tsx +++ b/shared/common/newui/button/index.tsx @@ -2,7 +2,7 @@ import cn from "@edgedb/common/utils/classNames"; import styles from "./button.module.scss"; import Spinner from "../../ui/spinner"; -import {PropsWithChildren} from "react"; +import {CSSProperties, PropsWithChildren, useEffect, useState} from "react"; interface _BaseButtonProps { className?: string; @@ -12,6 +12,7 @@ interface _BaseButtonProps { rightIcon?: JSX.Element; disabled?: boolean; loading?: boolean; + style?: CSSProperties; } export interface ButtonProps extends _BaseButtonProps { @@ -107,3 +108,31 @@ export function LinkButton({ ); } + +export function ConfirmButton({onClick, children, ...props}: ButtonProps) { + const [confirming, setConfirming] = useState(false); + + useEffect(() => { + if (confirming) { + const timer = setTimeout(() => setConfirming(false), 1000); + + return () => clearTimeout(timer); + } + }, [confirming]); + + return ( + + ); +} diff --git a/shared/common/newui/checkbox/checkbox.module.scss b/shared/common/newui/checkbox/checkbox.module.scss index 995ae8c8..2cf420b7 100644 --- a/shared/common/newui/checkbox/checkbox.module.scss +++ b/shared/common/newui/checkbox/checkbox.module.scss @@ -43,6 +43,14 @@ pointer-events: none; } + &.readonly { + pointer-events: none; + + .check { + opacity: 0.5; + } + } + @include darkTheme { color: #ccc; diff --git a/shared/common/newui/checkbox/index.tsx b/shared/common/newui/checkbox/index.tsx index 312e86f2..8822d96a 100644 --- a/shared/common/newui/checkbox/index.tsx +++ b/shared/common/newui/checkbox/index.tsx @@ -2,32 +2,40 @@ import cn from "@edgedb/common/utils/classNames"; import styles from "./checkbox.module.scss"; -export interface CheckboxProps { +export type CheckboxProps = { className?: string; label?: string | JSX.Element; checked: boolean; - onChange: (checked: boolean) => void; disabled?: boolean; -} + readOnly?: Readonly; +} & (Readonly extends true + ? { + onChange?: (checked: boolean) => void; + } + : { + onChange: (checked: boolean) => void; + }); -export function Checkbox({ +export function Checkbox({ className, label, checked, onChange, disabled, -}: CheckboxProps) { + readOnly, +}: CheckboxProps) { return (