Skip to content

Commit 2059a4d

Browse files
committed
Update create storage page to use toast notifications
1 parent cdf2198 commit 2059a4d

File tree

5 files changed

+57
-27
lines changed

5 files changed

+57
-27
lines changed

app/scripts/controllers/createPersistentVolumeClaim.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ angular.module('openshiftConsole')
1717
AuthorizationService,
1818
DataService,
1919
Navigate,
20+
NotificationsService,
2021
ProjectsService,
2122
keyValueEditorUtils) {
22-
$scope.alerts = {};
2323
$scope.projectName = $routeParams.project;
2424
$scope.accessModes="ReadWriteOnce";
2525
$scope.claim = {};
@@ -38,6 +38,19 @@ angular.module('openshiftConsole')
3838
}
3939
];
4040

41+
var hideErrorNotifications = function() {
42+
NotificationsService.hideNotification("create-pvc-error");
43+
};
44+
45+
var navigateBack = function() {
46+
$window.history.back();
47+
};
48+
49+
$scope.cancel = function() {
50+
hideErrorNotifications();
51+
navigateBack();
52+
};
53+
4154
ProjectsService
4255
.get($routeParams.project)
4356
.then(_.spread(function(project, context) {
@@ -51,21 +64,27 @@ angular.module('openshiftConsole')
5164
}
5265

5366
$scope.createPersistentVolumeClaim = function() {
67+
hideErrorNotifications();
5468
if ($scope.createPersistentVolumeClaimForm.$valid) {
5569
$scope.disableInputs = true;
5670
var claim = generatePersistentVolumeClaim();
5771
DataService.create('persistentvolumeclaims', null, claim, context)
58-
.then(function() { // Success
59-
// Return to the previous page
60-
$window.history.back();
72+
.then(function(claim) { // Success
73+
NotificationsService.addNotification({
74+
type: "success",
75+
message: "Persistent volume claim " + claim.metadata.name + " successfully created."
76+
});
77+
78+
navigateBack();
6179
},
6280
function(result) { // Failure
6381
$scope.disableInputs = false;
64-
$scope.alerts['create-persistent-volume-claim'] = {
65-
type: "error",
66-
message: "An error occurred requesting storage claim.",
67-
details: $filter('getErrorDetails')(result)
68-
};
82+
NotificationsService.addNotification({
83+
id: "create-pvc-error",
84+
type: "error",
85+
message: "An error occurred requesting storage.",
86+
details: $filter('getErrorDetails')(result)
87+
});
6988
});
7089
}
7190
};

app/views/create-persistent-volume-claim.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>Create Storage</h1>
1817
<div class="help-block">
@@ -28,7 +27,7 @@ <h1>Create Storage</h1>
2827
ng-click="createPersistentVolumeClaim()"
2928
ng-disabled="createPersistentVolumeClaimForm.$invalid || disableInputs"
3029
value="">Create</button>
31-
<a class="btn btn-default btn-lg" href="" back>Cancel</a>
30+
<a class="btn btn-default btn-lg" href="" ng-click="cancel()" role="button">Cancel</a>
3231
</div>
3332
</fieldset>
3433
</form>

app/views/directives/osc-persistent-volume-claim.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
ng-pattern="nameValidation.pattern"
7070
ng-maxlength="nameValidation.maxlength"
7171
placeholder="my-storage-claim"
72+
take-focus
7273
select-on-focus
7374
autocorrect="off"
7475
autocapitalize="off"

dist/scripts/scripts.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8544,17 +8544,25 @@ kubernetes:c.VERSION.kubernetes
85448544
c.withUser(), a.cliDownloadURL = d.CLI, a.cliDownloadURLPresent = a.cliDownloadURL && !_.isEmpty(a.cliDownloadURL), a.loginBaseURL = b.openshiftAPIBaseUrl(), a.sessionToken = c.UserStore().getToken(), a.showSessionToken = !1, a.toggleShowSessionToken = function() {
85458545
a.showSessionToken = !a.showSessionToken;
85468546
};
8547-
} ]), angular.module("openshiftConsole").controller("CreatePersistentVolumeClaimController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "ProjectsService", "keyValueEditorUtils", function(a, b, c, d, e, f, g, h, i, j) {
8548-
c.alerts = {}, c.projectName = b.project, c.accessModes = "ReadWriteOnce", c.claim = {}, c.breadcrumbs = [ {
8547+
} ]), angular.module("openshiftConsole").controller("CreatePersistentVolumeClaimController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "keyValueEditorUtils", function(a, b, c, d, e, f, g, h, i, j, k) {
8548+
c.projectName = b.project, c.accessModes = "ReadWriteOnce", c.claim = {}, c.breadcrumbs = [ {
85498549
title:c.projectName,
85508550
link:"project/" + c.projectName
85518551
}, {
85528552
title:"Storage",
85538553
link:"project/" + c.projectName + "/browse/storage"
85548554
}, {
85558555
title:"Create Storage"
8556-
} ], i.get(b.project).then(_.spread(function(e, i) {
8557-
function k() {
8556+
} ];
8557+
var l = function() {
8558+
i.hideNotification("create-pvc-error");
8559+
}, m = function() {
8560+
d.history.back();
8561+
};
8562+
c.cancel = function() {
8563+
l(), m();
8564+
}, j.get(b.project).then(_.spread(function(d, e) {
8565+
function j() {
85588566
var a = {
85598567
kind:"PersistentVolumeClaim",
85608568
apiVersion:"v1",
@@ -8572,23 +8580,27 @@ requests:{}
85728580
a.spec.accessModes = [ c.claim.accessModes || "ReadWriteOnce" ];
85738581
var b = c.claim.unit || "Mi";
85748582
if (a.spec.resources.requests.storage = c.claim.amount + b, c.claim.selectedLabels) {
8575-
var d = j.mapEntries(j.compactEntries(c.claim.selectedLabels));
8583+
var d = k.mapEntries(k.compactEntries(c.claim.selectedLabels));
85768584
_.isEmpty(d) || _.set(a, "spec.selector.matchLabels", d);
85778585
}
85788586
return c.claim.storageClass && "No Storage Class" !== c.claim.storageClass.metadata.name && (a.metadata.annotations["volume.beta.kubernetes.io/storage-class"] = c.claim.storageClass.metadata.name), a;
85798587
}
8580-
return c.project = e, c.breadcrumbs[0].title = a("displayName")(e), f.canI("persistentvolumeclaims", "create", b.project) ? void (c.createPersistentVolumeClaim = function() {
8581-
if (c.createPersistentVolumeClaimForm.$valid) {
8588+
return c.project = d, c.breadcrumbs[0].title = a("displayName")(d), f.canI("persistentvolumeclaims", "create", b.project) ? void (c.createPersistentVolumeClaim = function() {
8589+
if (l(), c.createPersistentVolumeClaimForm.$valid) {
85828590
c.disableInputs = !0;
8583-
var b = k();
8584-
g.create("persistentvolumeclaims", null, b, i).then(function() {
8585-
d.history.back();
8591+
var b = j();
8592+
g.create("persistentvolumeclaims", null, b, e).then(function(a) {
8593+
i.addNotification({
8594+
type:"success",
8595+
message:"Persistent volume claim " + a.metadata.name + " successfully created."
8596+
}), m();
85868597
}, function(b) {
8587-
c.disableInputs = !1, c.alerts["create-persistent-volume-claim"] = {
8598+
c.disableInputs = !1, i.addNotification({
8599+
id:"create-pvc-error",
85888600
type:"error",
8589-
message:"An error occurred requesting storage claim.",
8601+
message:"An error occurred requesting storage.",
85908602
details:a("getErrorDetails")(b)
8591-
};
8603+
});
85928604
});
85938605
}
85948606
}) :void h.toErrorPage("You do not have authority to create persistent volume claims in project " + b.project + ".", "access_denied");

dist/scripts/templates.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4641,7 +4641,6 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
46414641
"<div class=\"row\">\n" +
46424642
"<div class=\"col-md-10 col-md-offset-1\">\n" +
46434643
"<breadcrumbs breadcrumbs=\"breadcrumbs\"></breadcrumbs>\n" +
4644-
"<alerts alerts=\"alerts\"></alerts>\n" +
46454644
"<div class=\"mar-top-xl\">\n" +
46464645
"<h1>Create Storage</h1>\n" +
46474646
"<div class=\"help-block\">\n" +
@@ -4653,7 +4652,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
46534652
"<osc-persistent-volume-claim model=\"claim\" project-name=\"projectName\"></osc-persistent-volume-claim>\n" +
46544653
"<div class=\"button-group gutter-bottom\">\n" +
46554654
"<button type=\"submit\" class=\"btn btn-primary btn-lg\" ng-click=\"createPersistentVolumeClaim()\" ng-disabled=\"createPersistentVolumeClaimForm.$invalid || disableInputs\" value=\"\">Create</button>\n" +
4656-
"<a class=\"btn btn-default btn-lg\" href=\"\" back>Cancel</a>\n" +
4655+
"<a class=\"btn btn-default btn-lg\" href=\"\" ng-click=\"cancel()\" role=\"button\">Cancel</a>\n" +
46574656
"</div>\n" +
46584657
"</fieldset>\n" +
46594658
"</form>\n" +
@@ -7707,7 +7706,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
77077706
"<div class=\"form-group\">\n" +
77087707
"<label for=\"claim-name\" class=\"required\">Name</label>\n" +
77097708
"<span ng-class=\"{ 'has-error': persistentVolumeClaimForm.name.$invalid && persistentVolumeClaimForm.name.$touched && !claimDisabled }\">\n" +
7710-
"<input id=\"claim-name\" class=\"form-control\" type=\"text\" name=\"name\" ng-model=\"claim.name\" ng-required=\"true\" ng-pattern=\"nameValidation.pattern\" ng-maxlength=\"nameValidation.maxlength\" placeholder=\"my-storage-claim\" select-on-focus autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" aria-describedby=\"claim-name-help\">\n" +
7709+
"<input id=\"claim-name\" class=\"form-control\" type=\"text\" name=\"name\" ng-model=\"claim.name\" ng-required=\"true\" ng-pattern=\"nameValidation.pattern\" ng-maxlength=\"nameValidation.maxlength\" placeholder=\"my-storage-claim\" take-focus select-on-focus autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" aria-describedby=\"claim-name-help\">\n" +
77117710
"</span>\n" +
77127711
"<div>\n" +
77137712
"<span id=\"claim-name-help\" class=\"help-block\">A unique name for the storage claim within the project.</span>\n" +

0 commit comments

Comments
 (0)