fix: Fix for credential download & show

1. fix credential role show
2. fix credential download

Change-Id: Ib460a507d65395963db0445ca40a3d2a4d5eb83f
This commit is contained in:
zhuyue 2021-09-16 19:09:14 +08:00
parent 6e96e18809
commit 20c47ece8a
6 changed files with 62 additions and 29 deletions

View File

@ -13,7 +13,7 @@
// limitations under the License.
import React, { Component } from 'react';
import { Checkbox } from 'antd';
import { Checkbox, Row, Col } from 'antd';
import PropTypes from 'prop-types';
export default class index extends Component {
@ -57,12 +57,22 @@ export default class index extends Component {
};
render() {
const { className, options } = this.props;
const { className, options, span } = this.props;
const values = this.getValues();
const conf = {
className,
onChange: this.onChange,
};
return <Checkbox.Group {...conf} options={options} value={values} />;
return (
<Checkbox.Group {...conf} value={values} style={{ width: '100%' }}>
<Row>
{options.map((opt) => (
<Col span={span} key={opt.value}>
<Checkbox value={opt.value}>{opt.label}</Checkbox>
</Col>
))}
</Row>
</Checkbox.Group>
);
}
}

View File

@ -52,6 +52,7 @@
"Add network": "Add network",
"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})",
"Admin": "Admin",
"Admin State": "Admin State",
"Admin Status": "Admin Status",
"Administrator": "Administrator",
@ -1289,6 +1290,7 @@
"Ram value is { ram }, NUMA RAM value is { totalRam }, need to be equal. ": "Ram value is { ram }, NUMA RAM value is { totalRam }, need to be equal. ",
"Ramdisk ID": "Ramdisk ID",
"Ramdisk Image": "Ramdisk Image",
"Reader": "Reader",
"Real Name": "Real Name",
"Reason": "Reason",
"Reason: ": "Reason: ",

View File

@ -52,6 +52,7 @@
"Add network": "添加网络",
"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})",
"Admin": "管理员",
"Admin State": "管理状态",
"Admin Status": "管理状态",
"Administrator": "管理平台",
@ -1289,6 +1290,7 @@
"Ram value is { ram }, NUMA RAM value is { totalRam }, need to be equal. ": "内存是 { ram }MBNUMA节点的内存是{ totalRam }MB需要一致。",
"Ramdisk ID": "内存盘ID",
"Ramdisk Image": "Ramdisk镜像",
"Reader": "只读",
"Real Name": "真实姓名",
"Reason": "原因",
"Reason: ": "原因:",

View File

@ -19,18 +19,30 @@ import moment from 'moment';
import globalRootStore from 'stores/root';
import { toJS } from 'mobx';
import FileSaver from 'file-saver';
import rolePermission from 'resources/role';
@inject('rootStore')
@observer
export default class Create extends ModalAction {
export class Create extends ModalAction {
static id = 'create-application_credentials';
static title = t('Create Application Credentials');
static get modalSize() {
return 'middle';
}
getModalSize() {
return 'middle';
}
get name() {
return t('Create Application Credentials');
}
get rolePermissions() {
return rolePermission;
}
onSubmit = (values) => {
if (values.expires_at) {
values.expires_at = values.expires_at.clone().endOf('day');
@ -61,7 +73,10 @@ export default class Create extends ModalAction {
// const baseRoles = toJS(globalRootStore.baseRoles);
const roles = toJS(globalRootStore.roles);
return roles.map((i) => ({ label: i.name, value: i.id }));
return roles.map((i) => ({
label: this.rolePermissions[i.name] || i.name,
value: i.id,
}));
}
get formItems() {
@ -86,6 +101,7 @@ export default class Create extends ModalAction {
label: t('Roles'),
type: 'check-group',
options: this.roleOptions,
span: 12,
},
{
name: 'description',
@ -96,3 +112,5 @@ export default class Create extends ModalAction {
];
}
}
export default inject('rootStore')(observer(Create))

View File

@ -14,16 +14,14 @@
import React from 'react';
import { observer, inject } from 'mobx-react';
import { Popover, Row, Col } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
import { Row, Col } from 'antd';
import Base from 'containers/List';
import { CredentialStore } from 'stores/keystone/credential';
import globalRootStore from 'stores/root';
import rolePermission from 'resources/role';
import { actionConfigs, detailConfigs } from './actions';
@inject('rootStore')
@observer
export default class Credentials extends Base {
export class Credentials extends Base {
init() {
this.store = new CredentialStore();
this.downloadStore = new CredentialStore();
@ -43,6 +41,10 @@ export default class Credentials extends Base {
return params;
};
get rolePermissions() {
return rolePermission;
}
get isFilterByBackend() {
return true;
}
@ -91,23 +93,17 @@ export default class Credentials extends Base {
{
title: t('Roles'),
dataIndex: 'roles',
render: (roles) => {
const content = (
<Row gutter={[8]} style={{ maxWidth: 200 }}>
{roles.map((i) => (
<Col span={24} key={i.id}>
{i.name}
</Col>
))}
</Row>
);
return (
<Popover content={content}>
<SearchOutlined />
</Popover>
);
},
isHideable: true,
render: (roles) => (
<Row gutter={[8]} style={{ maxWidth: 300 }}>
{roles.map((i) => (
<Col span={24} key={i.id}>
{this.rolePermissions[i.name] || i.name}
</Col>
))}
</Row>
),
stringify: (values) =>
values.map((i) => this.rolePermissions[i.name] || i.name).join('\n'),
},
];
return ret;
@ -123,3 +119,5 @@ export default class Credentials extends Base {
return filters;
}
}
export default inject('rootStore')(observer(Credentials))

View File

@ -18,6 +18,9 @@ const rolePermission = {
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 default rolePermission;