Skip to content

fix(site): fix dialog loading buttons displaying text over the spinner #10501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 3, 2023
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,
},
};
6 changes: 1 addition & 5 deletions site/src/components/Dialogs/ConfirmDialog/ConfirmDialog.tsx
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