From 92c6610b879cae47f80452c9651408d4994c42b8 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Wed, 21 Apr 2021 13:40:24 +0100 Subject: [PATCH] Improve Role Required Indicators/Validation - RBAC Role type improvements - Remove rule 'Non-Resource URL' field. RBAC role type is namespaced, non-resource url's are not. - Apply additional validation ( - rule resource AND api group required, rather than default rule resource, non-resource url or api group required - name is required - Show Required indicator for all fields (reflecting validation) - Other Role type improvements - Show Required indicator for rule Verbs field - This does mean that when the page initially loads we show an empty rule row with required fields... but user can ignore this and successfully save the role anyway. The alternative is to not show an empty rule to begin with... but this forces the user to `Add Resource`. I feel the later is more of an issue than the former. - name is required --- assets/translations/en-us.yaml | 4 ++- components/auth/RoleDetailEdit.vue | 35 ++++++++++++++------- models/management.cattle.io.globalrole.js | 10 ++---- models/management.cattle.io.roletemplate.js | 10 ++---- models/rbac.authorization.k8s.io.role.js | 9 +++++- utils/validators/role-template.js | 14 +++++++-- 6 files changed, 50 insertions(+), 32 deletions(-) diff --git a/assets/translations/en-us.yaml b/assets/translations/en-us.yaml index 1595e523933..126a7fd00f9 100644 --- a/assets/translations/en-us.yaml +++ b/assets/translations/en-us.yaml @@ -3139,7 +3139,9 @@ validation: roleTemplate: roleTemplateRules: missingVerb: You must specify at least one verb for each resource grant - missingResource: You must specify at least one Resource, Non-Resource URL or API Group for each resource grant + missingResource: You must specify a Resource for each resource grant + missingApiGroup: You must specify an API Group for each resource grant + missingOneResource: You must specify at least one Resource, Non-Resource URL or API Group for each resource grant service: externalName: none: External Name is required on an ExternalName Service. diff --git a/components/auth/RoleDetailEdit.vue b/components/auth/RoleDetailEdit.vue index 0d9be2bcab9..cf32873f992 100644 --- a/components/auth/RoleDetailEdit.vue +++ b/components/auth/RoleDetailEdit.vue @@ -156,6 +156,9 @@ export default { doneLocationOverride() { return this.value.listLocation; }, + ruleClass() { + return `col ${ this.isNamespaced ? 'span-4' : 'span-3' }`; + }, // Detail View rules() { return this.createRules(this.value); @@ -374,23 +377,29 @@ export default { >