Skip to content

Commit c8e8103

Browse files
author
OpenShift Bot
authored
Merge pull request #1646 from spadgett/steve-deployment-toasts
Merged by openshift-bot
2 parents 5ecda44 + 79ebb8f commit c8e8103

File tree

14 files changed

+431
-435
lines changed

14 files changed

+431
-435
lines changed

app/scripts/controllers/deploymentConfig.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ angular.module('openshiftConsole')
2020
ImageStreamResolver,
2121
ModalsService,
2222
Navigate,
23+
NotificationsService,
2324
Logger,
2425
ProjectsService,
2526
StorageService,
@@ -134,27 +135,25 @@ angular.module('openshiftConsole')
134135
updateHPAWarnings();
135136
$scope.updatedDeploymentConfig = EnvironmentService.copyAndNormalize($scope.deploymentConfig);
136137
$scope.saveEnvVars = function() {
138+
NotificationsService.hideNotification("save-dc-env-error");
137139
EnvironmentService.compact($scope.updatedDeploymentConfig);
138140
saveEnvPromise = DataService.update("deploymentconfigs",
139141
$routeParams.deploymentconfig,
140142
$scope.updatedDeploymentConfig,
141143
context);
142144
saveEnvPromise.then(function success(){
143-
// TODO: de-duplicate success and error messages.
144-
// as it stands, multiple messages appear based on how edit
145-
// is made.
146-
$scope.alerts['saveDCEnvVarsSuccess'] = {
145+
NotificationsService.addNotification({
147146
type: "success",
148-
// TODO: improve success alert
149-
message: $scope.deploymentConfigName + " was updated."
150-
};
147+
message: "Environment variables for deployment config " + $scope.deploymentConfigName + " were successfully updated."
148+
});
151149
$scope.forms.dcEnvVars.$setPristine();
152150
}, function error(e){
153-
$scope.alerts['saveDCEnvVarsError'] = {
151+
NotificationsService.addNotification({
152+
id: "save-dc-env-error",
154153
type: "error",
155-
message: $scope.deploymentConfigName + " was not updated.",
156-
details: "Reason: " + $filter('getErrorDetails')(e)
157-
};
154+
message: "An error occurred updating environment variables for deployment config " + $scope.deploymentConfigName + ".",
155+
details: $filter('getErrorDetails')(e)
156+
});
158157
}).finally(function() {
159158
saveEnvPromise = null;
160159
});
@@ -353,7 +352,7 @@ angular.module('openshiftConsole')
353352

354353
$scope.startLatestDeployment = function() {
355354
if ($scope.canDeploy()) {
356-
DeploymentsService.startLatestDeployment($scope.deploymentConfig, context, $scope);
355+
DeploymentsService.startLatestDeployment($scope.deploymentConfig, context);
357356
}
358357
};
359358

app/scripts/controllers/edit/deploymentConfig.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ angular.module('openshiftConsole')
1313
$location,
1414
$routeParams,
1515
$uibModal,
16+
$window,
1617
AlertMessageService,
1718
AuthorizationService,
1819
BreadcrumbsService,
1920
DataService,
2021
EnvironmentService,
2122
Navigate,
23+
NotificationsService,
2224
ProjectsService,
2325
SecretsService,
2426
keyValueEditorUtils) {
@@ -320,6 +322,14 @@ angular.module('openshiftConsole')
320322
return updatedTriggers;
321323
};
322324

