feat: update role detail page

1. Update TabDetail to support fetch api when router change
2. Update role detail page: show implied roles in detail page

Change-Id: I99cf7510c30d3924a7f7281f3d5fb3f6db67bd4d
This commit is contained in:
Jingwei.Zhang 2022-06-22 16:56:52 +08:00
parent b1591a9a56
commit e86bff5f0f
7 changed files with 33 additions and 144 deletions

View File

@ -47,6 +47,13 @@ export default class DetailBase extends React.Component {
this.fetchDataWithPolicy();
}
componentDidUpdate(prevProps) {
const { id: oldId } = prevProps.match.params;
if (this.id !== oldId) {
this.handleRefresh(true);
}
}
get params() {
return this.props.match.params || {};
}

View File

@ -76,7 +76,6 @@
"Additional routes announced to the instance, one entry per line(e.g. 192.168.200.0/24,10.56.1.254)": "Additional routes announced to the instance, one entry per line(e.g. 192.168.200.0/24,10.56.1.254)",
"Additional routes announced to the instance, one entry per line(e.g. {ip})": "Additional routes announced to the instance, one entry per line(e.g. {ip})",
"Addresses": "Addresses",
"Admin": "Admin",
"Admin State": "Admin State",
"Admin Status": "Admin Status",
"Administrator": "Administrator",
@ -246,7 +245,6 @@
"Block Device Mapping": "Block Device Mapping",
"Block Migrate": "Block Migrate",
"Block Storage Services": "Block Storage Services",
"Block Storage service:": "Block Storage service:",
"Blocked": "Blocked",
"Bolivia": "Bolivia",
"Boot Device": "Boot Device",
@ -394,7 +392,6 @@
"Compute Stop Instance": "Compute Stop Instance",
"Compute Suspend Instance": "Compute Suspend Instance",
"Compute Unpause Instance": "Compute Unpause Instance",
"Compute service:": "Compute service:",
"Conductor Live Migrate Instance": "Conductor Live Migrate Instance",
"Conductor Live Resize Instance": "Conductor Live Resize Instance",
"Conductor Migrate Server": "Conductor Migrate Server",
@ -1084,7 +1081,6 @@
"Iceland": "Iceland",
"Identifier of the physical port on the switch to which nodes port is connected to": "Identifier of the physical port on the switch to which nodes port is connected to",
"Identity": "Identity",
"Identity service:": "Identity service:",
"If \"Enable\" fails to roll back, the resource will be deleted after the creation fails; if \"Disable\" fails to roll back, the resource will be retained after the creation fails.": "If \"Enable\" fails to roll back, the resource will be deleted after the creation fails; if \"Disable\" fails to roll back, the resource will be retained after the creation fails.",
"If OS is Linux, system will reset root password, if OS is Windows, system will reset Administrator password.": "If OS is Linux, system will reset root password, if OS is Windows, system will reset Administrator password.",
"If an instance is using this flavor, deleting it will cause the instance's flavor data to be missing. Are you sure to delete {name}?": "If an instance is using this flavor, deleting it will cause the instance's flavor data to be missing. Are you sure to delete {name}?",
@ -1114,9 +1110,9 @@
"Image Size": "Image Size",
"Image Snapshot Pending": "Image Snapshot Pending",
"Image Uploading": "Image Uploading",
"Image service:": "Image service:",
"Immediate effect": "Immediate effect",
"Immediately delete": "Immediately delete",
"Implied Roles": "Implied Roles",
"Import Keypair": "Import Keypair",
"Import Metadata": "Import Metadata",
"Import metadata": "Import metadata",
@ -1483,7 +1479,6 @@
"Network topology page": "Network topology page",
"Networking": "Networking",
"Networking *": "Networking *",
"Networking service:": "Networking service:",
"Networks": "Networks",
"Neutron Agent Detail": "Neutron Agent Detail",
"Neutron Agents": "Neutron Agents",
@ -1580,7 +1575,6 @@
"Orchestration": "Orchestration",
"Orchestration Services": "Orchestration Services",
"Orchestration information": "Orchestration information",
"Orchestration service:": "Orchestration service:",
"Origin File Name": "Origin File Name",
"Original Password": "Original Password",
"Other Protocol": "Other Protocol",
@ -1651,7 +1645,6 @@
"Physical Node": "Physical Node",
"Physical Storage Usage": "Physical Storage Usage",
"Pitcairn": "Pitcairn",
"Placement service:": "Placement service:",
"Platform Info": "Platform Info",
"Please confirm your password!": "Please confirm your password!",
"Please enter JSON in the correct format!": "Please enter JSON in the correct format!",
@ -1767,16 +1760,13 @@
"Profile": "Profile",
"Progress": "Progress",
"Project": "Project",
"Project Admin": "Project Admin",
"Project Detail": "Project Detail",
"Project ID": "Project ID",
"Project ID/Name": "Project ID/Name",
"Project Member": "Project Member",
"Project Name": "Project Name",
"Project Num": "Project Num",
"Project Quota": "Project Quota",
"Project Range": "Project Range",
"Project Reader": "Project Reader",
"Project Scope": "Project Scope",
"Project Scope (Project Name: Role Names)": "Project Scope (Project Name: Role Names)",
"Project User": "Project User",
@ -1837,7 +1827,6 @@
"Read And Write": "Read And Write",
"Read and write": "Read and write",
"Read only": "Read only",
"Reader": "Reader",
"Real Name": "Real Name",
"Reason": "Reason",
"Reason: ": "Reason: ",
@ -1922,7 +1911,6 @@
"Role": "Role",
"Role Detail": "Role Detail",
"Role Name": "Role Name",
"Role Power": "Role Power",
"Roles": "Roles",
"Rollback Complete": "Rollback Complete",
"Rollback Failed": "Rollback Failed",
@ -2174,12 +2162,10 @@
"Syncing": "Syncing",
"Syrian Arab Republic": "Syrian Arab Republic",
"System": "System",
"System Admin": "System Admin",
"System Config": "System Config",
"System Disk": "System Disk",
"System Info": "System Info",
"System Load": "System Load",
"System Reader": "System Reader",
"System Roles": "System Roles",
"System Running Time": "System Running Time",
"System is error, please try again later.": "System is error, please try again later.",

View File

@ -76,7 +76,6 @@
"Additional routes announced to the instance, one entry per line(e.g. 192.168.200.0/24,10.56.1.254)": "云主机额外路由,每行一条(例如: 192.168.200.0/24,10.56.1.254)",
"Additional routes announced to the instance, one entry per line(e.g. {ip})": "云主机额外路由,每行一条(例如: {ip})",
"Addresses": "地址",
"Admin": "管理员",
"Admin State": "管理状态",
"Admin Status": "管理状态",
"Administrator": "管理平台",
@ -246,7 +245,6 @@
"Block Device Mapping": "创建块设备中",
"Block Migrate": "块迁移",
"Block Storage Services": "块存储服务",
"Block Storage service:": "块存储服务(cinder):",
"Blocked": "",
"Bolivia": "玻利维亚",
"Boot Device": "引导设备",
@ -394,7 +392,6 @@
"Compute Stop Instance": "关闭",
"Compute Suspend Instance": "云主机挂起",
"Compute Unpause Instance": "恢复",
"Compute service:": "计算服务(nova):",
"Conductor Live Migrate Instance": "执行热迁移实例",
"Conductor Live Resize Instance": "执行在线配置调整",
"Conductor Migrate Server": "执行迁移服务器",
@ -1084,7 +1081,6 @@
"Iceland": "冰岛",
"Identifier of the physical port on the switch to which nodes port is connected to": "节点端口所连接的交换机物理端口ID",
"Identity": "身份管理",
"Identity service:": "身份服务(keystone):",
"If \"Enable\" fails to roll back, the resource will be deleted after the creation fails; if \"Disable\" fails to roll back, the resource will be retained after the creation fails.": "若“启用”失败回滚,创建失败后会删除资源;若“禁用”失败回滚,创建失败后会保留资源。",
"If OS is Linux, system will reset root password, if OS is Windows, system will reset Administrator password.": "如果操作系统是Linux系统会修改root用户密码如果是Windows系统会修改Administrator用户密码。",
"If an instance is using this flavor, deleting it will cause the instance's flavor data to be missing. Are you sure to delete {name}?": "若有云主机正在使用此 flavor删除会导致云主机的 flavor 数据缺失,确定删除 {name} ",
@ -1114,9 +1110,9 @@
"Image Size": "镜像大小",
"Image Snapshot Pending": "镜像快照等待上传",
"Image Uploading": "镜像上传中",
"Image service:": "镜像服务(glance):",
"Immediate effect": "即时生效",
"Immediately delete": "立即删除",
"Implied Roles": "隐含角色",
"Import Keypair": "导入密钥",
"Import Metadata": "导入元数据",
"Import metadata": "导入元数据",
@ -1483,7 +1479,6 @@
"Network topology page": "网络拓扑页面",
"Networking": "创建网络中",
"Networking *": "网络 *",
"Networking service:": "网络服务(neutron):",
"Networks": "网络",
"Neutron Agent Detail": "网络服务详情",
"Neutron Agents": "网络服务",
@ -1580,7 +1575,6 @@
"Orchestration": "资源编排",
"Orchestration Services": "编排服务",
"Orchestration information": "编排信息",
"Orchestration service:": "编排服务(heat):",
"Origin File Name": "原始文件名称",
"Original Password": "原始密码",
"Other Protocol": "其他协议",
@ -1651,7 +1645,6 @@
"Physical Node": "物理节点",
"Physical Storage Usage": "物理存储使用量",
"Pitcairn": "皮特凯恩岛",
"Placement service:": "放置服务(placement):",
"Platform Info": "平台概况",
"Please confirm your password!": "请确认您的密码",
"Please enter JSON in the correct format!": "请输入正确格式的JSON",
@ -1767,16 +1760,13 @@
"Profile": "概要",
"Progress": "进度",
"Project": "项目",
"Project Admin": "项目管理权限",
"Project Detail": "项目详情",
"Project ID": "项目ID",
"Project ID/Name": "项目ID/名称",
"Project Member": "项目使用权限",
"Project Name": "项目名称",
"Project Num": "项目数量",
"Project Quota": "项目配额",
"Project Range": "项目范围",
"Project Reader": "项目只读权限",
"Project Scope": "所属项目",
"Project Scope (Project Name: Role Names)": "所属项目(项目名称:角色名称)",
"Project User": "项目用户",
@ -1837,7 +1827,6 @@
"Read And Write": "",
"Read and write": "可读可写",
"Read only": "只读",
"Reader": "只读",
"Real Name": "真实姓名",
"Reason": "原因",
"Reason: ": "原因:",
@ -1922,7 +1911,6 @@
"Role": "角色",
"Role Detail": "角色详情",
"Role Name": "角色名称",
"Role Power": "角色权限",
"Roles": "角色",
"Rollback Complete": "回滚完成",
"Rollback Failed": "回滚失败",
@ -2174,12 +2162,10 @@
"Syncing": "同步中",
"Syrian Arab Republic": "叙利亚",
"System": "系统",
"System Admin": "系统管理权限",
"System Config": "系统配置",
"System Disk": "系统盘",
"System Info": "系统信息",
"System Load": "系统负载",
"System Reader": "系统只读权限",
"System Roles": "系统角色",
"System Running Time": "",
"System is error, please try again later.": "系统出错,请稍后再试。",

View File

@ -12,31 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import React from 'react';
import { inject, observer } from 'mobx-react';
import globalRoleStore from 'stores/keystone/role';
import Base from 'containers/BaseDetail';
import { toJS } from 'mobx';
import rolePermission from 'resources/keystone/role';
export class BaseDetail extends Base {
init() {
this.store = globalRoleStore;
}
fetchData = (params) => {
const { id } = this.props.match.params;
this.store
.fetchImpliedRoles({
id,
...params,
})
.catch(this.catch);
};
get detailData() {
return toJS(this.store.implyRoles);
}
get leftCards() {
const cards = [this.roleCard];
return cards;
@ -45,61 +25,24 @@ export class BaseDetail extends Base {
get roleCard() {
const options = [
{
label: t('Compute service:'),
dataIndex: 'nova',
label: t('Roles'),
dataIndex: 'implies',
render: (value) => {
return rolePermission[value] || '-';
},
},
{
label: t('Block Storage service:'),
dataIndex: 'cinder',
render: (value) => {
return rolePermission[value] || '-';
},
},
{
label: t('Networking service:'),
dataIndex: 'neutron',
render: (value) => {
return rolePermission[value] || '-';
},
},
{
label: t('Image service:'),
dataIndex: 'glance',
render: (value) => {
return rolePermission[value] || '-';
},
},
{
label: t('Placement service:'),
dataIndex: 'placement',
render: (value) => {
return rolePermission[value] || '-';
},
},
{
label: t('Orchestration service:'),
dataIndex: 'heat',
render: (value) => {
return rolePermission[value] || '-';
},
},
{
label: t('Identity service:'),
dataIndex: 'keystone',
render: (value) => {
return rolePermission[value] || '-';
if (!value || !value.length) {
return '-';
}
return value.map((it) => {
const { id, name } = it;
const link = this.getLinkRender('roleDetail', name, { id });
return <div key={id}>{link}</div>;
});
},
},
];
return {
title: t('Resource'),
title: t('Implied Roles'),
options,
labelCol: 12,
contentCol: 12,
};
}
}

View File

@ -17,7 +17,7 @@ import { RoleStore } from 'stores/keystone/role';
import Base from 'containers/TabDetail';
import User from '../../User';
import Group from '../../UserGroup';
import impliedRole from './BaseDetail';
import BaseDetail from './BaseDetail';
import actionConfigs from '../actions';
export class RoleDetail extends Base {
@ -57,9 +57,9 @@ export class RoleDetail extends Base {
get tabs() {
const tabs = [
{
title: t('Role Power'),
key: 'role',
component: impliedRole,
title: t('Base Info'),
key: 'base',
component: BaseDetail,
},
{
title: t('Binding User'),

View File

@ -12,17 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
const rolePermission = {
project_admin: t('Project Admin'),
project_reader: t('Project Reader'),
project_member: t('Project Member'),
system_admin: t('System Admin'),
system_reader: t('System Reader'),
admin: t('Admin'),
reader: t('Reader'),
member: t('Member'),
};
export const editable = (item) => {
const { options: { immutable } = {} } = item || {};
if (immutable || immutable === 'true' || immutable === 'True') {
@ -30,5 +19,3 @@ export const editable = (item) => {
}
return true;
};
export default rolePermission;

View File

@ -28,34 +28,14 @@ export class RoleStore extends Base {
@observable
systemRoles = new List();
@action
async fetchImpliedRoles({ id }) {
const rolesResult = await this.client.implies.list(id);
const {
role_inference: { implies },
} = rolesResult;
const sources = [
'nova',
'neutron',
'glance',
'placement',
'heat',
'keystone',
'cinder',
];
const sourceRole = {};
sources.forEach((source) => {
const roles = [];
implies.forEach((it) => {
if (it.name.indexOf(source) !== -1) {
const role = it.name.split(`${source}_`)[1];
roles.push(role);
}
});
sourceRole[source] = roles;
});
this.isLoading = false;
this.implyRoles = sourceRole;
async detailDidFetch(item) {
const { id } = item;
const { role_inference: { implies = [] } = {} } =
await this.client.implies.list(id);
return {
...item,
implies,
};
}
checkSystemRole = (roleItem) => {