From d8802fef6dae166945e8cbdfb947e75358ca34e4 Mon Sep 17 00:00:00 2001 From: Tatiana Ovchinnikova Date: Thu, 16 Jun 2022 12:42:05 -0500 Subject: [PATCH] Fix Create Container issues This patch fixes container name check and Create Container action. Change-Id: Idfb90a327e94ccaa3263aaaad1d6d52fa46312f4 --- .../project/containers/containers-model.service.js | 2 +- .../project/containers/containers-model.service.spec.js | 2 +- .../dashboard/project/containers/containers.controller.js | 6 +++--- .../static/app/core/openstack-service-api/swift.service.js | 2 +- .../app/core/openstack-service-api/swift.service.spec.js | 1 - 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.js b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.js index 2ace67ed35..d239c01a69 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.js @@ -92,7 +92,7 @@ push.apply(model.containers, data.data.items); }), swiftAPI.getInfo().then(function onInfo(data) { - model.swift_info = data.info; + model.swift_info = data.data.info; }) ]).then(function resolve() { model.intialiseDeferred.resolve(); diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js index b67cb5be65..4b8ec824d0 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js @@ -46,7 +46,7 @@ expect(swiftAPI.getInfo).toHaveBeenCalled(); expect(swiftAPI.getContainers).toHaveBeenCalled(); - infoDeferred.resolve({info: 'spam'}); + infoDeferred.resolve({data: {info: 'spam'}}); containersDeferred.resolve({data: {items: ['two', 'items']}}); $rootScope.$apply(); diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers.controller.js b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers.controller.js index 9c6a606152..eed4e39355 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers.controller.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers.controller.js @@ -97,11 +97,11 @@ return $q.when(); } - var def = $q.defer(); // reverse the sense here - successful lookup == error so we reject the // name if we find it in swift - swiftAPI.getContainer(containerName, true).then(def.reject, def.resolve); - return def.promise; + return swiftAPI.getContainer(containerName, true).then(function onSuccess(response) { + return $q.reject(response); + }, function onError() { return true; }); } function selectContainer(container) { diff --git a/openstack_dashboard/static/app/core/openstack-service-api/swift.service.js b/openstack_dashboard/static/app/core/openstack-service-api/swift.service.js index 6480f33823..b2b170efec 100644 --- a/openstack_dashboard/static/app/core/openstack-service-api/swift.service.js +++ b/openstack_dashboard/static/app/core/openstack-service-api/swift.service.js @@ -137,7 +137,7 @@ function getContainer(container, ignoreError) { var promise = apiService.get(service.getContainerURL(container) + '/metadata/'); if (ignoreError) { - return promise.catch(angular.noop); + return promise; } return promise.catch(function onError() { toastService.add('error', gettext('Unable to get the container details.')); diff --git a/openstack_dashboard/static/app/core/openstack-service-api/swift.service.spec.js b/openstack_dashboard/static/app/core/openstack-service-api/swift.service.spec.js index c1d317c54b..40ec0002da 100644 --- a/openstack_dashboard/static/app/core/openstack-service-api/swift.service.spec.js +++ b/openstack_dashboard/static/app/core/openstack-service-api/swift.service.spec.js @@ -247,7 +247,6 @@ spyOn(promise, 'catch'); spyOn(toastService, 'add'); service.getContainer('spam', true); - expect(promise.catch).toHaveBeenCalledWith(angular.noop); expect(toastService.add).not.toHaveBeenCalled(); });