This repository was archived by the owner on Mar 1, 2024. It is now read-only.
forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 11
Disable restart action in VM import status #237
Merged
mareklibra
merged 1 commit into
kubevirt:master
from
pcbailey:disable-actions-on-vm-import
Apr 2, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ import { | |
CloneDialog, | ||
getResource, | ||
findVMIMigration, | ||
getVmImporterPods, | ||
getVmStatus, | ||
VM_STATUS_IMPORTING, | ||
} from 'kubevirt-web-ui-components'; | ||
|
||
import { Kebab, LoadingInline } from '../utils/okdutils'; | ||
|
@@ -18,6 +21,7 @@ import { | |
PersistentVolumeClaimModel, | ||
VirtualMachineModel, | ||
DataVolumeModel, | ||
PodModel, | ||
} from '../../models/index'; | ||
import { startStopVmModal } from '../modals/start-stop-vm-modal'; | ||
import { restartVmModal } from '../modals/restart-vm-modal'; | ||
|
@@ -28,51 +32,75 @@ import { | |
import { modalResourceLauncher } from '../utils/modalResourceLauncher'; | ||
import { showError } from '../utils/showErrors'; | ||
|
||
const getStatusForVm = (vm, actionArgs) => { | ||
if (!actionArgs) { | ||
return null; | ||
} | ||
|
||
const pods = actionArgs[PodModel.kind]; | ||
const importerPods= getVmImporterPods(actionArgs[PodModel.kind], vm); | ||
const migrations = actionArgs[VirtualMachineInstanceMigrationModel.kind]; | ||
return getVmStatus(vm, pods, migrations, importerPods); | ||
}; | ||
|
||
const isImporting = (vm, actionArgs) => { | ||
const status = getStatusForVm(vm, actionArgs); | ||
return status ? status.status === VM_STATUS_IMPORTING : false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shorthand? |
||
}; | ||
|
||
const getStartStopActionLabel = (vm) => { | ||
return _.get(vm, 'spec.running', false) ? 'Stop Virtual Machine' : 'Start Virtual Machine'; | ||
}; | ||
|
||
const menuActionStart = (kind, vm) => ({ | ||
label: getStartStopActionLabel(vm), | ||
callback: () => startStopVmModal({ | ||
kind, | ||
resource: vm, | ||
start: !_.get(vm, 'spec.running', false), | ||
}), | ||
}); | ||
const menuActionStart = (kind, vm, actionArgs) => { | ||
return { | ||
hidden: isImporting(vm, actionArgs), | ||
label: getStartStopActionLabel(vm), | ||
callback: () => startStopVmModal({ | ||
kind, | ||
resource: vm, | ||
start: !_.get(vm, 'spec.running', false), | ||
}), | ||
}; | ||
}; | ||
|
||
const menuActionRestart = (kind, vm) => ({ | ||
hidden: !_.get(vm, 'spec.running', false), | ||
label: 'Restart Virtual Machine', | ||
callback: () => restartVmModal({ | ||
kind, | ||
resource: vm, | ||
}), | ||
}); | ||
const menuActionRestart = (kind, vm, actionArgs) => { | ||
return { | ||
hidden: !isVmRunning(vm) || isImporting(vm, actionArgs), | ||
label: 'Restart Virtual Machine', | ||
callback: () => restartVmModal({ | ||
kind, | ||
resource: vm, | ||
}), | ||
}; | ||
}; | ||
|
||
const menuActionClone = (kind, vm) => ({ | ||
label: 'Clone Virtual Machine', | ||
callback: () => { | ||
return modalResourceLauncher(CloneDialog, { | ||
namespaces: { | ||
resource: getResource(NamespaceModel), | ||
required: true, | ||
}, | ||
persistentVolumeClaims: { | ||
resource: getResource(PersistentVolumeClaimModel), | ||
required: true, | ||
}, | ||
virtualMachines: { | ||
resource: getResource(VirtualMachineModel), | ||
required: true, | ||
}, | ||
dataVolumes: { | ||
resource: getResource(DataVolumeModel), | ||
required: true, | ||
}, | ||
})({ vm, k8sCreate, k8sPatch, LoadingComponent: LoadingInline }); | ||
}, | ||
}); | ||
const menuActionClone = (kind, vm, actionArgs) => { | ||
return { | ||
hidden: isImporting(vm, actionArgs), | ||
label: 'Clone Virtual Machine', | ||
callback: () => { | ||
return modalResourceLauncher(CloneDialog, { | ||
namespaces: { | ||
resource: getResource(NamespaceModel), | ||
required: true, | ||
}, | ||
persistentVolumeClaims: { | ||
resource: getResource(PersistentVolumeClaimModel), | ||
required: true, | ||
}, | ||
virtualMachines: { | ||
resource: getResource(VirtualMachineModel), | ||
required: true, | ||
}, | ||
dataVolumes: { | ||
resource: getResource(DataVolumeModel), | ||
required: true, | ||
}, | ||
})({vm, k8sCreate, k8sPatch, LoadingComponent: LoadingInline}); | ||
}, | ||
}; | ||
}; | ||
|
||
const menuActionCancelMigration = (kind, vm, actionArgs) => { | ||
const migration = actionArgs && findVMIMigration(actionArgs[VirtualMachineInstanceMigrationModel.kind], actionArgs[VirtualMachineInstanceModel.kind]); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ const VMRow = ({obj: vm}) => { | |
resources={[ | ||
getResource(VirtualMachineInstanceModel, {name, namespace, isList: false}), | ||
migrationResources, | ||
getResource(PodModel, {namespace, matchLabels: {[CDI_KUBEVIRT_IO]: 'importer'}}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better to select just pods without the importer labels. Because it might be confusing when somebody gets to use |
||
]} /> | ||
</div> | ||
</ResourceRow>; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not have to supply importerPods anymore if you supply all pods. Please see
getVmStatus