add delete button

This commit is contained in:
Maren Süwer
2018-08-30 11:33:49 +02:00
parent d8d106d441
commit 961cbd9f90

View File

@@ -11,7 +11,12 @@ type Props = {
name: string, name: string,
confirmDialog?: boolean, confirmDialog?: boolean,
t: string => string, t: string => string,
deletePermission: (permission: Permission, namespace: string, name: string) => void deletePermission: (
permission: Permission,
namespace: string,
name: string
) => void,
loading: boolean
}; };
class DeletePermissionButton extends React.Component<Props> { class DeletePermissionButton extends React.Component<Props> {
@@ -20,7 +25,11 @@ class DeletePermissionButton extends React.Component<Props> {
}; };
deletePermission = () => { deletePermission = () => {
this.props.deletePermission(this.props.permission, this.props.namespace, this.props.name); this.props.deletePermission(
this.props.permission,
this.props.namespace,
this.props.name
);
}; };
confirmDelete = () => { confirmDelete = () => {
@@ -46,13 +55,19 @@ class DeletePermissionButton extends React.Component<Props> {
}; };
render() { render() {
const { confirmDialog, t } = this.props; const { confirmDialog, loading, t } = this.props;
const action = confirmDialog ? this.confirmDelete : this.deletePermission; const action = confirmDialog ? this.confirmDelete : this.deletePermission;
if (!this.isDeletable()) { if (!this.isDeletable()) {
return null; return null;
} }
return <DeleteButton label={t("delete-permission-button.label")} action={action} />; return (
<DeleteButton
label={t("delete-permission-button.label")}
action={action}
loading={loading}
/>
);
} }
} }