diff --git a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.js b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.js index 5d15b307a0..517a1c79d0 100644 --- a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.js +++ b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.js @@ -54,7 +54,6 @@ ctrl.diskFormats = []; ctrl.prepareUpload = prepareUpload; ctrl.apiVersion = 0; - ctrl.allowPublicizeImage = true; $scope.stepModels.imageForm = ctrl.image = { source_type: '', @@ -66,7 +65,7 @@ min_ram: 0, container_format: '', disk_format: '', - visibility: 'public' + visibility: 'shared' }; ctrl.uploadProgress = -1; @@ -84,8 +83,8 @@ ctrl.imageSourceOptions = []; ctrl.imageVisibilityOptions = [ - { label: gettext('Public'), value: 'public'}, - { label: gettext('Private'), value: 'private' } + { label: gettext('Private'), value: 'private' }, + { label: gettext('Shared'), value: 'shared'} ]; ctrl.kernelImages = []; @@ -148,11 +147,14 @@ function init() { glance.getImages({paginate: false}).success(onGetImages); - policyAPI.ifAllowed({rules: [['image', 'publicize_image']]}).then( - angular.noop, + policyAPI.ifAllowed({rules: [['image', 'communitize_image']]}).then( function () { - ctrl.image.visibility = "private"; - ctrl.allowPublicizeImage = false; + ctrl.imageVisibilityOptions.push({ label: gettext('Community'), value: 'community' }); + } + ); + policyAPI.ifAllowed({rules: [['image', 'publicize_image']]}).then( + function () { + ctrl.imageVisibilityOptions.push({ label: gettext('Public'), value: 'public' }); } ); } diff --git a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.spec.js b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.spec.js index d0301d48f3..ffb2c2511f 100644 --- a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.spec.js +++ b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.spec.js @@ -97,7 +97,7 @@ it('should have options for visibility, protected and copying', function() { var ctrl = createController(); - expect(ctrl.imageVisibilityOptions.length).toEqual(2); + expect(ctrl.imageVisibilityOptions.length).toEqual(4); expect(ctrl.imageProtectedOptions.length).toEqual(2); expect(ctrl.imageCopyOptions.length).toEqual(2); }); @@ -124,7 +124,7 @@ expect(ctrl.imageFormats).toBeDefined(); expect(ctrl.validationRules).toBeDefined(); expect(ctrl.diskFormats).toEqual([]); - expect(ctrl.image.visibility).toEqual('public'); + expect(ctrl.image.visibility).toEqual('shared'); expect(ctrl.image.min_disk).toEqual(0); expect(ctrl.image.min_ram).toEqual(0); }); @@ -214,6 +214,16 @@ $timeout.flush(); expect(ctrl.imageSourceOptions).toEqual([fileSourceOption, urlSourceOption]); }); + + it('test image visibility is private if set as default', function() { + var ctrl = createController(); + settingsCall.resolve({ + OPENSTACK_IMAGE_FORMATS: [], + CREATE_IMAGE_DEFAULTS: { image_visibility: 'private' } + }); + $timeout.flush(); + expect(ctrl.image.visibility).toEqual('private'); + }); }); }); diff --git a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.html b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.html index 5ea8afbf3d..4cfe7a60bc 100644 --- a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.html +++ b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.html @@ -221,7 +221,7 @@