From e4a54fe375a8e880f76be52971322f9541b753b8 Mon Sep 17 00:00:00 2001 From: Mr Forest Date: Mon, 10 Oct 2022 00:53:55 +0800 Subject: [PATCH] fix: disable roles inputbox when model doesn't support RBAC (#1201) * feat:Support simple ldap server * fix:fix review problems * fix:fix review problems * fix: fix ldapserver crash bug * Update ldapserver.go * fix: fix dulpicate go routines * fix gofumpt problems * fix: fix UserList error * feat:disable 'sub role' when model is incorrect * feat:disable 'sub role' when model is incorrect * feat:disable 'sub role' when model is incorrect * delete useless output * update func name * Update PermissionEditPage.js * Update PermissionEditPage.js Co-authored-by: Yang Luo --- web/src/PermissionEditPage.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/web/src/PermissionEditPage.js b/web/src/PermissionEditPage.js index 70719b27..c4c7f372 100644 --- a/web/src/PermissionEditPage.js +++ b/web/src/PermissionEditPage.js @@ -35,6 +35,7 @@ class PermissionEditPage extends React.Component { permissionName: props.match.params.permissionName, permission: null, organizations: [], + model: null, users: [], roles: [], models: [], @@ -59,6 +60,7 @@ class PermissionEditPage extends React.Component { this.getRoles(permission.owner); this.getModels(permission.owner); this.getResources(permission.owner); + this.getModel(permission.owner, permission.model); }); } @@ -98,6 +100,15 @@ class PermissionEditPage extends React.Component { }); } + getModel(organizationName, modelName) { + ModelBackend.getModel(organizationName, modelName) + .then((res) => { + this.setState({ + model: res, + }); + }); + } + getResources(organizationName) { ApplicationBackend.getApplicationsByOrganization("admin", organizationName) .then((res) => { @@ -115,6 +126,10 @@ class PermissionEditPage extends React.Component { } updatePermissionField(key, value) { + if (key === "model") { + this.getModel(this.state.permission.owner, value); + } + value = this.parsePermissionField(key, value); const permission = this.state.permission; @@ -124,6 +139,13 @@ class PermissionEditPage extends React.Component { }); } + hasRoleDefinition(model) { + if (model !== null) { + return model.modelText.includes("role_definition"); + } + return false; + } + renderPermission() { return ( - {this.updatePermissionField("roles", value);})}> { this.state.roles.filter(roles => (roles.owner !== this.state.roles.owner || roles.name !== this.state.roles.name)).map((permission, index) => ) }