diff --git a/pkg/machines/actions/provider-actions.es6 b/pkg/machines/actions/provider-actions.es6 index 518979e0776e..9d9a1e61940f 100644 --- a/pkg/machines/actions/provider-actions.es6 +++ b/pkg/machines/actions/provider-actions.es6 @@ -29,6 +29,7 @@ import { CREATE_AND_ATTACH_VOLUME, CREATE_VM, DELETE_VM, + DETACH_DISK, ENABLE_LIBVIRT, FORCEOFF_VM, FORCEREBOOT_VM, @@ -79,6 +80,10 @@ export function deleteVm(vm, options) { return virt(DELETE_VM, { name: vm.name, id: vm.id, connectionName: vm.connectionName, options: options }); } +export function detachDisk({ connectionName, target, name, id, live = false }) { + return virt(DETACH_DISK, { connectionName, target, name, id, live }); +} + export function enableLibvirt(enable, serviceName) { return virt(ENABLE_LIBVIRT, { enable, serviceName }); } diff --git a/pkg/machines/components/diskRemove.jsx b/pkg/machines/components/diskRemove.jsx new file mode 100644 index 000000000000..42a680414de2 --- /dev/null +++ b/pkg/machines/components/diskRemove.jsx @@ -0,0 +1,35 @@ +/* + * This file is part of Cockpit. + * + * Copyright (C) 2018 Red Hat, Inc. + * + * Cockpit is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * Cockpit is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Cockpit; If not, see . + */ +import React from 'react'; + +import { detachDisk } from '../actions/provider-actions.es6'; + +const onDetachDisk = (dispatch, vm, target) => { + return () => { + dispatch(detachDisk({ connectionName:vm.connectionName, id:vm.id, name:vm.name, target, live: vm.state == 'running' })); + }; +}; + +const RemoveDiskAction = ({ dispatch, vm, target, idPrefixRow }) => { + return ( +