Skip to content

Commit ed926a7

Browse files
Merge pull request #2473 from dtaylor113/projectNameTaken
Automatic merge from submit-queue. Correct ProjectNameTaken error handling in various add-to-projects wizards Updated deployImage, processTemplate, and fromFile wizards. Fixes #1955 ![image](https://user-images.githubusercontent.com/12733153/32521149-6e627f7c-c3e0-11e7-81d2-e00d5137c5eb.png)
2 parents 501c413 + 6494391 commit ed926a7

File tree

4 files changed

+66
-36
lines changed

4 files changed

+66
-36
lines changed

app/scripts/directives/deployImage.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ angular.module("openshiftConsole")
2626
// Must be initialized the controller. The link function is too late.
2727
$scope.forms = {};
2828
$scope.noProjectsCantCreate = false;
29-
},
30-
link: function($scope) {
29+
3130
$scope.input = {
3231
selectedProject: $scope.project
3332
};
3433

34+
$scope.$watch('input.selectedProject.metadata.name', function() {
35+
$scope.projectNameTaken = false;
36+
});
37+
},
38+
link: function($scope) {
3539
// Pick from an image stream tag or Docker image name.
3640
$scope.mode = "istag"; // "istag" or "dockerImage"
3741

@@ -378,13 +382,17 @@ angular.module("openshiftConsole")
378382
};
379383
nameTakenPromise.then(setNameTaken, setNameTaken).then(showWarningsOrCreate, showWarningsOrCreate);
380384
}, function(e) {
381-
NotificationsService.addNotification({
382-
id: "deploy-image-create-project-error",
383-
type: "error",
384-
message: "An error occurred creating project",
385-
details: getErrorDetails(e)
386-
});
387385
$scope.disableInputs = false;
386+
if (e.data.reason === 'AlreadyExists') {
387+
$scope.projectNameTaken = true;
388+
} else {
389+
NotificationsService.addNotification({
390+
id: "deploy-image-create-project-error",
391+
type: "error",
392+
message: "An error occurred creating project.",
393+
details: getErrorDetails(e)
394+
});
395+
}
388396
});
389397
};
390398

app/scripts/directives/fromFile.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ angular.module("openshiftConsole")
3737
selectedProject: $scope.project
3838
};
3939

40+
$scope.$watch('input.selectedProject.metadata.name', function() {
41+
$scope.projectNameTaken = false;
42+
});
43+
4044
$scope.aceLoaded = function(editor) {
4145
aceEditorSession = editor.getSession();
4246
aceEditorSession.setOption('tabSize', 2);
@@ -181,14 +185,17 @@ angular.module("openshiftConsole")
181185
}
182186
});
183187
}, function(e) {
184-
NotificationsService.addNotification({
185-
id: "import-create-project-error",
186-
type: "error",
187-
message: "An error occurred creating project",
188-
details: getErrorDetails(e)
189-
});
188+
if (e.data.reason === 'AlreadyExists') {
189+
$scope.projectNameTaken = true;
190+
} else {
191+
NotificationsService.addNotification({
192+
id: "import-create-project-error",
193+
type: "error",
194+
message: "An error occurred creating project.",
195+
details: getErrorDetails(e)
196+
});
197+
}
190198
});
191-
192199
};
193200

194201
$scope.cancel = function() {

app/scripts/directives/processTemplate.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
ctrl.templateDisplayName = displayName(ctrl.template);
8484
ctrl.selectedProject = ctrl.project;
8585

86+
$scope.$watch('$ctrl.selectedProject.metadata.name', function() {
87+
ctrl.projectNameTaken = false;
88+
});
89+
8690
$scope.$on('no-projects-cannot-create', function() {
8791
ctrl.noProjectsCantCreate = true;
8892
});
@@ -245,16 +249,20 @@
245249
);
246250
}, function(result) {
247251
ctrl.disableInputs = false;
248-
var details;
249-
if (result.data && result.data.message) {
250-
details = result.data.message;
252+
if (result.data.reason === 'AlreadyExists') {
253+
ctrl.projectNameTaken = true;
254+
} else {
255+
var details;
256+
if (result.data && result.data.message) {
257+
details = result.data.message;
258+
}
259+
NotificationsService.addNotification({
260+
id: "process-template-error",
261+
type: "error",
262+
message: "An error occurred creating the project.",
263+
details: details
264+
});
251265
}
252-
NotificationsService.addNotification({
253-
id: "process-template-error",
254-
type: "error",
255-
message: "An error occurred creating the project.",
256-
details: details
257-
});
258266
});
259267
};
260268

dist/scripts/scripts.js

