Change add to library "show duplicate entry" button to be a link

This commit is contained in:
schroda
2025-12-02 22:08:12 +01:00
parent 17390b4ed9
commit 36248e17f0
3 changed files with 44 additions and 16 deletions

View File

@@ -14,6 +14,7 @@ import { useTranslation } from 'react-i18next';
import Button from '@mui/material/Button';
import Stack from '@mui/material/Stack';
import { AwaitableComponentProps } from 'awaitable-component';
import { Link as RouterLink } from 'react-router-dom';
type Action = {
show?: boolean;
@@ -22,7 +23,7 @@ type Action = {
};
type Actions = {
extra?: Action;
extra?: Action & { link?: string };
cancel?: Action;
confirm?: Action;
};
@@ -49,6 +50,7 @@ export const ConfirmDialog = ({
show: passedActions?.extra?.show ?? false,
title: passedActions?.extra?.title ?? '',
contain: passedActions?.extra?.contain ?? false,
link: passedActions?.extra?.link ?? undefined,
},
cancel: {
show: passedActions?.cancel?.show ?? true,
@@ -85,17 +87,39 @@ export const ConfirmDialog = ({
gap: 1,
}}
>
{actions.extra.show && (
<Button
onClick={() => {
onDismiss();
onExtra?.();
}}
variant={actions.extra.contain ? 'contained' : undefined}
>
{actions.extra.title}
</Button>
)}
{(() => {
if (!actions.extra.show) {
return null;
}
if (actions.extra.link) {
return (
<Button
component={RouterLink}
to={actions.extra.link}
onClick={() => {
onDismiss();
onExtra?.();
}}
variant={actions.extra.contain ? 'contained' : undefined}
>
{actions.extra.title}
</Button>
);
}
return (
<Button
onClick={() => {
onDismiss();
onExtra?.();
}}
variant={actions.extra.contain ? 'contained' : undefined}
>
{actions.extra.title}
</Button>
);
})()}
<Stack
sx={{
flexDirection: 'row',