Fix incorrect volume type value in ng images create volume form
The value of the 'volume_type' is determined by the 'volumeType' object [1]. The value of the 'volume_type' changes only the 'volumeType' object changes. However, the current value of the 'volume_type' is changed according to the volume object change [2]. It will cause a phenomenon, when the page is initialized, the value of 'volume_type' is empty, when we switch volume types drop-down box, its value is also empty, only change the name, description, size and availability zone, the value of 'volume_type' is the page selection. [1] https://github.com/openstack/horizon/blob/master/openstack_dashboard/static/app/core/images/steps/create-volume/create-volume.html#L45 [2] https://github.com/openstack/horizon/blob/master/openstack_dashboard/static/app/core/images/steps/create-volume/create-volume.controller.js#L140 Change-Id: If754d0c2ced844414c35829d4cefa1fb861522d5 Closes-Bug:#1737900
This commit is contained in:
parent
f8701149a2
commit
3aee4cbac6
|
@ -135,11 +135,11 @@
|
|||
updateStorageGraph
|
||||
);
|
||||
|
||||
var volumeWatcher = $scope.$watch(
|
||||
var volumeTypeWatcher = $scope.$watch(
|
||||
function() {
|
||||
return ctrl.volume;
|
||||
return ctrl.volumeType;
|
||||
},
|
||||
volumeChangeEvent,
|
||||
updateVolumeType,
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -222,13 +222,13 @@
|
|||
return image.name + ' (' + $filter('bytes')(image.size) + ')';
|
||||
}
|
||||
|
||||
function volumeChangeEvent() {
|
||||
function updateVolumeType() {
|
||||
ctrl.volume.volume_type = ctrl.volumeType.name || '';
|
||||
}
|
||||
|
||||
function deregisterWatchers() {
|
||||
capacityWatcher();
|
||||
volumeWatcher();
|
||||
volumeTypeWatcher();
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -272,16 +272,12 @@
|
|||
expect(graph.maxLimit).toEqual(graph.maxLimit);
|
||||
});
|
||||
|
||||
it('should update volume type from volume name', function() {
|
||||
it('should update volume type when ctrl.volumeType changes', function() {
|
||||
var ctrl = createController();
|
||||
|
||||
ctrl.volumeType = {name: 'spam'};
|
||||
$scope.$apply();
|
||||
|
||||
ctrl.volume.volume_type = 'spam';
|
||||
ctrl.volume.name = 'nova2';
|
||||
$scope.$apply();
|
||||
|
||||
expect(ctrl.volume.volume_type).toEqual('lvmdriver-1');
|
||||
expect(ctrl.volume.volume_type).toEqual('spam');
|
||||
});
|
||||
|
||||
it('should set the validity of the volume size input field based on the limit', function() {
|
||||
|
@ -342,13 +338,13 @@
|
|||
expect(graph.overMax).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should deregister the volume watcher when the destroy event is thrown', function() {
|
||||
it('should deregister the volume type watcher when the destroy event is thrown', function() {
|
||||
var ctrl = createController();
|
||||
|
||||
$scope.$emit('$destroy');
|
||||
$scope.$emit.calls.reset();
|
||||
|
||||
ctrl.volume.size = 100;
|
||||
ctrl.volumeType = {name: 'spam'};
|
||||
$scope.$apply();
|
||||
|
||||
expect($scope.$emit).not.toHaveBeenCalled();
|
||||
|
|
Loading…
Reference in New Issue