diff --git a/src/components/FullPlayground.tsx b/src/components/FullPlayground.tsx index 6364620..f7bd447 100644 --- a/src/components/FullPlayground.tsx +++ b/src/components/FullPlayground.tsx @@ -602,7 +602,7 @@ export function ThemedAppView(props: { datastore: DataStore }) { >(undefined); const conductValidation = () => { - validationService.conductValidation((validated: boolean) => { + validationService.conductValidation(() => { return false; }); }; diff --git a/src/playground-ui/ConfirmDialog.tsx b/src/playground-ui/ConfirmDialog.tsx index 5da9528..b541d3f 100644 --- a/src/playground-ui/ConfirmDialog.tsx +++ b/src/playground-ui/ConfirmDialog.tsx @@ -8,10 +8,12 @@ import DialogTitle from "@material-ui/core/DialogTitle"; import TextField from "@material-ui/core/TextField"; import React, { useState } from "react"; +export type ConfirmValue = "undefined" | "load" | "replace" | "nevermind" + /** * ConfirmDialogButton is a button in the confirm dialog. */ -export interface ConfirmDialogButton { +export interface ConfirmDialogButton { /** * title is the title of the button. */ @@ -20,7 +22,7 @@ export interface ConfirmDialogButton { /** * value is the value to given to the callback if the button is clicked. */ - value: B + value?: ConfirmValue /** * color is the color of the button. Default is `default`. @@ -38,12 +40,12 @@ export interface ConfirmDialogButton { isEnabled?: (promptValue?: string) => boolean } -export type ConfirmCallback = (value: B, promptValue?: string) => void; +export type ConfirmCallback = (value: ConfirmValue, promptValue?: string) => void; /** * ConfirmDialogProps are the props for the confirm dialog. */ -export interface ConfirmDialogProps { +export interface ConfirmDialogProps { /** * isOpen indicates whether the ConfirmDialog is currently open. */ @@ -54,7 +56,7 @@ export interface ConfirmDialogProps { * returns the value clicked. If the [X] is clicked, the `value` will be * undefined. */ - handleComplete: ConfirmCallback + handleComplete: ConfirmCallback /** * title is the title of the confirm. @@ -69,7 +71,7 @@ export interface ConfirmDialogProps { /** * buttons are the buttons on the confirm dialog. */ - buttons: ConfirmDialogButton[] + buttons: ConfirmDialogButton[] /** @@ -97,13 +99,15 @@ const useStyles = makeStyles((theme: Theme) => * title="My confirm" content="Hi there!" * buttons={[{"title": "Close", "value": undefined}]}/> */ -export function ConfirmDialog(props: ConfirmDialogProps) { +export function ConfirmDialog(props: ConfirmDialogProps) { const [promptValue, setPromptValue] = useState(''); const classes = useStyles(); - const handleComplete = (value: any) => { - props.handleComplete(value as B, promptValue); - setPromptValue(''); + const handleComplete = (value: ConfirmValue | undefined) => { + if (value) { + props.handleComplete(value, promptValue); + setPromptValue(''); + } }; return (props: ConfirmDialogProps) { - {props.buttons.map((button: ConfirmDialogButton, index: number) => { + {props.buttons.map((button: ConfirmDialogButton, index: number) => { return