+ {loadError &&
{loadError.message}}
{isVmRunning(this.props.vm) && (
The VM {getName(this.props.vm)} is still running. It will be powered off while cloning.
@@ -182,16 +213,83 @@ export class CloneDialog extends React.Component {
CloneDialog.propTypes = {
vm: PropTypes.object.isRequired,
- namespaces: PropTypes.array.isRequired,
- persistentVolumeClaims: PropTypes.array.isRequired,
- LoadingComponent: PropTypes.func,
- virtualMachines: PropTypes.array.isRequired,
k8sCreate: PropTypes.func.isRequired,
k8sPatch: PropTypes.func.isRequired,
- dataVolumes: PropTypes.array.isRequired,
- onClose: PropTypes.func.isRequired,
+ namespaces: PropTypes.object,
+ persistentVolumeClaims: PropTypes.object,
+ virtualMachines: PropTypes.object,
+ dataVolumes: PropTypes.object,
+ requestsDatavolumes: PropTypes.bool,
+ requestsPVCs: PropTypes.bool,
+ loadError: PropTypes.object,
+ LoadingComponent: PropTypes.func,
+ close: PropTypes.func.isRequired,
+ cancel: PropTypes.func.isRequired,
};
CloneDialog.defaultProps = {
LoadingComponent: Loading,
+ namespaces: null,
+ persistentVolumeClaims: null,
+ virtualMachines: null,
+ dataVolumes: null,
+ requestsDatavolumes: false,
+ requestsPVCs: false,
+ loadError: null,
+};
+
+// eslint-disable-next-line react/no-multi-comp
+export class CloneVMModalFirehose extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ namespace: getNamespace(props.vm),
+ };
+ }
+
+ render() {
+ const { vm, Firehose } = this.props;
+ const { namespace } = this.state;
+
+ const requestsDatavolumes = !!getVolumes(vm).find(v => v.dataVolume && v.dataVolume.name);
+ const requestsPVCs = !!getVolumes(vm).find(v => v.persistentVolumeClaim && v.persistentVolumeClaim.claimName);
+
+ const resources = [
+ getResource(NamespaceModel, { prop: 'namespaces' }),
+ getResource(VirtualMachineModel, { namespace, prop: 'virtualMachines' }),
+ ];
+
+ if (requestsPVCs) {
+ resources.push(getResource(PersistentVolumeClaimModel, { namespace, prop: 'persistentVolumeClaims' }));
+ }
+
+ if (requestsDatavolumes) {
+ resources.push(getResource(DataVolumeModel, { namespace, prop: 'dataVolumes' }));
+ }
+
+ return (
+
+ this.setState({ namespace: n })}
+ requestsDatavolumes={requestsDatavolumes}
+ requestsPVCs={requestsPVCs}
+ />
+
+ );
+ }
+}
+
+CloneVMModalFirehose.propTypes = {
+ vm: PropTypes.object.isRequired,
+ Firehose: PropTypes.object.isRequired,
+ LoadingComponent: PropTypes.func,
+ k8sCreate: PropTypes.func.isRequired,
+ k8sPatch: PropTypes.func.isRequired,
+ close: PropTypes.func.isRequired,
+ cancel: PropTypes.func.isRequired,
+};
+
+CloneVMModalFirehose.defaultProps = {
+ LoadingComponent: Loading,
};
diff --git a/src/components/Dialog/CloneDialog/fixtures/CloneDialog.fixture.js b/src/components/Dialog/CloneDialog/fixtures/CloneDialog.fixture.js
index 7ccea4433..b4c37239d 100644
--- a/src/components/Dialog/CloneDialog/fixtures/CloneDialog.fixture.js
+++ b/src/components/Dialog/CloneDialog/fixtures/CloneDialog.fixture.js
@@ -10,13 +10,13 @@ export default {
component: CloneDialog,
props: {
vm: cloudInitTestVm,
- namespaces,
- persistentVolumeClaims: [],
- dataVolumes: [],
+ namespaces: { data: namespaces, loaded: true },
+ persistentVolumeClaims: { data: [], loaded: true },
+ dataVolumes: { data: [], loaded: true },
k8sCreate,
k8sPatch,
units,
onClose: noop,
- virtualMachines: [],
+ virtualMachines: { data: [], loaded: true },
},
};
diff --git a/src/components/Dialog/CloneDialog/index.js b/src/components/Dialog/CloneDialog/index.js
index fd3ae997e..6c86d5230 100644
--- a/src/components/Dialog/CloneDialog/index.js
+++ b/src/components/Dialog/CloneDialog/index.js
@@ -1 +1 @@
-export { CloneDialog } from './CloneDialog';
+export { CloneDialog, CloneVMModalFirehose } from './CloneDialog';
diff --git a/src/components/Dialog/CloneDialog/tests/CloneDialog.test.js b/src/components/Dialog/CloneDialog/tests/CloneDialog.test.js
index 03345a5d3..5229a3e06 100644
--- a/src/components/Dialog/CloneDialog/tests/CloneDialog.test.js
+++ b/src/components/Dialog/CloneDialog/tests/CloneDialog.test.js
@@ -19,7 +19,13 @@ import { flushPromises, setCheckbox, setInput, clickButton, selectDropdownItem }
jest.mock('../../../../k8s/clone');
const testCloneDialog = (vms = [], onClose = noop, vm = cloudInitTestVm) => (
-
+
);
const setVmName = (component, value) => setInput(component.find('#vm-name').find(Text), value);
diff --git a/src/components/Dialog/CloneDialog/tests/__snapshots__/CloneDialog.test.js.snap b/src/components/Dialog/CloneDialog/tests/__snapshots__/CloneDialog.test.js.snap
index 216974d04..571ab3f8c 100644
--- a/src/components/Dialog/CloneDialog/tests/__snapshots__/CloneDialog.test.js.snap
+++ b/src/components/Dialog/CloneDialog/tests/__snapshots__/CloneDialog.test.js.snap
@@ -39,7 +39,6 @@ exports[` renders correctly 1`] = `
bsStyle="default"
className="close"
disabled={false}
- onClick={[Function]}
>
renders correctly 1`] = `
bsStyle="default"
className="btn-cancel"
disabled={false}
- onClick={[Function]}
>
Cancel