Skip to content

Commit 13a3b68

Browse files
spadgettsg00dwin
authored andcommitted
Hide error notifications when form is resubmitted
1 parent fde2e7c commit 13a3b68

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
lines changed

app/scripts/controllers/createRoute.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ angular.module('openshiftConsole')
4646
}
4747
];
4848

49+
var hideErrorNotifications = function() {
50+
NotificationsService.hideNotification("create-route-error");
51+
};
52+
53+
$scope.cancel = function() {
54+
hideErrorNotifications();
55+
$window.history.back();
56+
};
57+
4958
ProjectsService
5059
.get($routeParams.project)
5160
.then(_.spread(function(project, context) {
@@ -82,6 +91,7 @@ angular.module('openshiftConsole')
8291

8392
$scope.createRoute = function() {
8493
if ($scope.createRouteForm.$valid) {
94+
hideErrorNotifications();
8595
$scope.disableInputs = true;
8696
var serviceName = $scope.routing.to.service.metadata.name;
8797
var labels = keyValueEditorUtils.mapEntries(keyValueEditorUtils.compactEntries($scope.labels));
@@ -111,6 +121,7 @@ angular.module('openshiftConsole')
111121
$scope.disableInputs = false;
112122
NotificationsService.addNotification({
113123
type: "error",
124+
id: "create-route-error",
114125
message: "An error occurred creating the route.",
115126
details: $filter('getErrorDetails')(result)
116127
});

app/scripts/controllers/edit/route.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ angular.module('openshiftConsole')
4141
title: "Edit"
4242
}];
4343

44+
$scope.hideErrorNotifications = function() {
45+
NotificationsService.hideNotification("edit-route-error");
46+
};
47+
4448
ProjectsService
4549
.get($routeParams.project)
4650
.then(_.spread(function(project, context) {
@@ -158,19 +162,21 @@ angular.module('openshiftConsole')
158162

159163
$scope.updateRoute = function() {
160164
if ($scope.form.$valid) {
165+
$scope.hideErrorNotifications();
161166
$scope.disableInputs = true;
162167
var updated = updateRouteFields();
163168
DataService.update('routes', $scope.routeName, updated, context)
164169
.then(function() { // Success
165170
NotificationsService.addNotification({
166-
type: "success",
167-
message: "Route " + $scope.routeName + " was successfully updated."
171+
type: "success",
172+
message: "Route " + $scope.routeName + " was successfully updated."
168173
});
169174
$location.path($scope.routeURL);
170175
}, function(response) { // Failure
171176
$scope.disableInputs = false;
172177
NotificationsService.addNotification({
173178
type: "error",
179+
id: "edit-route-error",
174180
message: "An error occurred updating route " + $scope.routeName + ".",
175181
details: $filter('getErrorDetails')(response)
176182
});

app/views/create-route.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h1>Create Route</h1>
3939
ng-click="createRoute()"
4040
ng-disabled="createRouteForm.$invalid || disableInputs || !createRoute"
4141
value="">Create</button>
42-
<a class="btn btn-default btn-lg" href="#" back>Cancel</a>
42+
<a class="btn btn-default btn-lg" href="" ng-click="cancel()">Cancel</a>
4343
</div>
4444
</fieldset>
4545
</div>

app/views/edit/route.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ <h1>Edit Route {{routeName}}</h1>
3030
ng-click="updateRoute()"
3131
ng-disabled="form.$invalid || disableInputs"
3232
value="">Save</button>
33-
<a class="btn btn-default btn-lg" ng-href="{{routeURL}}">Cancel</a>
33+
<a class="btn btn-default btn-lg"
34+
ng-click="hideErrorNotifications()"
35+
ng-href="{{routeURL}}">Cancel</a>
3436
</div>
3537
</fieldset>
3638
</form>

dist/scripts/scripts.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7894,7 +7894,7 @@ n(o + " could not be loaded.", m(a));
78947894
}) :void j.toErrorPage("You do not have authority to update " + o + ".", "access_denied");
78957895
}));
78967896
} ]), angular.module("openshiftConsole").controller("EditRouteController", [ "$filter", "$location", "$routeParams", "$scope", "AlertMessageService", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "RoutesService", function(a, b, c, d, e, f, g, h, i, j, k) {
7897-
d.alerts = {}, d.renderOptions = {
7897+
d.renderOptions = {
78987898
hideFilterWidget:!0
78997899
}, d.projectName = c.project, d.routeName = c.route, d.loading = !0, d.routeURL = h.resourceURL(d.routeName, "Route", d.projectName), d.breadcrumbs = [ {
79007900
title:d.projectName,
@@ -7907,7 +7907,9 @@ title:d.routeName,
79077907
link:d.routeURL
79087908
}, {
79097909
title:"Edit"
7910-
} ], j.get(c.project).then(_.spread(function(e, j) {
7910+
} ], d.hideErrorNotifications = function() {
7911+
i.hideNotification("edit-route-error");
7912+
}, j.get(c.project).then(_.spread(function(e, j) {
79117913
if (d.project = e, d.breadcrumbs[0].title = a("displayName")(e), !f.canI("routes", "update", c.project)) return void h.toErrorPage("You do not have authority to update route " + c.routeName + ".", "access_denied");
79127914
var l, m = a("orderByDisplayName");
79137915
g.get("routes", d.routeName, j).then(function(a) {
@@ -7953,7 +7955,7 @@ weight:a.weight
79537955
};
79547956
d.updateRoute = function() {
79557957
if (d.form.$valid) {
7956-
d.disableInputs = !0;
7958+
d.hideErrorNotifications(), d.disableInputs = !0;
79577959
var c = n();
79587960
g.update("routes", d.routeName, c, j).then(function() {
79597961
i.addNotification({
@@ -7963,6 +7965,7 @@ message:"Route " + d.routeName + " was successfully updated."
79637965
}, function(b) {
79647966
d.disableInputs = !1, i.addNotification({
79657967
type:"error",
7968+
id:"edit-route-error",
79667969
message:"An error occurred updating route " + d.routeName + ".",
79677970
details:a("getErrorDetails")(b)
79687971
});
@@ -8717,7 +8720,7 @@ details:c("getErrorDetails")(b)
87178720
});
87188721
}));
87198722
} ]), angular.module("openshiftConsole").controller("CreateRouteController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "keyValueEditorUtils", function(a, b, c, d, e, f, g, h, i, j, k) {
8720-
c.alerts = {}, c.renderOptions = {
8723+
c.renderOptions = {
87218724
hideFilterWidget:!0
87228725
}, c.projectName = b.project, c.serviceName = b.service, c.labels = [], c.routing = {
87238726
name:c.serviceName || ""
@@ -8729,11 +8732,17 @@ title:"Routes",
87298732
link:"project/" + c.projectName + "/browse/routes"
87308733
}, {
87318734
title:"Create Route"
8732-
} ], j.get(b.project).then(_.spread(function(j, l) {
8735+
} ];
8736+
var l = function() {
8737+
i.hideNotification("create-route-error");
8738+
};
8739+
c.cancel = function() {
8740+
l(), d.history.back();
8741+
}, j.get(b.project).then(_.spread(function(j, m) {
87338742
if (c.project = j, c.breadcrumbs[0].title = a("displayName")(j), !f.canI("routes", "create", b.project)) return void h.toErrorPage("You do not have authority to create routes in project " + b.project + ".", "access_denied");
8734-
var m = a("orderByDisplayName");
8735-
g.list("services", l).then(function(a) {
8736-
c.services = m(a.by("metadata.name")), c.routing.to = {}, c.routing.to.service = _.find(c.services, function(a) {
8743+
var n = a("orderByDisplayName");
8744+
g.list("services", m).then(function(a) {
8745+
c.services = n(a.by("metadata.name")), c.routing.to = {}, c.routing.to.service = _.find(c.services, function(a) {
87378746
return !c.serviceName || a.metadata.name === c.serviceName;
87388747
});
87398748
}), c.copyServiceLabels = function() {
@@ -8746,22 +8755,23 @@ value:a
87468755
});
87478756
}, c.createRoute = function() {
87488757
if (c.createRouteForm.$valid) {
8749-
c.disableInputs = !0;
8758+
l(), c.disableInputs = !0;
87508759
var b = c.routing.to.service.metadata.name, f = k.mapEntries(k.compactEntries(c.labels)), h = e.createRoute(c.routing, b, f), j = _.get(c, "routing.alternateServices", []);
87518760
_.isEmpty(j) || (h.spec.to.weight = _.get(c, "routing.to.weight"), h.spec.alternateBackends = _.map(j, function(a) {
87528761
return {
87538762
kind:"Service",
87548763
name:_.get(a, "service.metadata.name"),
87558764
weight:a.weight
87568765
};
8757-
})), g.create("routes", null, h, l).then(function() {
8766+
})), g.create("routes", null, h, m).then(function() {
87588767
i.addNotification({
87598768
type:"success",
87608769
message:"Route " + h.metadata.name + " was successfully created."
87618770
}), d.history.back();
87628771
}, function(b) {
87638772
c.disableInputs = !1, i.addNotification({
87648773
type:"error",
8774+
id:"create-route-error",
87658775
message:"An error occurred creating the route.",
87668776
details:a("getErrorDetails")(b)
87678777
});

dist/scripts/templates.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4694,7 +4694,6 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
46944694
"<div class=\"row\">\n" +
46954695
"<div class=\"col-md-10 col-md-offset-1\">\n" +
46964696
"<breadcrumbs breadcrumbs=\"breadcrumbs\"></breadcrumbs>\n" +
4697-
"<alerts alerts=\"alerts\"></alerts>\n" +
46984697
"<div class=\"mar-top-xl\">\n" +
46994698
"<h1>Create Route</h1>\n" +
47004699
"<div class=\"help-block\">\n" +
@@ -4711,7 +4710,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
47114710
"<a href=\"\" ng-click=\"copyServiceLabels()\">Copy Service Labels</a>\n" +
47124711
"<div class=\"button-group gutter-top gutter-bottom\">\n" +
47134712
"<button type=\"submit\" class=\"btn btn-primary btn-lg\" ng-click=\"createRoute()\" ng-disabled=\"createRouteForm.$invalid || disableInputs || !createRoute\" value=\"\">Create</button>\n" +
4714-
"<a class=\"btn btn-default btn-lg\" href=\"#\" back>Cancel</a>\n" +
4713+
"<a class=\"btn btn-default btn-lg\" href=\"\" ng-click=\"cancel()\">Cancel</a>\n" +
47154714
"</div>\n" +
47164715
"</fieldset>\n" +
47174716
"</div>\n" +
@@ -9789,7 +9788,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
97899788
"</osc-routing>\n" +
97909789
"<div class=\"button-group gutter-top gutter-bottom\">\n" +
97919790
"<button type=\"submit\" class=\"btn btn-primary btn-lg\" ng-click=\"updateRoute()\" ng-disabled=\"form.$invalid || disableInputs\" value=\"\">Save</button>\n" +
9792-
"<a class=\"btn btn-default btn-lg\" ng-href=\"{{routeURL}}\">Cancel</a>\n" +
9791+
"<a class=\"btn btn-default btn-lg\" ng-click=\"hideErrorNotifications()\" ng-href=\"{{routeURL}}\">Cancel</a>\n" +
97939792
"</div>\n" +
97949793
"</fieldset>\n" +
97959794
"</form>\n" +

0 commit comments

Comments
 (0)