325+
var doneEditing = function() {
326+
_.set($scope, 'confirm.doneEditing', true);
327+
}
328+
329+
var hideErrorNotifications = function() {
330+
NotificationsService.hideNotification("edit-deployment-config-error");
331+
};
332+
323333
$scope.save = function() {
324334
$scope.disableInputs = true;
325335

@@ -369,30 +379,35 @@ angular.module('openshiftConsole')
369379
$scope.updatedDeploymentConfig.spec.strategy = $scope.strategyData;
370380
$scope.updatedDeploymentConfig.spec.triggers = updateTriggers();
371381

382+
hideErrorNotifications();
372383
DataService.update("deploymentconfigs", $scope.updatedDeploymentConfig.metadata.name, $scope.updatedDeploymentConfig, $scope.context).then(
373384
function() {
374-
AlertMessageService.addAlert({
375-
name: $scope.updatedDeploymentConfig.metadata.name,
376-
data: {
377-
type: "success",
378-
message: "Deployment config " + $scope.updatedDeploymentConfig.metadata.name + " was successfully updated."
379-
}
385+
NotificationsService.addNotification({
386+
type: "success",
387+
message: "Deployment config " + $scope.updatedDeploymentConfig.metadata.name + " was successfully updated."
380388
});
381-
_.set($scope, 'confirm.doneEditing', true);
389+
doneEditing();
382390
var returnURL = Navigate.resourceURL($scope.updatedDeploymentConfig);
383391
$location.url(returnURL);
384392
},
385393
function(result) {
386394
$scope.disableInputs = false;
387-
$scope.alerts["save"] = {
395+
NotificationsService.addNotification({
396+
id: "edit-deployment-config-error",
388397
type: "error",
389398
message: "An error occurred updating deployment config " + $scope.updatedDeploymentConfig.metadata.name + ".",
390399
details: $filter('getErrorDetails')(result)
391-
};
400+
});
392401
}
393402
);
394403
};
395404

405+
$scope.cancel = function() {
406+
hideErrorNotifications();
407+
doneEditing();
408+
$window.history.back();
409+
};
410+
396411
$scope.$on('$destroy', function(){
397412
DataService.unwatchAll(watches);
398413
});

app/scripts/controllers/edit/healthChecks.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ angular.module('openshiftConsole')
1313
$location,
1414
$routeParams,
1515
$scope,
16-
AlertMessageService,
1716
AuthorizationService,
1817
BreadcrumbsService,
1918
APIService,
2019
DataService,
2120
Navigate,
21+
NotificationsService,
2222
ProjectsService) {
2323
if (!$routeParams.kind || !$routeParams.name) {
2424
Navigate.toErrorPage("Kind or name parameter missing.");
@@ -39,10 +39,6 @@ angular.module('openshiftConsole')
3939

4040
$scope.name = $routeParams.name;
4141
$scope.resourceURL = Navigate.resourceURL($scope.name, $routeParams.kind, $routeParams.project);
42-
$scope.alerts = {};
43-
$scope.renderOptions = {
44-
hideFilterWidget: true
45-
};
4642

4743
$scope.breadcrumbs = BreadcrumbsService.getBreadcrumbs({
4844
name: $routeParams.name,
@@ -56,13 +52,29 @@ angular.module('openshiftConsole')
5652
$scope.previousProbes = {};
5753

5854
var getErrorDetails = $filter('getErrorDetails');
55+
var upperFirst = $filter('upperFirst');
5956

6057
var displayError = function(errorMessage, errorDetails) {
61-
$scope.alerts['add-health-check'] = {
58+
NotificationsService.addNotification({
59+
id: "add-health-check-error",
6260
type: "error",
6361
message: errorMessage,
6462
details: errorDetails
65-
};
63+
});
64+
};
65+
66+
var navigateBack = function() {
67+
_.set($scope, 'confirm.doneEditing', true);
68+
$location.url($scope.resourceURL);
69+
};
70+
71+
var hideErrorNotifications = function() {
72+
NotificationsService.hideNotification("add-health-check-error");
73+
};
74+
75+
$scope.cancel = function() {
76+
hideErrorNotifications();
77+
navigateBack();
6678
};
6779

6880
ProjectsService
@@ -107,31 +119,27 @@ angular.module('openshiftConsole')
107119

108120
$scope.save = function() {
109121
$scope.disableInputs = true;
122+
hideErrorNotifications();
110123
DataService.update(APIService.kindToResource($routeParams.kind),
111124
$scope.name,
112125
object,
113126
context).then(
114127
function() {
115-
AlertMessageService.addAlert({
116-
name: $scope.name,
117-
data: {
128+
NotificationsService.addNotification({
118129
type: "success",
119-
message: displayName + " was updated."
120-
}
130+
message: upperFirst(displayName) + " was updated."
121131
});
122-
_.set($scope, 'confirm.doneEditing', true);
123-
$location.url($scope.resourceURL);
132+
navigateBack();
124133
},
125134
function(result) {
126135
$scope.disableInputs = false;
127-
displayError(displayName + ' could not be updated.', getErrorDetails(result));
136+
displayError(upperFirst(displayName) + ' could not be updated.', getErrorDetails(result));
128137
});
129138
};
130139
},
131140
function(result) {
132-
displayError(displayName + ' could not be loaded.', getErrorDetails(result));
141+
displayError(upperFirst(displayName) + ' could not be loaded.', getErrorDetails(result));
133142
}
134143
);
135144
}));
136145
});
137-

