import { ConfirmAction } from 'containers/Action';
import { checkSystemAdmin } from 'resources/skyline/policy';
import globalLbaasStore from 'stores/octavia/loadbalancer';
import globalRootStore from 'stores/root';
export default class DeleteAction extends ConfirmAction {
get id() {
return 'delete';
}
get title() {
return t('Delete Load Balancer');
}
get isDanger() {
return true;
}
get buttonText() {
return t('Delete');
}
get actionName() {
return t('delete load balancer');
}
policy = 'os_load-balancer_api:loadbalancer:delete';
confirmContext = (data) => {
const name = this.getName(data);
return (
t('Are you sure to {action} (instance: {name})?', {
action: this.actionNameDisplay || this.title,
name,
}) + t('This will delete all child objects of the load balancer.')
);
};
allowedCheckFunc = (item) => {
if (!item) {
return true;
}
return (
(this.isCurrentProject(item) && item.provisioning_status === 'ACTIVE') ||
item.provisioning_status === 'ERROR'
);
};
isCurrentProject(item) {
const rootStore = globalRootStore;
if (!checkSystemAdmin() && item.project_id !== rootStore.user.project.id) {
return false;
}
return true;
}
onSubmit = (data) => globalLbaasStore.delete(data);
}