1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 15:29:42 +02:00

refactor(kube/namespaces): migrate table to react [EE-4694] (#10988)

This commit is contained in:
Chaim Lev-Ari 2024-04-02 22:26:22 +03:00 committed by GitHub
parent da615afc92
commit 26bb028ace
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 387 additions and 346 deletions

View file

@ -5,18 +5,30 @@ import { confirmDelete } from '@@/modals/confirm';
import { Button } from './Button';
type ConfirmOrClick =
| {
confirmMessage: ReactNode;
onConfirmed(): Promise<void> | void;
onClick?: never;
}
| {
confirmMessage?: never;
onConfirmed?: never;
/** if onClick is set, will skip confirmation (confirmation should be done on the parent) */
onClick(): void;
};
export function DeleteButton({
disabled,
confirmMessage,
onConfirmed,
size,
children,
}: PropsWithChildren<{
size?: ComponentProps<typeof Button>['size'];
disabled?: boolean;
confirmMessage: ReactNode;
onConfirmed(): Promise<void> | void;
}>) {
...props
}: PropsWithChildren<
ConfirmOrClick & {
size?: ComponentProps<typeof Button>['size'];
disabled?: boolean;
}
>) {
return (
<Button
size={size}
@ -31,6 +43,11 @@ export function DeleteButton({
);
async function handleClick() {
const { confirmMessage, onConfirmed, onClick } = props;
if (onClick) {
return onClick();
}
if (!(await confirmDelete(confirmMessage))) {
return undefined;
}