app/scripts/controllers/edit/yaml.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ angular.module('openshiftConsole')
1313
$location,
1414
$routeParams,
1515
$window,
16-
AlertMessageService,
1716
APIService,
1817
AuthorizationService,
1918
BreadcrumbsService,
2019
DataService,
2120
Navigate,
21+
NotificationsService,
2222
ProjectsService) {
2323
if (!$routeParams.kind || !$routeParams.name) {
2424
Navigate.toErrorPage("Kind or name parameter missing.");
@@ -160,13 +160,9 @@ angular.module('openshiftConsole')
160160
$scope.updatingNow = false;
161161
return;
162162
}
163-
164-
AlertMessageService.addAlert({
165-
name: 'edit-yaml',
166-
data: {
163+
NotificationsService.addNotification({
167164
type: "success",
168165
message: humanizeKind($routeParams.kind, true) + " " + $routeParams.name + " was successfully updated."
169-
}
170166
});
171167
navigateBack();
172168
},

app/scripts/controllers/replicaSet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ angular.module('openshiftConsole')
561561
};
562562

563563
$scope.cancelRunningDeployment = function(replicaSet) {
564-
DeploymentsService.cancelRunningDeployment(replicaSet, context, $scope);
564+
DeploymentsService.cancelRunningDeployment(replicaSet, context);
565565
};
566566

567567
$scope.scale = function(replicas) {

app/scripts/controllers/setLimits.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ angular.module('openshiftConsole')
1414
$parse,
1515
$routeParams,
1616
$scope,
17-
AlertMessageService,
1817
APIService,
1918
AuthorizationService,
2019
BreadcrumbsService,
2120
DataService,
2221
LimitRangesService,
2322
Navigate,
23+
NotificationsService,
2424
ProjectsService) {
2525
if (!$routeParams.kind || !$routeParams.name) {
2626
Navigate.toErrorPage("Kind or name parameter missing.");
@@ -47,7 +47,6 @@ angular.module('openshiftConsole')
4747
$scope.showPodWarning = true;
4848
}
4949

50-
$scope.alerts = {};
5150
$scope.renderOptions = {
5251
hideFilterWidget: true
5352
};
@@ -63,11 +62,26 @@ angular.module('openshiftConsole')
6362
var getErrorDetails = $filter('getErrorDetails');
6463

6564
var displayError = function(errorMessage, errorDetails) {
66-
$scope.alerts['set-compute-limits'] = {
65+
NotificationsService.addNotification({
66+
id: "set-compute-limits-error",
6767
type: "error",
6868
message: errorMessage,
6969
details: errorDetails
70-
};
70+
});
71+
};
72+
73+
var navigateBack = function() {
74+
_.set($scope, 'confirm.doneEditing', true);
75+
$location.url($scope.resourceURL);
76+
};
77+
78+
var hideErrorNotifications = function() {
79+
NotificationsService.hideNotification("set-compute-limits-error");
80+
};
81+
82+
$scope.cancel = function() {
83+
hideErrorNotifications();
84+
navigateBack();
7185
};
7286

7387
ProjectsService
@@ -100,17 +114,14 @@ angular.module('openshiftConsole')
100114
$scope.containers = _.get(object, 'spec.template.spec.containers');
101115
$scope.save = function() {
102116
$scope.disableInputs = true;
117+
hideErrorNotifications();
103118
DataService.update(resourceGroupVersion, $scope.name, object, context).then(
104119
function() {
105-
AlertMessageService.addAlert({
106-
name: $scope.name,
107-
data: {
120+
NotificationsService.addNotification({
108121
type: "success",
109122
message: displayName + " was updated."
110-
}
111123
});
112-
_.set($scope, 'confirm.doneEditing', true);
113-
$location.url($scope.resourceURL);
124+
navigateBack();
114125
},
115126
function(result) {
116127
$scope.disableInputs = false;

app/scripts/directives/deleteLink.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,17 @@ angular.module("openshiftConsole")
7979
group: 'autoscaling'
8080
}, hpa.metadata.name, { namespace: scope.projectName })
8181
.then(function() {
82-
showAlert({
83-
name: hpa.metadata.name,
84-
data: {
82+
NotificationsService.addNotification({
8583
type: "success",
86-
message: "Horizontal Pod Autoscaler " + hpa.metadata.name + " was marked for deletion."
87-
}
84+
message: "Horizontal pod autoscaler " + hpa.metadata.name + " was marked for deletion."
8885
});
8986
})
9087
.catch(function(err) {
9188
showAlert({
9289
name: hpa.metadata.name,
9390
data: {
9491
type: "error",
95-
message: "Horizontal Pod Autoscaler " + hpa.metadata.name + " could not be deleted."
92+
message: "Horizontal pod autoscaler " + hpa.metadata.name + " could not be deleted."
9693
}
9794
});
9895
Logger.error("HPA " + hpa.metadata.name + " could not be deleted.", err);
@@ -150,12 +147,9 @@ angular.module("openshiftConsole")
150147
group: scope.group
151148
}, resourceName, context)
152149
.then(function() {
153-
showAlert({
154-
name: resourceName,
155-
data: {
150+
NotificationsService.addNotification({
156151
type: "success",
157152
message: _.capitalize(formattedResource) + " was marked for deletion."
158-
}
159153
});
160154

161155
if (scope.success) {
@@ -183,4 +177,3 @@ angular.module("openshiftConsole")
183177
}
184178
};
185179
});
186-

app/scripts/directives/overview/listRow.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
row.startDeployment = function() {
254254
DeploymentsService.startLatestDeployment(row.apiObject, {
255255
namespace: row.apiObject.metadata.namespace
256-
}, { alerts: row.state.alerts });
256+
});
257257
};
258258

259259
// TODO: Pulled from dc.js, but we should probably make the dialog generic and reuse for the deployment config page.
@@ -312,7 +312,7 @@
312312

313313
DeploymentsService.cancelRunningDeployment(replicationController, {
314314
namespace: replicationController.metadata.namespace
315-
}, { alerts: row.state.alerts });
315+
});
316316
});
317317
};
318318

0 commit comments

Comments
 (0)