Add option to highlight specific button in ConfirmDialog
This commit is contained in:
@@ -118,7 +118,7 @@ export const useManageMangaLibraryState = (
|
|||||||
error: e.message,
|
error: e.message,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
extra: { show: true, title: t('global.button.retry') },
|
extra: { show: true, title: t('global.button.retry'), contain: true },
|
||||||
confirm: { title: t('global.button.add') },
|
confirm: { title: t('global.button.add') },
|
||||||
},
|
},
|
||||||
onExtra: () =>
|
onExtra: () =>
|
||||||
@@ -134,7 +134,7 @@ export const useManageMangaLibraryState = (
|
|||||||
title: t('global.label.are_you_sure'),
|
title: t('global.label.are_you_sure'),
|
||||||
message: t('manga.action.library.add.dialog.duplicate.label.info'),
|
message: t('manga.action.library.add.dialog.duplicate.label.info'),
|
||||||
actions: {
|
actions: {
|
||||||
extra: { show: true, title: t('migrate.dialog.action.button.show_entry') },
|
extra: { show: true, title: t('migrate.dialog.action.button.show_entry'), contain: true },
|
||||||
confirm: { title: t('global.button.add') },
|
confirm: { title: t('global.button.add') },
|
||||||
},
|
},
|
||||||
onExtra: () => navigate(`/manga/${duplicatedLibraryMangas!.data.mangas.nodes[0].id}`),
|
onExtra: () => navigate(`/manga/${duplicatedLibraryMangas!.data.mangas.nodes[0].id}`),
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import Stack from '@mui/material/Stack';
|
|||||||
type Action = {
|
type Action = {
|
||||||
show?: boolean;
|
show?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
contain?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Actions = {
|
type Actions = {
|
||||||
@@ -46,14 +47,21 @@ export const ConfirmDialog = ({
|
|||||||
extra: {
|
extra: {
|
||||||
show: passedActions?.extra?.show ?? false,
|
show: passedActions?.extra?.show ?? false,
|
||||||
title: passedActions?.extra?.title ?? '',
|
title: passedActions?.extra?.title ?? '',
|
||||||
|
contain: passedActions?.extra?.contain ?? false,
|
||||||
},
|
},
|
||||||
cancel: {
|
cancel: {
|
||||||
show: passedActions?.cancel?.show ?? true,
|
show: passedActions?.cancel?.show ?? true,
|
||||||
title: passedActions?.cancel?.title ?? t('global.button.cancel'),
|
title: passedActions?.cancel?.title ?? t('global.button.cancel'),
|
||||||
|
contain: passedActions?.cancel?.contain ?? false,
|
||||||
},
|
},
|
||||||
confirm: {
|
confirm: {
|
||||||
show: passedActions?.confirm?.show ?? true,
|
show: passedActions?.confirm?.show ?? true,
|
||||||
title: passedActions?.confirm?.title ?? t('global.button.ok'),
|
title: passedActions?.confirm?.title ?? t('global.button.ok'),
|
||||||
|
contain:
|
||||||
|
!passedActions?.extra?.contain &&
|
||||||
|
!passedActions?.cancel?.contain &&
|
||||||
|
!passedActions?.confirm?.contain &&
|
||||||
|
true,
|
||||||
},
|
},
|
||||||
} satisfies Actions;
|
} satisfies Actions;
|
||||||
|
|
||||||
@@ -73,10 +81,22 @@ export const ConfirmDialog = ({
|
|||||||
direction="row"
|
direction="row"
|
||||||
justifyContent={actions.extra.show ? 'space-between' : 'end'}
|
justifyContent={actions.extra.show ? 'space-between' : 'end'}
|
||||||
>
|
>
|
||||||
{actions.extra.show && <Button onClick={onExtra}>{actions.extra.title}</Button>}
|
{actions.extra.show && (
|
||||||
|
<Button onClick={onExtra} variant={actions.extra.contain ? 'contained' : undefined}>
|
||||||
|
{actions.extra.title}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
{actions.cancel.show && <Button onClick={onCancel}>{actions.cancel.title}</Button>}
|
{actions.cancel.show && (
|
||||||
{actions.confirm.show && <Button onClick={onConfirm}>{actions.confirm.title}</Button>}
|
<Button onClick={onCancel} variant={actions.cancel.contain ? 'contained' : undefined}>
|
||||||
|
{actions.cancel.title}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{actions.confirm.show && (
|
||||||
|
<Button onClick={onConfirm} variant={actions.confirm.contain ? 'contained' : undefined}>
|
||||||
|
{actions.confirm.title}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
|
|||||||
Reference in New Issue
Block a user