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

View File

@ -226,7 +226,6 @@
"BareMetal Parameters": "裸机参数", "BareMetal Parameters": "裸机参数",
"Base Config": "基础配置", "Base Config": "基础配置",
"Base Info": "基本信息", "Base Info": "基本信息",
"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": "绑定资源名称",
"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}": "您好,{name}",
"Heterogeneous Computing": "异构计算", "Heterogeneous Computing": "异构计算",
"Hidden": "隐藏", "Hidden": "隐藏",
"Hide Advanced Options": "隐藏高级选项", "Hide Advanced Options": "隐藏高级选项",

View File

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

View File

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

View File

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