Skip to content

Commit 44421e9

Browse files
committed
Update edit config map to use toast notifications
1 parent cdf2198 commit 44421e9

File tree

4 files changed

+53
-35
lines changed

4 files changed

+53
-35
lines changed

app/scripts/controllers/edit/configMap.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ angular.module('openshiftConsole')
1616
DataService,
1717
BreadcrumbsService,
1818
Navigate,
19+
NotificationsService,
1920
ProjectsService) {
2021
var watches = [];
21-
$scope.alerts = {};
2222
$scope.forms = {};
2323
$scope.projectName = $routeParams.project;
2424

@@ -34,6 +34,19 @@ angular.module('openshiftConsole')
3434
return _.get(resource, 'metadata.resourceVersion');
3535
};
3636

37+
var hideErrorNotifications = function() {
38+
NotificationsService.hideNotification("edit-config-map-error");
39+
};
40+
41+
var navigateBack = function() {
42+
$window.history.back();
43+
};
44+
45+
$scope.cancel = function() {
46+
hideErrorNotifications();
47+
navigateBack();
48+
};
49+
3750
ProjectsService
3851
.get($routeParams.project)
3952
.then(_.spread(function(project, context) {
@@ -54,29 +67,30 @@ angular.module('openshiftConsole')
5467
$scope.resourceDeleted = action === "DELETED";
5568
}));
5669
}, function(e) {
57-
$scope.loaded = true;
58-
$scope.alerts["load"] = {
59-
type: "error",
60-
message: "The config map details could not be loaded.",
61-
details: $filter('getErrorDetails')(e)
62-
};
70+
Navigate.toErrorPage("Could not load config map " + $routeParams.configMap + ". " +
71+
$filter('getErrorDetails')(e));
6372
});
6473

6574
$scope.updateConfigMap = function() {
6675
if ($scope.forms.editConfigMapForm.$valid) {
76+
hideErrorNotifications();
6777
$scope.disableInputs = true;
6878

6979
DataService.update('configmaps', $scope.configMap.metadata.name, $scope.configMap, context)
7080
.then(function() { // Success
71-
// Return to the previous page
72-
$window.history.back();
81+
NotificationsService.addNotification({
82+
type: "success",
83+
message: "Config map " + $scope.configMap.metadata.name + " successfully updated."
84+
});
85+
navigateBack();
7386
}, function(result) { // Failure
7487
$scope.disableInputs = false;
75-
$scope.alerts['create-config-map'] = {
88+
NotificationsService.addNotification({
89+
id: "edit-config-map-error",
7690
type: "error",
7791
message: "An error occurred updating the config map.",
7892
details: $filter('getErrorDetails')(result)
79-
};
93+
});
8094
});
8195
}
8296
};

app/views/edit/config-map.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<div class="row">
1313
<div class="col-md-10 col-md-offset-1">
1414
<breadcrumbs breadcrumbs="breadcrumbs"></breadcrumbs>
15-
<alerts alerts="alerts"></alerts>
1615
<div class="mar-top-xl">
1716
<h1>Edit Config Map {{configMap.metadata.name}}</h1>
1817
<div class="help-block">
@@ -41,7 +40,7 @@ <h1>Edit Config Map {{configMap.metadata.name}}</h1>
4140
ng-click="updateConfigMap()"
4241
ng-disabled="forms.editConfigMapForm.$invalid || forms.editConfigMapForm.$pristine || disableInputs || resourceChanged || resourceDeleted"
4342
value="">Save</button>
44-
<a class="btn btn-default btn-lg" href="#" back>Cancel</a>
43+
<a class="btn btn-default btn-lg" href="" ng-click="cancel()" role="button">Cancel</a>
4544
</div>
4645
</fieldset>
4746
</form>

