Skip to content

Commit 1f2c340

Browse files
author
OpenShift Bot
authored
Merge pull request #1659 from spadgett/create-pvc-toast
Merged by openshift-bot
2 parents a33749d + 2059a4d commit 1f2c340

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
@@ -8555,17 +8555,25 @@ kubernetes:c.VERSION.kubernetes
85558555
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() {
85568556
a.showSessionToken = !a.showSessionToken;
85578557
};
8558-
} ]), 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) {
8559-
c.alerts = {}, c.projectName = b.project, c.accessModes = "ReadWriteOnce", c.claim = {}, c.breadcrumbs = [ {
8558+
} ]), 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) {
8559+
c.projectName = b.project, c.accessModes = "ReadWriteOnce", c.claim = {}, c.breadcrumbs = [ {
85608560
title:c.projectName,
85618561
link:"project/" + c.projectName
85628562
}, {
85638563
title:"Storage",
85648564
link:"project/" + c.projectName + "/browse/storage"
85658565
}, {
85668566
title:"Create Storage"
8567-
} ], i.get(b.project).then(_.spread(function(e, i) {
8568-
function k() {
8567+
} ];
8568+
var l = function() {
8569+
i.hideNotification("create-pvc-error");
8570+
}, m = function() {
8571+
d.history.back();
8572+
};
8573+
c.cancel = function() {
8574+
l(), m();
8575+
}, j.get(b.project).then(_.spread(function(d, e) {
8576+
function j() {
85698577
var a = {
85708578
kind:"PersistentVolumeClaim",
85718579
apiVersion:"v1",
@@ -8583,23 +8591,27 @@ requests:{}
85838591
a.spec.accessModes = [ c.claim.accessModes || "ReadWriteOnce" ];
85848592
var b = c.claim.unit || "Mi";
85858593
if (a.spec.resources.requests.storage = c.claim.amount + b, c.claim.selectedLabels) {
8586-
var d = j.mapEntries(j.compactEntries(c.claim.selectedLabels));
8594+
var d = k.mapEntries(k.compactEntries(c.claim.selectedLabels));
85878595
_.isEmpty(d) || _.set(a, "spec.selector.matchLabels", d);
85888596
}
85898597
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;
85908598
}
8591-
return c.project = e, c.breadcrumbs[0].title = a("displayName")(e), f.canI("persistentvolumeclaims", "create", b.project) ? void (c.createPersistentVolumeClaim = function() {
8592-
if (c.createPersistentVolumeClaimForm.$valid) {
8599+
return c.project = d, c.breadcrumbs[0].title = a("displayName")(d), f.canI("persistentvolumeclaims", "create", b.project) ? void (c.createPersistentVolumeClaim = function() {
8600+
if (l(), c.createPersistentVolumeClaimForm.$valid) {
85938601
c.disableInputs = !0;
8594-
var b = k();
8595-
g.create("persistentvolumeclaims", null, b, i).then(function() {
8596-
d.history.back();
8602+
var b = j();
8603+
g.create("persistentvolumeclaims", null, b, e).then(function(a) {
8604+
i.addNotification({
8605+
type:"success",
8606+
message:"Persistent volume claim " + a.metadata.name + " successfully created."
8607+
}), m();
85978608
}, function(b) {
8598-
c.disableInputs = !1, c.alerts["create-persistent-volume-claim"] = {
8609+
c.disableInputs = !1, i.addNotification({
8610+
id:"create-pvc-error",
85998611
type:"error",
8600-
message:"An error occurred requesting storage claim.",
8612+
message:"An error occurred requesting storage.",
86018613
details:a("getErrorDetails")(b)
8602-
};
8614+
});
86038615
});
86048616
}
86058617
}) :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)