Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ export const SuccessDialogWithCancel: Story = {
type: "success",
},
};

export const SuccessDialogLoading: Story = {
args: {
description: "I am successful.",
hideCancel: true,
type: "success",
confirmLoading: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ const CONFIRM_DIALOG_DEFAULTS: Record<
};

export interface ConfirmDialogProps
extends Omit<
DialogActionButtonsProps,
"color" | "confirmDialog" | "onCancel"
> {
extends Omit<DialogActionButtonsProps, "color" | "onCancel"> {
readonly description?: ReactNode;
/**
* hideCancel hides the cancel button when set true, and shows the cancel
Expand Down Expand Up @@ -135,7 +132,6 @@ export const ConfirmDialog: FC<PropsWithChildren<ConfirmDialogProps>> = ({
<DialogActions>
<DialogActionButtons
cancelText={cancelText}
confirmDialog
confirmLoading={confirmLoading}
confirmText={confirmText || defaults.confirmText}
disabled={disabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ const meta: Meta<typeof DeleteDialog> = {
};

export default meta;

type Story = StoryObj<typeof DeleteDialog>;

const Example: Story = {};

export const Loading: Story = {
args: {
confirmLoading: true,
},
};

export { Example as DeleteDialog };
29 changes: 22 additions & 7 deletions site/src/components/Dialogs/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export interface DialogActionButtonsProps {
confirmText?: ReactNode;
/** Whether or not confirm is loading, also disables cancel when true */
confirmLoading?: boolean;
/** Whether or not this is a confirm dialog */
confirmDialog?: boolean;
/** Whether or not the submit button is disabled */
disabled?: boolean;
/** Called when cancel is clicked */
Expand Down Expand Up @@ -49,6 +47,7 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
{cancelText}
</LoadingButton>
)}

{onConfirm && (
<LoadingButton
fullWidth
Expand Down Expand Up @@ -76,7 +75,10 @@ const styles = {
"&.MuiButton-contained": {
backgroundColor: colors.red[10],
borderColor: colors.red[9],
color: theme.palette.text.primary,

"&:not(.MuiLoadingButton-loading)": {
color: theme.palette.text.primary,
},

"&:hover:not(:disabled)": {
backgroundColor: colors.red[9],
Expand All @@ -86,26 +88,39 @@ const styles = {
"&.Mui-disabled": {
backgroundColor: colors.red[15],
borderColor: colors.red[15],
color: colors.red[9],

"&:not(.MuiLoadingButton-loading)": {
color: colors.red[9],
},
},
},
}),
successButton: (theme) => ({
"&.MuiButton-contained": {
backgroundColor: theme.palette.success.main,
color: theme.palette.primary.contrastText,

"&:not(.MuiLoadingButton-loading)": {
color: theme.palette.primary.contrastText,
},

"&:hover": {
backgroundColor: theme.palette.success.dark,

"@media (hover: none)": {
backgroundColor: "transparent",
},

"&.Mui-disabled": {
backgroundColor: "transparent",
},
},

"&.Mui-disabled": {
backgroundColor: theme.palette.action.disabledBackground,
color: theme.palette.text.secondary,
backgroundColor: theme.palette.success.dark,

"&:not(.MuiLoadingButton-loading)": {
color: theme.palette.text.secondary,
},
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export const ScheduleDialog: FC<PropsWithChildren<ScheduleDialogProps>> = ({
<DialogActions>
<DialogActionButtons
cancelText={cancelText}
confirmDialog
confirmLoading={confirmLoading}
confirmText="Submit"
disabled={disabled}
Expand Down