dist/scripts/scripts.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6940,47 +6940,53 @@ details:b("getErrorDetails")(c)
69406940
}, a.$on("$destroy", function() {
69416941
h.unwatchAll(q);
69426942
});
6943-
} ]), angular.module("openshiftConsole").controller("EditConfigMapController", [ "$filter", "$routeParams", "$scope", "$window", "DataService", "BreadcrumbsService", "Navigate", "ProjectsService", function(a, b, c, d, e, f, g, h) {
6944-
var i = [];
6945-
c.alerts = {}, c.forms = {}, c.projectName = b.project, c.breadcrumbs = f.getBreadcrumbs({
6943+
} ]), angular.module("openshiftConsole").controller("EditConfigMapController", [ "$filter", "$routeParams", "$scope", "$window", "DataService", "BreadcrumbsService", "Navigate", "NotificationsService", "ProjectsService", function(a, b, c, d, e, f, g, h, i) {
6944+
var j = [];
6945+
c.forms = {}, c.projectName = b.project, c.breadcrumbs = f.getBreadcrumbs({
69466946
name:b.configMap,
69476947
kind:"ConfigMap",
69486948
namespace:b.project,
69496949
includeProject:!0,
69506950
subpage:"Edit Config Map"
69516951
});
6952-
var j = function(a) {
6952+
var k = function(a) {
69536953
return _.get(a, "metadata.resourceVersion");
6954+
}, l = function() {
6955+
h.hideNotification("edit-config-map-error");
6956+
}, m = function() {
6957+
d.history.back();
69546958
};
6955-
h.get(b.project).then(_.spread(function(g, h) {
6956-
e.get("configmaps", b.configMap, h).then(function(a) {
6959+
c.cancel = function() {
6960+
l(), m();
6961+
}, i.get(b.project).then(_.spread(function(d, i) {
6962+
e.get("configmaps", b.configMap, i).then(function(a) {
69576963
c.loaded = !0, c.breadcrumbs = f.getBreadcrumbs({
69586964
name:b.configMap,
69596965
object:a,
69606966
includeProject:!0,
6961-
project:g,
6967+
project:d,
69626968
subpage:"Edit Config Map"
6963-
}), c.configMap = a, i.push(e.watchObject("configmaps", b.configMap, h, function(a, b) {
6964-
c.resourceChanged = j(a) !== j(c.configMap), c.resourceDeleted = "DELETED" === b;
6969+
}), c.configMap = a, j.push(e.watchObject("configmaps", b.configMap, i, function(a, b) {
6970+
c.resourceChanged = k(a) !== k(c.configMap), c.resourceDeleted = "DELETED" === b;
69656971
}));
6966-
}, function(b) {
6967-
c.loaded = !0, c.alerts.load = {
6968-
type:"error",
6969-
message:"The config map details could not be loaded.",
6970-
details:a("getErrorDetails")(b)
6971-
};
6972+
}, function(c) {
6973+
g.toErrorPage("Could not load config map " + b.configMap + ". " + a("getErrorDetails")(c));
69726974
}), c.updateConfigMap = function() {
6973-
c.forms.editConfigMapForm.$valid && (c.disableInputs = !0, e.update("configmaps", c.configMap.metadata.name, c.configMap, h).then(function() {
6974-
d.history.back();
6975+
c.forms.editConfigMapForm.$valid && (l(), c.disableInputs = !0, e.update("configmaps", c.configMap.metadata.name, c.configMap, i).then(function() {
6976+
h.addNotification({
6977+
type:"success",
6978+
message:"Config map " + c.configMap.metadata.name + " successfully updated."
6979+
}), m();
69756980
}, function(b) {
6976-
c.disableInputs = !1, c.alerts["create-config-map"] = {
6981+
c.disableInputs = !1, h.addNotification({
6982+
id:"edit-config-map-error",
69776983
type:"error",
69786984
message:"An error occurred updating the config map.",
69796985
details:a("getErrorDetails")(b)
6980-
};
6986+
});
69816987
}));
69826988
}, c.$on("$destroy", function() {
6983-
e.unwatchAll(i);
6989+
e.unwatchAll(j);
69846990
});
69856991
}));
69866992
} ]), angular.module("openshiftConsole").controller("EditDeploymentConfigController", [ "$scope", "$filter", "$location", "$routeParams", "$uibModal", "$window", "AuthorizationService", "BreadcrumbsService", "DataService", "EnvironmentService", "Navigate", "NotificationsService", "ProjectsService", "SecretsService", "keyValueEditorUtils", function(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) {

dist/scripts/templates.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9294,7 +9294,6 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
92949294
"<div class=\"row\">\n" +
92959295
"<div class=\"col-md-10 col-md-offset-1\">\n" +
92969296
"<breadcrumbs breadcrumbs=\"breadcrumbs\"></breadcrumbs>\n" +
9297-
"<alerts alerts=\"alerts\"></alerts>\n" +
92989297
"<div class=\"mar-top-xl\">\n" +
92999298
"<h1>Edit Config Map {{configMap.metadata.name}}</h1>\n" +
93009299
"<div class=\"help-block\">\n" +
@@ -9317,7 +9316,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
93179316
"<edit-config-map model=\"configMap\"></edit-config-map>\n" +
93189317
"<div class=\"button-group gutter-top gutter-bottom\">\n" +
93199318
"<button type=\"submit\" class=\"btn btn-primary btn-lg\" ng-click=\"updateConfigMap()\" ng-disabled=\"forms.editConfigMapForm.$invalid || forms.editConfigMapForm.$pristine || disableInputs || resourceChanged || resourceDeleted\" value=\"\">Save</button>\n" +
9320-
"<a class=\"btn btn-default btn-lg\" href=\"#\" back>Cancel</a>\n" +
9319+
"<a class=\"btn btn-default btn-lg\" href=\"\" ng-click=\"cancel()\" role=\"button\">Cancel</a>\n" +
93219320
"</div>\n" +
93229321
"</fieldset>\n" +
93239322
"</form>\n" +

0 commit comments

Comments
 (0)