diff --git a/app/scripts/directives/deployImage.js b/app/scripts/directives/deployImage.js index f375a01aad..c704a2accb 100644 --- a/app/scripts/directives/deployImage.js +++ b/app/scripts/directives/deployImage.js @@ -26,12 +26,16 @@ angular.module("openshiftConsole") // Must be initialized the controller. The link function is too late. $scope.forms = {}; $scope.noProjectsCantCreate = false; - }, - link: function($scope) { + $scope.input = { selectedProject: $scope.project }; + $scope.$watch('input.selectedProject.metadata.name', function() { + $scope.projectNameTaken = false; + }); + }, + link: function($scope) { // Pick from an image stream tag or Docker image name. $scope.mode = "istag"; // "istag" or "dockerImage" @@ -378,13 +382,17 @@ angular.module("openshiftConsole") }; nameTakenPromise.then(setNameTaken, setNameTaken).then(showWarningsOrCreate, showWarningsOrCreate); }, function(e) { - NotificationsService.addNotification({ - id: "deploy-image-create-project-error", - type: "error", - message: "An error occurred creating project", - details: getErrorDetails(e) - }); $scope.disableInputs = false; + if (e.data.reason === 'AlreadyExists') { + $scope.projectNameTaken = true; + } else { + NotificationsService.addNotification({ + id: "deploy-image-create-project-error", + type: "error", + message: "An error occurred creating project.", + details: getErrorDetails(e) + }); + } }); }; diff --git a/app/scripts/directives/fromFile.js b/app/scripts/directives/fromFile.js index e3630c321a..bedd6c1dcd 100644 --- a/app/scripts/directives/fromFile.js +++ b/app/scripts/directives/fromFile.js @@ -37,6 +37,10 @@ angular.module("openshiftConsole") selectedProject: $scope.project }; + $scope.$watch('input.selectedProject.metadata.name', function() { + $scope.projectNameTaken = false; + }); + $scope.aceLoaded = function(editor) { aceEditorSession = editor.getSession(); aceEditorSession.setOption('tabSize', 2); @@ -181,14 +185,17 @@ angular.module("openshiftConsole") } }); }, function(e) { - NotificationsService.addNotification({ - id: "import-create-project-error", - type: "error", - message: "An error occurred creating project", - details: getErrorDetails(e) - }); + if (e.data.reason === 'AlreadyExists') { + $scope.projectNameTaken = true; + } else { + NotificationsService.addNotification({ + id: "import-create-project-error", + type: "error", + message: "An error occurred creating project.", + details: getErrorDetails(e) + }); + } }); - }; $scope.cancel = function() { diff --git a/app/scripts/directives/processTemplate.js b/app/scripts/directives/processTemplate.js index 5f9966f66d..ac2f5340b9 100644 --- a/app/scripts/directives/processTemplate.js +++ b/app/scripts/directives/processTemplate.js @@ -83,6 +83,10 @@ ctrl.templateDisplayName = displayName(ctrl.template); ctrl.selectedProject = ctrl.project; + $scope.$watch('$ctrl.selectedProject.metadata.name', function() { + ctrl.projectNameTaken = false; + }); + $scope.$on('no-projects-cannot-create', function() { ctrl.noProjectsCantCreate = true; }); @@ -245,16 +249,20 @@ ); }, function(result) { ctrl.disableInputs = false; - var details; - if (result.data && result.data.message) { - details = result.data.message; + if (result.data.reason === 'AlreadyExists') { + ctrl.projectNameTaken = true; + } else { + var details; + if (result.data && result.data.message) { + details = result.data.message; + } + NotificationsService.addNotification({ + id: "process-template-error", + type: "error", + message: "An error occurred creating the project.", + details: details + }); } - NotificationsService.addNotification({ - id: "process-template-error", - type: "error", - message: "An error occurred creating the project.", - details: details - }); }); }; diff --git a/dist/scripts/scripts.js b/dist/scripts/scripts.js index 59d28ca3fc..680c13205b 100644 --- a/dist/scripts/scripts.js +++ b/dist/scripts/scripts.js @@ -9656,7 +9656,9 @@ d.clear(), p.$on("no-projects-cannot-create", function() { p.noProjectsCantCreate = !0; }), p.input = { selectedProject: p.project -}, p.aceLoaded = function(e) { +}, p.$watch("input.selectedProject.metadata.name", function() { +p.projectNameTaken = !1; +}), p.aceLoaded = function(e) { (P = e.getSession()).setOption("tabSize", 2), P.setOption("useSoftTabs", !0), e.setDragDelay = 0, e.$blockScrolling = 1 / 0; }; var I = function(e) { @@ -9710,10 +9712,10 @@ namespace: p.input.selectedProject.metadata.name }).then(N) : (p.updateTemplate = 1 === p.updateResources.length && "Template" === p.updateResources[0].kind, p.updateTemplate ? v() : h())); }); }, function(e) { -c.addNotification({ +"AlreadyExists" === e.data.reason ? p.projectNameTaken = !0 : c.addNotification({ id: "import-create-project-error", type: "error", -message: "An error occurred creating project", +message: "An error occurred creating project.", details: R(e) }); }); @@ -13039,7 +13041,9 @@ value: v.template.metadata.name } var g, v = this, h = e("displayName"), y = e("humanize"); v.noProjectsCantCreate = !1, v.$onInit = function() { -v.labels = [], v.template = angular.copy(v.template), v.templateDisplayName = h(v.template), v.selectedProject = v.project, n.$on("no-projects-cannot-create", function() { +v.labels = [], v.template = angular.copy(v.template), v.templateDisplayName = h(v.template), v.selectedProject = v.project, n.$watch("$ctrl.selectedProject.metadata.name", function() { +v.projectNameTaken = !1; +}), n.$on("no-projects-cannot-create", function() { v.noProjectsCantCreate = !0; }), f(); }; @@ -13127,7 +13131,7 @@ details: t }); }); }, function(e) { -v.disableInputs = !1; +if (v.disableInputs = !1, "AlreadyExists" === e.data.reason) v.projectNameTaken = !0; else { var t; e.data && e.data.message && (t = e.data.message), i.addNotification({ id: "process-template-error", @@ -13135,6 +13139,7 @@ type: "error", message: "An error occurred creating the project.", details: t }); +} }); }, v.cancel = function() { k(), o.toProjectOverview(v.project.metadata.name); @@ -13978,7 +13983,11 @@ isDialog: "=" }, templateUrl: "views/directives/deploy-image.html", controller: [ "$scope", function(e) { -e.forms = {}, e.noProjectsCantCreate = !1; +e.forms = {}, e.noProjectsCantCreate = !1, e.input = { +selectedProject: e.project +}, e.$watch("input.selectedProject.metadata.name", function() { +e.projectNameTaken = !1; +}); } ], link: function(n) { function m() { @@ -13994,9 +14003,7 @@ env: p.compactEntries(n.env), labels: e }); } -n.input = { -selectedProject: n.project -}, n.mode = "istag", n.istag = {}, n.app = {}, n.env = [], n.labels = [ { +n.mode = "istag", n.istag = {}, n.app = {}, n.env = [], n.labels = [ { name: "app", value: "" } ], n.$on("no-projects-cannot-create", function() { @@ -14160,12 +14167,12 @@ return n.nameTaken = e.nameTaken, a; }; t.then(o, o).then(E, E); }, function(e) { -c.addNotification({ +n.disableInputs = !1, "AlreadyExists" === e.data.reason ? n.projectNameTaken = !0 : c.addNotification({ id: "deploy-image-create-project-error", type: "error", -message: "An error occurred creating project", +message: "An error occurred creating project.", details: g(e) -}), n.disableInputs = !1; +}); }); }, n.$on("newAppFromDeployImage", n.create), n.$on("$destroy", h); }