Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions app/scripts/controllers/membership.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,30 @@ angular

var allRoles = [];

// NOTE: these could all be moved out into a strings service.
var messages = {
errorReason: _.template('Reason: "<%- httpErr %>"'),
notice: {
yourLastRole: _.template('Removing the role "<%- roleName %>" may completely remove your ability to see this project.')
yourLastRole: _.template('Removing the role "<%= roleName %>" may completely remove your ability to see this project.')
},
warning: {
serviceAccount: _.template('Removing a system role granted to a service account may cause unexpected behavior.')
},
remove: {
areYouSure: {
subject: _.template('Are you sure you want to remove <strong><%- roleName %></strong> from the <%- kindName %> <strong><%- subjectName %></strong>?'),
self: _.template('Are you sure you want to remove <strong><%- roleName %></strong> from <strong><%- subjectName %></strong> (you)?')
html: {
subject: _.template('Are you sure you want to remove <strong><%- roleName %></strong> from the <%- kindName %> <strong><%- subjectName %></strong>?'),
self: _.template('Are you sure you want to remove <strong><%- roleName %></strong> from <strong><%- subjectName %></strong> (you)?')
}
},
success: _.template('The role "<%- roleName %>" was removed from "<%- subjectName %>".'),
error: _.template('The role "<%- roleName %>" was not removed from "<%- subjectName %>".')
success: _.template('The role "<%= roleName %>" was removed from "<%= subjectName %>".'),
error: _.template('The role "<%= roleName %>" was not removed from "<%= subjectName %>".')
},
update: {
subject: {
success: _.template('The role "<%- roleName %>" was given to "<%- subjectName %>".'),
error: _.template('The role "<%- roleName %>" was not given to "<%- subjectName %>".')
success: _.template('The role "<%= roleName %>" was given to "<%= subjectName %>".'),
error: _.template('The role "<%= roleName %>" was not given to "<%= subjectName %>".')
}
}
},
errorReason: _.template('Reason: "<%= httpErr %>"')
};