+19-12
Original file line numberDiff line numberDiff line change
@@ -9656,7 +9656,9 @@ d.clear(), p.$on("no-projects-cannot-create", function() {
96569656
p.noProjectsCantCreate = !0;
96579657
}), p.input = {
96589658
selectedProject: p.project
9659-
}, p.aceLoaded = function(e) {
9659+
}, p.$watch("input.selectedProject.metadata.name", function() {
9660+
p.projectNameTaken = !1;
9661+
}), p.aceLoaded = function(e) {
96609662
(P = e.getSession()).setOption("tabSize", 2), P.setOption("useSoftTabs", !0), e.setDragDelay = 0, e.$blockScrolling = 1 / 0;
96619663
};
96629664
var I = function(e) {
@@ -9710,10 +9712,10 @@ namespace: p.input.selectedProject.metadata.name
97109712
}).then(N) : (p.updateTemplate = 1 === p.updateResources.length && "Template" === p.updateResources[0].kind, p.updateTemplate ? v() : h()));
97119713
});
97129714
}, function(e) {
9713-
c.addNotification({
9715+
"AlreadyExists" === e.data.reason ? p.projectNameTaken = !0 : c.addNotification({
97149716
id: "import-create-project-error",
97159717
type: "error",
9716-
message: "An error occurred creating project",
9718+
message: "An error occurred creating project.",
97179719
details: R(e)
97189720
});
97199721
});
@@ -13039,7 +13041,9 @@ value: v.template.metadata.name
1303913041
}
1304013042
var g, v = this, h = e("displayName"), y = e("humanize");
1304113043
v.noProjectsCantCreate = !1, v.$onInit = function() {
13042-
v.labels = [], v.template = angular.copy(v.template), v.templateDisplayName = h(v.template), v.selectedProject = v.project, n.$on("no-projects-cannot-create", function() {
13044+
v.labels = [], v.template = angular.copy(v.template), v.templateDisplayName = h(v.template), v.selectedProject = v.project, n.$watch("$ctrl.selectedProject.metadata.name", function() {
13045+
v.projectNameTaken = !1;
13046+
}), n.$on("no-projects-cannot-create", function() {
1304313047
v.noProjectsCantCreate = !0;
1304413048
}), f();
1304513049
};
@@ -13127,14 +13131,15 @@ details: t
1312713131
});
1312813132
});
1312913133
}, function(e) {
13130-
v.disableInputs = !1;
13134+
if (v.disableInputs = !1, "AlreadyExists" === e.data.reason) v.projectNameTaken = !0; else {
1313113135
var t;
1313213136
e.data && e.data.message && (t = e.data.message), i.addNotification({
1313313137
id: "process-template-error",
1313413138
type: "error",
1313513139
message: "An error occurred creating the project.",
1313613140
details: t
1313713141
});
13142+
}
1313813143
});
1313913144
}, v.cancel = function() {
1314013145
k(), o.toProjectOverview(v.project.metadata.name);
@@ -13978,7 +13983,11 @@ isDialog: "="
1397813983
},
1397913984
templateUrl: "views/directives/deploy-image.html",
1398013985
controller: [ "$scope", function(e) {
13981-
e.forms = {}, e.noProjectsCantCreate = !1;
13986+
e.forms = {}, e.noProjectsCantCreate = !1, e.input = {
13987+
selectedProject: e.project
13988+
}, e.$watch("input.selectedProject.metadata.name", function() {
13989+
e.projectNameTaken = !1;
13990+
});
1398213991
} ],
1398313992
link: function(n) {
1398413993
function m() {
@@ -13994,9 +14003,7 @@ env: p.compactEntries(n.env),
1399414003
labels: e
1399514004
});
1399614005
}
13997-
n.input = {
13998-
selectedProject: n.project
13999-
}, n.mode = "istag", n.istag = {}, n.app = {}, n.env = [], n.labels = [ {
14006+
n.mode = "istag", n.istag = {}, n.app = {}, n.env = [], n.labels = [ {
1400014007
name: "app",
1400114008
value: ""
1400214009
} ], n.$on("no-projects-cannot-create", function() {
@@ -14160,12 +14167,12 @@ return n.nameTaken = e.nameTaken, a;
1416014167
};
1416114168
t.then(o, o).then(E, E);
1416214169
}, function(e) {
14163-
c.addNotification({
14170+
n.disableInputs = !1, "AlreadyExists" === e.data.reason ? n.projectNameTaken = !0 : c.addNotification({
1416414171
id: "deploy-image-create-project-error",
1416514172
type: "error",
14166-
message: "An error occurred creating project",
14173+
message: "An error occurred creating project.",
1416714174
details: g(e)
14168-
}), n.disableInputs = !1;
14175+
});
1416914176
});
1417014177
}, n.$on("newAppFromDeployImage", n.create), n.$on("$destroy", h);
1417114178
}

0 commit comments

Comments
 (0)