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:
parent
da615afc92
commit
26bb028ace
18 changed files with 387 additions and 346 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue