From 13167f3750b4fed8af26c75321d037a0ee22e196 Mon Sep 17 00:00:00 2001 From: manchandavishal Date: Tue, 28 Jun 2022 23:47:18 +0530 Subject: [PATCH] Migrate to AngularJS v1.8.2 This patch aligns current code with AngularJS v1.8.2 requirements. It also updates zun-ui to use the Firefox browser instead of phantomjs browser to fix "nodjs-run-test" job because phantomjs browser has some issue with backticks. Change-Id: Ibf995d6c29f64cd902834b64664cd87ef5014a45 --- package.json | 6 ++---- zun_ui/karma.conf.js | 10 ++-------- .../container/capsules/actions/delete.service.js | 4 ++-- .../containers/actions/delete-force.service.js | 4 ++-- .../containers/actions/delete-stop.service.js | 4 ++-- .../container/containers/actions/delete.service.js | 4 ++-- .../container/images/actions/delete.service.js | 4 ++-- zun_ui/static/dashboard/container/zun.service.js | 12 ++++++------ 8 files changed, 20 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index b0888ce..75cfbac 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,12 @@ "eslint-plugin-angular": "3.1.x", "jasmine-core": "2.8.x", "karma": "1.7.x", - "karma-chrome-launcher": "^2.2.0", + "karma-firefox-launcher": "2.1.0", "karma-cli": "1.0.x", "karma-coverage": "1.1.x", "karma-jasmine": "1.1.x", "karma-ng-html2js-preprocessor": "1.0.x", - "karma-phantomjs-launcher": "1.0.x", - "karma-threshold-reporter": "0.1.x", - "phantomjs-prebuilt": "2.1.x" + "karma-threshold-reporter": "0.1.x" }, "scripts": { "postinstall": "if [ ! -d .tox ] || [ ! -d .tox/karma ]; then tox -ekarma --notest; fi", diff --git a/zun_ui/karma.conf.js b/zun_ui/karma.conf.js index 725d494..d49c278 100644 --- a/zun_ui/karma.conf.js +++ b/zun_ui/karma.conf.js @@ -125,20 +125,14 @@ module.exports = function (config) { frameworks: ['jasmine'], - browsers: ['PhantomJS'], + browsers: ['Firefox'], browserNoActivityTimeout: 60000, - phantomjsLauncher: { - // Have phantomjs exit if a ResourceError is encountered - // (useful if karma exits without killing phantom) - exitOnResourceError: true - }, - reporters: ['progress', 'coverage', 'threshold'], plugins: [ - 'karma-phantomjs-launcher', + 'karma-firefox-launcher', 'karma-jasmine', 'karma-ng-html2js-preprocessor', 'karma-coverage', diff --git a/zun_ui/static/dashboard/container/capsules/actions/delete.service.js b/zun_ui/static/dashboard/container/capsules/actions/delete.service.js index eb8f105..ee61533 100644 --- a/zun_ui/static/dashboard/container/capsules/actions/delete.service.js +++ b/zun_ui/static/dashboard/container/capsules/actions/delete.service.js @@ -105,10 +105,10 @@ // for batch delete function afterCheck(result) { - var outcome = $q.reject(); // Reject the promise by default + var outcome = $q.reject().catch(angular.noop); // Reject the promise by default if (result.fail.length > 0) { toast.add('error', getMessage(notAllowedMessage, result.fail)); - outcome = $q.reject(result.fail); + outcome = $q.reject(result.fail).catch(angular.noop); } if (result.pass.length > 0) { outcome = deleteModal.open(scope, result.pass.map(getEntity), context).then(createResult); diff --git a/zun_ui/static/dashboard/container/containers/actions/delete-force.service.js b/zun_ui/static/dashboard/container/containers/actions/delete-force.service.js index 3139ad4..c662a3a 100644 --- a/zun_ui/static/dashboard/container/containers/actions/delete-force.service.js +++ b/zun_ui/static/dashboard/container/containers/actions/delete-force.service.js @@ -112,10 +112,10 @@ // for batch delete function afterCheck(result) { - var outcome = $q.reject(); // Reject the promise by default + var outcome = $q.reject().catch(angular.noop); // Reject the promise by default if (result.fail.length > 0) { toast.add('error', getMessage(notAllowedMessage, result.fail)); - outcome = $q.reject(result.fail); + outcome = $q.reject(result.fail).catch(angular.noop); } if (result.pass.length > 0) { outcome = deleteModal.open(scope, result.pass.map(getEntity), context).then(createResult); diff --git a/zun_ui/static/dashboard/container/containers/actions/delete-stop.service.js b/zun_ui/static/dashboard/container/containers/actions/delete-stop.service.js index c2abeae..74b06fa 100644 --- a/zun_ui/static/dashboard/container/containers/actions/delete-stop.service.js +++ b/zun_ui/static/dashboard/container/containers/actions/delete-stop.service.js @@ -112,10 +112,10 @@ // for batch delete function afterCheck(result) { - var outcome = $q.reject(); // Reject the promise by default + var outcome = $q.reject().catch(angular.noop); // Reject the promise by default if (result.fail.length > 0) { toast.add('error', getMessage(notAllowedMessage, result.fail)); - outcome = $q.reject(result.fail); + outcome = $q.reject(result.fail).catch(angular.noop); } if (result.pass.length > 0) { outcome = deleteModal.open(scope, result.pass.map(getEntity), context).then(createResult); diff --git a/zun_ui/static/dashboard/container/containers/actions/delete.service.js b/zun_ui/static/dashboard/container/containers/actions/delete.service.js index 19549af..8e91922 100644 --- a/zun_ui/static/dashboard/container/containers/actions/delete.service.js +++ b/zun_ui/static/dashboard/container/containers/actions/delete.service.js @@ -122,10 +122,10 @@ // for batch delete function afterCheck(result) { - var outcome = $q.reject(); // Reject the promise by default + var outcome = $q.reject().catch(angular.noop); // Reject the promise by default if (result.fail.length > 0) { toast.add('error', getMessage(notAllowedMessage, result.fail)); - outcome = $q.reject(result.fail); + outcome = $q.reject(result.fail).catch(angular.noop); } if (result.pass.length > 0) { outcome = deleteModal.open(scope, result.pass.map(getEntity), context).then(createResult); diff --git a/zun_ui/static/dashboard/container/images/actions/delete.service.js b/zun_ui/static/dashboard/container/images/actions/delete.service.js index 7dee270..6dc807d 100644 --- a/zun_ui/static/dashboard/container/images/actions/delete.service.js +++ b/zun_ui/static/dashboard/container/images/actions/delete.service.js @@ -103,10 +103,10 @@ // for batch delete function afterCheck(result) { - var outcome = $q.reject(); // Reject the promise by default + var outcome = $q.reject().catch(angular.noop); // Reject the promise by default if (result.fail.length > 0) { toast.add('error', getMessage(notAllowedMessage, result.fail)); - outcome = $q.reject(result.fail); + outcome = $q.reject(result.fail).catch(angular.noop); } if (result.pass.length > 0) { outcome = deleteModal.open(scope, result.pass.map(getEntity), context).then(createResult); diff --git a/zun_ui/static/dashboard/container/zun.service.js b/zun_ui/static/dashboard/container/zun.service.js index 624da50..f062b83 100644 --- a/zun_ui/static/dashboard/container/zun.service.js +++ b/zun_ui/static/dashboard/container/zun.service.js @@ -83,7 +83,7 @@ function getContainer(id, suppressError) { var promise = apiService.get(containersPath + id); - return suppressError ? promise : promise.error(function() { + return suppressError ? promise : promise.catch(function onError() { var msg = gettext('Unable to retrieve the Container.'); toastService.add('error', msg); }); @@ -96,7 +96,7 @@ function deleteContainer(id, suppressError) { var promise = apiService.delete(containersPath, [id]); - return suppressError ? promise : promise.error(function() { + return suppressError ? promise : promise.catch(function onError() { var msg = gettext('Unable to delete the Container with id: %(id)s'); toastService.add('error', interpolate(msg, { id: id }, true)); }); @@ -110,7 +110,7 @@ function deleteContainerForce(id, suppressError) { var promise = apiService.delete(containersPath + id + '/force', [id]); - return suppressError ? promise : promise.error(function() { + return suppressError ? promise : promise.catch(function onError() { var msg = gettext('Unable to delete forcely the Container with id: %(id)s'); toastService.add('error', interpolate(msg, { id: id }, true)); }); @@ -118,7 +118,7 @@ function deleteContainerStop(id, suppressError) { var promise = apiService.delete(containersPath + id + '/stop', [id]); - return suppressError ? promise : promise.error(function() { + return suppressError ? promise : promise.catch(function onError() { var msg = gettext('Unable to stop and delete the Container with id: %(id)s'); toastService.add('error', interpolate(msg, { id: id }, true)); }); @@ -225,7 +225,7 @@ function deleteCapsule(id, suppressError) { var promise = apiService.delete(capsulesPath, [id]); - return suppressError ? promise : promise.error(function() { + return suppressError ? promise : promise.catch(function onError() { var msg = gettext('Unable to delete the Capsule with id: %(id)s'); toastService.add('error', interpolate(msg, { id: id }, true)); }); @@ -247,7 +247,7 @@ function deleteImage(id, suppressError) { var promise = apiService.delete(imagesPath, [id]); - return suppressError ? promise : promise.error(function() { + return suppressError ? promise : promise.catch(function onError() { var msg = gettext('Unable to delete the Image with id: %(id)s'); toastService.add('error', interpolate(msg, { id: id }, true)); });