// NOTE: alert service?
Expand Down Expand Up @@ -90,13 +91,13 @@ angular
refreshRoleBindingList();
showAlert('rolebindingCreate', 'success', messages.update.subject.success({
roleName: role.metadata.name,
subjectName: _.escape(newSubject.name)
subjectName: newSubject.name
}));
}, function(err) {
resetForm();
showAlert('rolebindingCreateFail', 'error', messages.update.subject.error({
roleName: role.metadata.name,
subjectName: _.escape(newSubject.name)
subjectName: newSubject.name
}), messages.errorReason({httpErr: $filter('getErrorDetails')(err)}));
});
};
Expand All @@ -110,13 +111,13 @@ angular
refreshRoleBindingList();
showAlert('rolebindingUpdate', 'success', messages.update.subject.success({
roleName: rb.roleRef.name,
subjectName: _.escape(newSubject.name)
subjectName: newSubject.name
}));
}, function(err) {
resetForm();
showAlert('rolebindingUpdateFail', 'error', messages.update.subject.error({
roleName: rb.roleRef.name,
subjectName: _.escape(newSubject.name)
subjectName: newSubject.name
}), messages.errorReason({httpErr: $filter('getErrorDetails')(err)}));
});
};
Expand Down Expand Up @@ -177,19 +178,19 @@ angular
var createModalScope = function(subjectName, kind, roleName, currentUserName) {
var modalScope = {
alerts: {},
detailsMarkup: messages.remove.areYouSure.subject({
detailsMarkup: messages.remove.areYouSure.html.subject({
roleName: roleName,
kindName: humanizeKind(kind),
subjectName: _.escape(subjectName)
subjectName: subjectName
}),
okButtonText: 'Remove',
okButtonClass: 'btn-danger',
cancelButtonText: 'Cancel'
};
if(_.isEqual(subjectName, currentUserName)) {
modalScope.details = messages.remove.areYouSure.self({
modalScope.detailsMarkup = messages.remove.areYouSure.html.self({
roleName: roleName,
subjectName: _.escape(subjectName)
subjectName: subjectName
});
if(MembershipService.isLastRole($scope.user.metadata.name, $scope.roleBindings)) {
showAlert('currentUserLastRole', 'error', messages.notice.yourLastRole({roleName: roleName}), null, modalScope);
Expand Down Expand Up @@ -252,13 +253,13 @@ angular
refreshRoleBindingList();
showAlert('rolebindingUpdate', 'success', messages.remove.success({
roleName: roleName,
subjectName: _.escape(subjectName)
subjectName: subjectName
}));
}
}, function(err) {
showAlert('rolebindingUpdateFail', 'error', messages.remove.error({
roleName: roleName,
subjectName: _.escape(subjectName)
subjectName: subjectName
}), messages.errorReason({
httpErr: $filter('getErrorDetails')(err)
}));
Expand Down
36 changes: 19 additions & 17 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4775,27 +4775,29 @@ a !== b && (localStorage.setItem("monitoring.eventsidebar.collapsed", c.renderOp
}));
} ]), angular.module("openshiftConsole").controller("MembershipController", [ "$filter", "$location", "$routeParams", "$scope", "$timeout", "$uibModal", "AuthService", "AuthorizationService", "DataService", "ProjectsService", "MembershipService", "RoleBindingsService", "RolesService", function(a, b, c, d, e, f, g, h, i, j, k, l, m) {
var n, o = c.project, p = a("humanizeKind"), q = a("annotation"), r = [], s = {
errorReason:_.template('Reason: "<%- httpErr %>"'),
notice:{
yourLastRole:_.template('Removing the role "<%- roleName %>" may completely remove your ability to see this project.')
yourLastRole:_.template('Removing the role "<%= roleName %>" may completely remove your ability to see this project.')
},
warning:{
serviceAccount:_.template("Removing a system role granted to a service account may cause unexpected behavior.")
},
remove:{
areYouSure:{
html:{
subject:_.template("Are you sure you want to remove <strong><%- roleName %></strong> from the <%- kindName %> <strong><%- subjectName %></strong>?"),
self:_.template("Are you sure you want to remove <strong><%- roleName %></strong> from <strong><%- subjectName %></strong> (you)?")
}
},
success:_.template('The role "<%- roleName %>" was removed from "<%- subjectName %>".'),
error:_.template('The role "<%- roleName %>" was not removed from "<%- subjectName %>".')
success:_.template('The role "<%= roleName %>" was removed from "<%= subjectName %>".'),
error:_.template('The role "<%= roleName %>" was not removed from "<%= subjectName %>".')
},
update:{
subject:{
success:_.template('The role "<%- roleName %>" was given to "<%- subjectName %>".'),
error:_.template('The role "<%- roleName %>" was not given to "<%- subjectName %>".')
}
success:_.template('The role "<%= roleName %>" was given to "<%= subjectName %>".'),
error:_.template('The role "<%= roleName %>" was not given to "<%= subjectName %>".')
}
},
errorReason:_.template('Reason: "<%= httpErr %>"')
}, t = function(a, b, c, e, f) {
f = f || d, f.alerts[a] = {
type:b,
Expand All @@ -4818,12 +4820,12 @@ errorNotification:!1
d.disableAddForm = !0, l.create(b, c, o, n).then(function() {
u(), v(), t("rolebindingCreate", "success", s.update.subject.success({
roleName:b.metadata.name,
subjectName:_.escape(c.name)
subjectName:c.name
}));
}, function(d) {
u(), t("rolebindingCreateFail", "error", s.update.subject.error({
roleName:b.metadata.name,
subjectName:_.escape(c.name)
subjectName:c.name
}), s.errorReason({
httpErr:a("getErrorDetails")(d)
}));
Expand All @@ -4832,12 +4834,12 @@ httpErr:a("getErrorDetails")(d)
d.disableAddForm = !0, l.addSubject(b, c, e, n).then(function() {
u(), v(), t("rolebindingUpdate", "success", s.update.subject.success({
roleName:b.roleRef.name,
subjectName:_.escape(c.name)
subjectName:c.name
}));
}, function(d) {
u(), t("rolebindingUpdateFail", "error", s.update.subject.error({
roleName:b.roleRef.name,
subjectName:_.escape(c.name)
subjectName:c.name
}), s.errorReason({
httpErr:a("getErrorDetails")(d)
}));
Expand Down Expand Up @@ -4887,18 +4889,18 @@ return a ? e + (q(a, "description") || b) :b;
var A = function(a, b, c, e) {
var f = {
alerts:{},
detailsMarkup:s.remove.areYouSure.subject({
detailsMarkup:s.remove.areYouSure.html.subject({
roleName:c,
kindName:p(b),
subjectName:_.escape(a)
subjectName:a
}),
okButtonText:"Remove",
okButtonClass:"btn-danger",
cancelButtonText:"Cancel"
};
return _.isEqual(a, e) && (f.details = s.remove.areYouSure.self({
return _.isEqual(a, e) && (f.detailsMarkup = s.remove.areYouSure.html.self({
roleName:c,
subjectName:_.escape(a)
subjectName:a
}), k.isLastRole(d.user.metadata.name, d.roleBindings) && t("currentUserLastRole", "error", s.notice.yourLastRole({
roleName:c
}), null, f)), _.isEqual(b, "ServiceAccount") && _.startsWith(c, "system:") && t("editingServiceAccountRole", "error", s.warning.serviceAccount(), null, f), f;
Expand Down Expand Up @@ -4930,12 +4932,12 @@ return i;
l.removeSubject(c, g, d.roleBindings, n).then(function() {
h ? b.url("./") :(v(), t("rolebindingUpdate", "success", s.remove.success({
roleName:g,
subjectName:_.escape(c)
subjectName:c
})));
}, function(b) {
t("rolebindingUpdateFail", "error", s.remove.error({
roleName:g,
subjectName:_.escape(c)
subjectName:c
}), s.errorReason({
httpErr:a("getErrorDetails")(b)
}));
Expand Down