Commit 65721be3 by Samuel Padgett

Don't show both a toast and in-page alert for create project

parent 71d92355
...@@ -534,7 +534,6 @@ angular.module("openshiftCommonUI") ...@@ -534,7 +534,6 @@ angular.module("openshiftCommonUI")
return { return {
restrict: 'E', restrict: 'E',
scope: { scope: {
alerts: '=',
redirectAction: '&', redirectAction: '&',
onCancel: '&?', onCancel: '&?',
isDialog: '@' isDialog: '@'
...@@ -547,9 +546,8 @@ angular.module("openshiftCommonUI") ...@@ -547,9 +546,8 @@ angular.module("openshiftCommonUI")
$scope.isDialog = $scope.isDialog === 'true'; $scope.isDialog = $scope.isDialog === 'true';
var showAlert = function(name, alert) { var hideErrorNotifications = function() {
$scope.alerts[name] = alert; NotificationsService.hideNotification('create-project-error');
NotificationsService.addNotification(alert);
}; };
$scope.createProject = function() { $scope.createProject = function() {
...@@ -573,7 +571,7 @@ angular.module("openshiftCommonUI") ...@@ -573,7 +571,7 @@ angular.module("openshiftCommonUI")
} else { } else {
$location.path("project/" + encodeURIComponent(data.metadata.name) + "/create"); $location.path("project/" + encodeURIComponent(data.metadata.name) + "/create");
} }
showAlert('created-project', { NotificationsService.addNotification({
type: "success", type: "success",
message: "Project \'" + displayNameFilter(data) + "\' was successfully created." message: "Project \'" + displayNameFilter(data) + "\' was successfully created."
}); });
...@@ -584,7 +582,11 @@ angular.module("openshiftCommonUI") ...@@ -584,7 +582,11 @@ angular.module("openshiftCommonUI")
$scope.nameTaken = true; $scope.nameTaken = true;
} else { } else {
var msg = data.message || 'An error occurred creating the project.'; var msg = data.message || 'An error occurred creating the project.';
showAlert('error-creating-project', {type: 'error', message: msg}); NotificationsService.addNotification({
id: 'create-project-error',
type: 'error',
message: msg
});
} }
}); });
} }
...@@ -600,6 +602,8 @@ angular.module("openshiftCommonUI") ...@@ -600,6 +602,8 @@ angular.module("openshiftCommonUI")
$window.history.back(); $window.history.back();
} }
}; };
$scope.$on("$destroy", hideErrorNotifications);
}, },
}; };
}); });
......
...@@ -705,7 +705,6 @@ angular.module("openshiftCommonUI") ...@@ -705,7 +705,6 @@ angular.module("openshiftCommonUI")
return { return {
restrict: 'E', restrict: 'E',
scope: { scope: {
alerts: '=',
redirectAction: '&', redirectAction: '&',
onCancel: '&?', onCancel: '&?',
isDialog: '@' isDialog: '@'
...@@ -718,9 +717,8 @@ angular.module("openshiftCommonUI") ...@@ -718,9 +717,8 @@ angular.module("openshiftCommonUI")
$scope.isDialog = $scope.isDialog === 'true'; $scope.isDialog = $scope.isDialog === 'true';
var showAlert = function(name, alert) { var hideErrorNotifications = function() {
$scope.alerts[name] = alert; NotificationsService.hideNotification('create-project-error');
NotificationsService.addNotification(alert);
}; };
$scope.createProject = function() { $scope.createProject = function() {
...@@ -744,7 +742,7 @@ angular.module("openshiftCommonUI") ...@@ -744,7 +742,7 @@ angular.module("openshiftCommonUI")
} else { } else {
$location.path("project/" + encodeURIComponent(data.metadata.name) + "/create"); $location.path("project/" + encodeURIComponent(data.metadata.name) + "/create");
} }
showAlert('created-project', { NotificationsService.addNotification({
type: "success", type: "success",
message: "Project \'" + displayNameFilter(data) + "\' was successfully created." message: "Project \'" + displayNameFilter(data) + "\' was successfully created."
}); });
...@@ -755,7 +753,11 @@ angular.module("openshiftCommonUI") ...@@ -755,7 +753,11 @@ angular.module("openshiftCommonUI")
$scope.nameTaken = true; $scope.nameTaken = true;
} else { } else {
var msg = data.message || 'An error occurred creating the project.'; var msg = data.message || 'An error occurred creating the project.';
showAlert('error-creating-project', {type: 'error', message: msg}); NotificationsService.addNotification({
id: 'create-project-error',
type: 'error',
message: msg
});
} }
}); });
} }
...@@ -771,6 +773,8 @@ angular.module("openshiftCommonUI") ...@@ -771,6 +773,8 @@ angular.module("openshiftCommonUI")
$window.history.back(); $window.history.back();
} }
}; };
$scope.$on("$destroy", hideErrorNotifications);
}], }],
}; };
}]); }]);
......
...@@ -157,7 +157,6 @@ return humanizeKind(object.kind); ...@@ -157,7 +157,6 @@ return humanizeKind(object.kind);
return { return {
restrict:"E", restrict:"E",
scope:{ scope:{
alerts:"=",
redirectAction:"&", redirectAction:"&",
onCancel:"&?", onCancel:"&?",
isDialog:"@" isDialog:"@"
...@@ -165,8 +164,8 @@ isDialog:"@" ...@@ -165,8 +164,8 @@ isDialog:"@"
templateUrl:"src/components/create-project/createProject.html", templateUrl:"src/components/create-project/createProject.html",
controller:[ "$scope", "$filter", "$location", "DataService", "NotificationsService", "displayNameFilter", function($scope, $filter, $location, DataService, NotificationsService, displayNameFilter) { controller:[ "$scope", "$filter", "$location", "DataService", "NotificationsService", "displayNameFilter", function($scope, $filter, $location, DataService, NotificationsService, displayNameFilter) {
$scope.submitButtonLabel || ($scope.submitButtonLabel = "Create"), $scope.isDialog = "true" === $scope.isDialog; $scope.submitButtonLabel || ($scope.submitButtonLabel = "Create"), $scope.isDialog = "true" === $scope.isDialog;
var showAlert = function(name, alert) { var hideErrorNotifications = function() {
$scope.alerts[name] = alert, NotificationsService.addNotification(alert); NotificationsService.hideNotification("create-project-error");
}; };
$scope.createProject = function() { $scope.createProject = function() {
$scope.disableInputs = !0, $scope.createProjectForm.$valid && DataService.create("projectrequests", null, { $scope.disableInputs = !0, $scope.createProjectForm.$valid && DataService.create("projectrequests", null, {
...@@ -179,7 +178,7 @@ displayName:$scope.displayName, ...@@ -179,7 +178,7 @@ displayName:$scope.displayName,
description:$scope.description description:$scope.description
}, $scope).then(function(data) { }, $scope).then(function(data) {
var cb = $scope.redirectAction(); var cb = $scope.redirectAction();
cb ? cb(encodeURIComponent(data.metadata.name)) :$location.path("project/" + encodeURIComponent(data.metadata.name) + "/create"), showAlert("created-project", { cb ? cb(encodeURIComponent(data.metadata.name)) :$location.path("project/" + encodeURIComponent(data.metadata.name) + "/create"), NotificationsService.addNotification({
type:"success", type:"success",
message:"Project '" + displayNameFilter(data) + "' was successfully created." message:"Project '" + displayNameFilter(data) + "' was successfully created."
}); });
...@@ -188,7 +187,8 @@ $scope.disableInputs = !1; ...@@ -188,7 +187,8 @@ $scope.disableInputs = !1;
var data = result.data || {}; var data = result.data || {};
if ("AlreadyExists" === data.reason) $scope.nameTaken = !0; else { if ("AlreadyExists" === data.reason) $scope.nameTaken = !0; else {
var msg = data.message || "An error occurred creating the project."; var msg = data.message || "An error occurred creating the project.";
showAlert("error-creating-project", { NotificationsService.addNotification({
id:"create-project-error",
type:"error", type:"error",
message:msg message:msg
}); });
...@@ -199,7 +199,7 @@ if ($scope.onCancel) { ...@@ -199,7 +199,7 @@ if ($scope.onCancel) {
var cb = $scope.onCancel(); var cb = $scope.onCancel();
cb && cb(); cb && cb();
} else $window.history.back(); } else $window.history.back();
}; }, $scope.$on("$destroy", hideErrorNotifications);
} ] } ]
}; };
} ]), angular.module("openshiftCommonUI").directive("deleteProject", [ "$uibModal", "$location", "$filter", "$q", "hashSizeFilter", "APIService", "DataService", "NotificationsService", "Logger", function($uibModal, $location, $filter, $q, hashSizeFilter, APIService, DataService, NotificationsService, Logger) { } ]), angular.module("openshiftCommonUI").directive("deleteProject", [ "$uibModal", "$location", "$filter", "$q", "hashSizeFilter", "APIService", "DataService", "NotificationsService", "Logger", function($uibModal, $location, $filter, $q, hashSizeFilter, APIService, DataService, NotificationsService, Logger) {
......
...@@ -6,7 +6,6 @@ angular.module("openshiftCommonUI") ...@@ -6,7 +6,6 @@ angular.module("openshiftCommonUI")
return { return {
restrict: 'E', restrict: 'E',
scope: { scope: {
alerts: '=',
redirectAction: '&', redirectAction: '&',
onCancel: '&?', onCancel: '&?',
isDialog: '@' isDialog: '@'
...@@ -19,9 +18,8 @@ angular.module("openshiftCommonUI") ...@@ -19,9 +18,8 @@ angular.module("openshiftCommonUI")
$scope.isDialog = $scope.isDialog === 'true'; $scope.isDialog = $scope.isDialog === 'true';
var showAlert = function(name, alert) { var hideErrorNotifications = function() {
$scope.alerts[name] = alert; NotificationsService.hideNotification('create-project-error');
NotificationsService.addNotification(alert);
}; };
$scope.createProject = function() { $scope.createProject = function() {
...@@ -45,7 +43,7 @@ angular.module("openshiftCommonUI") ...@@ -45,7 +43,7 @@ angular.module("openshiftCommonUI")
} else { } else {
$location.path("project/" + encodeURIComponent(data.metadata.name) + "/create"); $location.path("project/" + encodeURIComponent(data.metadata.name) + "/create");
} }
showAlert('created-project', { NotificationsService.addNotification({
type: "success", type: "success",
message: "Project \'" + displayNameFilter(data) + "\' was successfully created." message: "Project \'" + displayNameFilter(data) + "\' was successfully created."
}); });
...@@ -56,7 +54,11 @@ angular.module("openshiftCommonUI") ...@@ -56,7 +54,11 @@ angular.module("openshiftCommonUI")
$scope.nameTaken = true; $scope.nameTaken = true;
} else { } else {
var msg = data.message || 'An error occurred creating the project.'; var msg = data.message || 'An error occurred creating the project.';
showAlert('error-creating-project', {type: 'error', message: msg}); NotificationsService.addNotification({
id: 'create-project-error',
type: 'error',
message: msg
});
} }
}); });
} }
...@@ -72,6 +74,8 @@ angular.module("openshiftCommonUI") ...@@ -72,6 +74,8 @@ angular.module("openshiftCommonUI")
$window.history.back(); $window.history.back();
} }
}; };
$scope.$on("$destroy", hideErrorNotifications);
}, },
}; };
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment