mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
- Add support for multiple share URLs per website with server-generated slugs - Create shares API endpoint for listing and creating website shares - Add SharesTable, ShareEditButton, ShareDeleteButton components - Move share management to website settings, remove header share button - Remove shareId from website update API (now uses separate share table) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { ConfirmationForm } from '@/components/common/ConfirmationForm';
|
|
import { useDeleteQuery, useMessages, useModified } from '@/components/hooks';
|
|
import { Trash } from '@/components/icons';
|
|
import { DialogButton } from '@/components/input/DialogButton';
|
|
import { messages } from '@/components/messages';
|
|
|
|
export function ShareDeleteButton({
|
|
shareId,
|
|
slug,
|
|
onSave,
|
|
}: {
|
|
shareId: string;
|
|
slug: string;
|
|
onSave?: () => void;
|
|
}) {
|
|
const { formatMessage, labels, getErrorMessage, FormattedMessage } = useMessages();
|
|
const { mutateAsync, isPending, error } = useDeleteQuery(`/share/id/${shareId}`);
|
|
const { touch } = useModified();
|
|
|
|
const handleConfirm = async (close: () => void) => {
|
|
await mutateAsync(null, {
|
|
onSuccess: () => {
|
|
touch('shares');
|
|
onSave?.();
|
|
close();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<DialogButton
|
|
icon={<Trash />}
|
|
title={formatMessage(labels.confirm)}
|
|
variant="quiet"
|
|
width="400px"
|
|
>
|
|
{({ close }) => (
|
|
<ConfirmationForm
|
|
message={
|
|
<FormattedMessage
|
|
{...messages.confirmRemove}
|
|
values={{
|
|
target: <b>{slug}</b>,
|
|
}}
|
|
/>
|
|
}
|
|
isLoading={isPending}
|
|
error={getErrorMessage(error)}
|
|
onConfirm={handleConfirm.bind(null, close)}
|
|
onClose={close}
|
|
buttonLabel={formatMessage(labels.delete)}
|
|
buttonVariant="danger"
|
|
/>
|
|
)}
|
|
</DialogButton>
|
|
);
|
|
}
|