Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct ProjectNameTaken error handling in various add-to-projects wizards #2473

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions app/scripts/directives/deployImage.js
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
});
}
});
};

Expand Down
21 changes: 14 additions & 7 deletions app/scripts/directives/fromFile.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down
26 changes: 17 additions & 9 deletions app/scripts/directives/processTemplate.js
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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
});
});
};

Expand Down
31 changes: 19 additions & 12 deletions dist/scripts/scripts.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
});
});
Expand Down Expand Up @@ -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();
};
Expand Down Expand Up @@ -13127,14 +13131,15 @@ 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",
type: "error",
message: "An error occurred creating the project.",
details: t
});
}
});
}, v.cancel = function() {
k(), o.toProjectOverview(v.project.metadata.name);
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}
Expand Down