refactor: move delete button into more button dropdown

This commit is contained in:
moonrailgun 2024-02-08 15:56:21 +08:00
parent e9b783f047
commit 70c60b5ee1

View File

@ -94,14 +94,24 @@ export const MonitorInfo: React.FC<MonitorInfoProps> = React.memo((props) => {
}); });
const handleDelete = useEvent(async () => { const handleDelete = useEvent(async () => {
Modal.confirm({
title: 'Warning',
content: 'Did you sure delete this monitor?',
okButtonProps: {
danger: true,
},
onOk: async () => {
await deleteMutation.mutateAsync({ await deleteMutation.mutateAsync({
workspaceId, workspaceId,
monitorId, monitorId,
}); });
await trpcUtils.monitor.all.refetch();
trpcUtils.monitor.all.refetch(); navigate('/monitor', {
replace: true,
navigate('/monitor'); });
},
});
}); });
const handleClearEvents = useEvent(() => { const handleClearEvents = useEvent(() => {
@ -205,13 +215,6 @@ export const MonitorInfo: React.FC<MonitorInfoProps> = React.memo((props) => {
</Button> </Button>
)} )}
<Popconfirm
title="Did you sure delete this monitor?"
onConfirm={handleDelete}
>
<Button danger={true}>Delete</Button>
</Popconfirm>
<Dropdown <Dropdown
trigger={['click']} trigger={['click']}
placement="bottomRight" placement="bottomRight"
@ -222,6 +225,15 @@ export const MonitorInfo: React.FC<MonitorInfoProps> = React.memo((props) => {
label: 'Show Badge', label: 'Show Badge',
onClick: () => setShowBadge(true), onClick: () => setShowBadge(true),
}, },
{
type: 'divider',
},
{
key: 'delete',
label: 'Delete',
danger: true,
onClick: handleDelete,
},
], ],
}} }}
> >