mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(ui/buttons): introduce Add and Delete buttons [EE-6296] (#10585)
This commit is contained in:
parent
66635ba6b1
commit
1f2f4525e3
6 changed files with 108 additions and 47 deletions
40
app/react/components/buttons/DeleteButton.tsx
Normal file
40
app/react/components/buttons/DeleteButton.tsx
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { Trash2 } from 'lucide-react';
|
||||
import { ComponentProps, PropsWithChildren, ReactNode } from 'react';
|
||||
|
||||
import { confirmDelete } from '@@/modals/confirm';
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
export function DeleteButton({
|
||||
disabled,
|
||||
confirmMessage,
|
||||
onConfirmed,
|
||||
size,
|
||||
children,
|
||||
}: PropsWithChildren<{
|
||||
size?: ComponentProps<typeof Button>['size'];
|
||||
disabled?: boolean;
|
||||
confirmMessage: ReactNode;
|
||||
onConfirmed(): Promise<void> | void;
|
||||
}>) {
|
||||
return (
|
||||
<Button
|
||||
size={size}
|
||||
color="dangerlight"
|
||||
disabled={disabled}
|
||||
onClick={() => handleClick()}
|
||||
icon={Trash2}
|
||||
className="!m-0"
|
||||
>
|
||||
{children || 'Remove'}
|
||||
</Button>
|
||||
);
|
||||
|
||||
async function handleClick() {
|
||||
if (!(await confirmDelete(confirmMessage))) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return onConfirmed();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue