refactor: remove the basic role display from the overview page

1. remove the basic role display from the overview page: because the api removed the base role information[1]
2. fix the title i18n

[1] I461ae3f8979377ae22ec851bf3315e509b22cfbd

Change-Id: Ib0e1ed51010c68dac64159a6154e65399f46a14d
This commit is contained in:
Jingwei.Zhang 2022-08-18 09:41:40 +08:00
parent 5d457caf83
commit 832cce176c
5 changed files with 13 additions and 80 deletions

View File

@ -226,7 +226,6 @@
"BareMetal Parameters": "BareMetal Parameters",
"Base Config": "Base Config",
"Base Info": "Base Info",
"Base Role": "Base Role",
"Basic Parameters": "Basic Parameters",
"Batch Allocate": "Batch Allocate",
"Belarus": "Belarus",
@ -239,6 +238,7 @@
"Bind Device": "Bind Device",
"Bind Device Type": "Bind Device Type",
"Bind Resource": "Bind Resource",
"Bind Resource Name": "Bind Resource Name",
"Binding": "Binding",
"Binding Groups": "Binding Groups",
"Binding Instance": "Binding Instance",
@ -1049,6 +1049,7 @@
"HealthMonitor Type": "HealthMonitor Type",
"Healthy": "Healthy",
"Heartbeat Timestamp": "Heartbeat Timestamp",
"Hello, {name}": "Hello, {name}",
"Heterogeneous Computing": "Heterogeneous Computing",
"Hidden": "Hidden",
"Hide Advanced Options": "Hide Advanced Options",

View File

@ -226,7 +226,6 @@
"BareMetal Parameters": "裸机参数",
"Base Config": "基础配置",
"Base Info": "基本信息",
"Base Role": "基础角色",
"Basic Parameters": "基本参数",
"Batch Allocate": "批量申请",
"Belarus": "白俄罗斯",
@ -239,6 +238,7 @@
"Bind Device": "绑定设备",
"Bind Device Type": "绑定设备类型",
"Bind Resource": "绑定资源",
"Bind Resource Name": "绑定资源名称",
"Binding": "绑定",
"Binding Groups": "绑定的用户组",
"Binding Instance": "绑定云主机",
@ -1049,6 +1049,7 @@
"HealthMonitor Type": "健康检查类型",
"Healthy": "健康",
"Heartbeat Timestamp": "心跳时间戳",
"Hello, {name}": "您好,{name}",
"Heterogeneous Computing": "异构计算",
"Hidden": "隐藏",
"Hide Advanced Options": "隐藏高级选项",

View File

@ -13,33 +13,11 @@
// limitations under the License.
import React, { Component } from 'react';
import { Card, Descriptions, Button } from 'antd';
import { Card, Descriptions } from 'antd';
import { inject, observer } from 'mobx-react';
import { UpOutlined, DownOutlined } from '@ant-design/icons';
import styles from '../style.less';
export class ProjectInfo extends Component {
constructor(props) {
super(props);
this.state = {
collapsed: true,
};
}
onCollapsedCallback = () => {};
handleDetailInfo = () => {
const { collapsed } = this.state;
this.setState(
{
collapsed: !collapsed,
},
() => {
this.onCollapsedCallback(!collapsed);
}
);
};
get rootStore() {
return this.props.rootStore || {};
}
@ -49,14 +27,9 @@ export class ProjectInfo extends Component {
return user || {};
}
get showRoles() {
const { roles = [], baseRoles = [] } = this.rootStore;
return roles.filter((it) => baseRoles.indexOf(it.name) === -1);
}
get baseRoles() {
const { roles = [], baseRoles = [] } = this.rootStore;
return roles.filter((it) => baseRoles.indexOf(it.name) !== -1);
get roles() {
const { roles = [] } = this.rootStore;
return roles;
}
renderAccount() {
@ -71,14 +44,14 @@ export class ProjectInfo extends Component {
);
}
renderShowRole() {
renderRoles() {
return (
<Descriptions.Item
label={t('My Role')}
labelStyle={{ fontSize: 14 }}
contentStyle={{ fontSize: 14 }}
>
{this.showRoles.map((item) => item.name).join(', ')}
{this.roles.map((item) => item.name).join(', ')}
</Descriptions.Item>
);
}
@ -95,36 +68,6 @@ export class ProjectInfo extends Component {
);
}
renderBaseRole() {
const { collapsed } = this.state;
if (collapsed) {
return null;
}
return (
<Descriptions.Item
label={t('Base Role')}
labelStyle={{ fontSize: 14 }}
contentStyle={{ fontSize: 14 }}
>
{this.baseRoles.map((item) => item.name).join(', ')}
</Descriptions.Item>
);
}
renderButton() {
const { collapsed } = this.state;
const icon = collapsed ? <DownOutlined /> : <UpOutlined />;
return (
<Button
onClick={this.handleDetailInfo}
icon={icon}
type="link"
className={styles['role-button']}
/>
);
}
render() {
if (!this.currentUser.name) {
return null;
@ -132,16 +75,14 @@ export class ProjectInfo extends Component {
return (
<Card
className={styles.project}
title={`Hello, ${this.currentUser.name}`}
title={t('Hello, {name}', { name: this.currentUser.name })}
bordered={false}
>
<Descriptions column={1}>
{this.renderAccount()}
{this.renderShowRole()}
{this.renderRoles()}
{this.renderDomain()}
{this.renderBaseRole()}
</Descriptions>
{this.renderButton()}
</Card>
);
}

View File

@ -64,7 +64,6 @@ export class Create extends ModalAction {
static policy = 'identity:create_application_credential';
get roleOptions() {
// const baseRoles = toJS(globalRootStore.baseRoles);
const roles = toJS(globalRootStore.roles);
return roles.map((i) => ({

View File

@ -33,9 +33,6 @@ export class RootStore {
@observable
roles = [];
@observable
baseRoles = [];
@observable
baseDomains = [];
@ -127,14 +124,8 @@ export class RootStore {
@action
async updateUserRoles(user) {
const {
roles = [],
base_roles = [],
base_domains,
user: userInfo = {},
} = user || {};
const { roles = [], base_domains, user: userInfo = {} } = user || {};
this.roles = roles;
this.baseRoles = base_roles;
this.baseDomains = base_domains;
this.hasAdminPageRole = await this.getUserSystemRoles(userInfo);
this.hasAdminRole = this.hasAdminPageRole;