fix: fix application credential api fetch
1. Fix application credential api fetch 2. Update role display to role name, not i18n name Change-Id: Iead1af8b8f867c3a8ecd8b3ab8d249b220e8b930
This commit is contained in:
parent
3be608547c
commit
549e75d011
@ -19,7 +19,6 @@ import moment from 'moment';
|
|||||||
import globalRootStore from 'stores/root';
|
import globalRootStore from 'stores/root';
|
||||||
import { toJS } from 'mobx';
|
import { toJS } from 'mobx';
|
||||||
import FileSaver from 'file-saver';
|
import FileSaver from 'file-saver';
|
||||||
import rolePermission from 'resources/keystone/role';
|
|
||||||
|
|
||||||
export class Create extends ModalAction {
|
export class Create extends ModalAction {
|
||||||
static id = 'create-application_credentials';
|
static id = 'create-application_credentials';
|
||||||
@ -38,10 +37,6 @@ export class Create extends ModalAction {
|
|||||||
return t('Create Application Credentials');
|
return t('Create Application Credentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
get rolePermissions() {
|
|
||||||
return rolePermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
onSubmit = (values) => {
|
onSubmit = (values) => {
|
||||||
if (values.expires_at) {
|
if (values.expires_at) {
|
||||||
values.expires_at = values.expires_at.clone().endOf('day');
|
values.expires_at = values.expires_at.clone().endOf('day');
|
||||||
@ -73,7 +68,7 @@ export class Create extends ModalAction {
|
|||||||
const roles = toJS(globalRootStore.roles);
|
const roles = toJS(globalRootStore.roles);
|
||||||
|
|
||||||
return roles.map((i) => ({
|
return roles.map((i) => ({
|
||||||
label: this.rolePermissions[i.name] || i.name,
|
label: i.name,
|
||||||
value: i.id,
|
value: i.id,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,9 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer, inject } from 'mobx-react';
|
import { observer, inject } from 'mobx-react';
|
||||||
import { Row, Col } from 'antd';
|
|
||||||
import Base from 'containers/List';
|
import Base from 'containers/List';
|
||||||
import { CredentialStore } from 'stores/keystone/credential';
|
import { CredentialStore } from 'stores/keystone/credential';
|
||||||
import globalRootStore from 'stores/root';
|
import globalRootStore from 'stores/root';
|
||||||
import rolePermission from 'resources/keystone/role';
|
|
||||||
import { actionConfigs, detailConfigs } from './actions';
|
import { actionConfigs, detailConfigs } from './actions';
|
||||||
|
|
||||||
export class Credentials extends Base {
|
export class Credentials extends Base {
|
||||||
@ -31,25 +29,6 @@ export class Credentials extends Base {
|
|||||||
return this.inDetailPage && this.path.includes('user-admin/detail');
|
return this.inDetailPage && this.path.includes('user-admin/detail');
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFetchParamsByPage = (params) => {
|
|
||||||
if (!this.isUserDetail) {
|
|
||||||
params.id = globalRootStore.user.user.id;
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
};
|
|
||||||
|
|
||||||
get rolePermissions() {
|
|
||||||
return rolePermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
get isFilterByBackend() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
get isSortByBackend() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
get policy() {
|
get policy() {
|
||||||
return 'identity:get_application_credential';
|
return 'identity:get_application_credential';
|
||||||
}
|
}
|
||||||
@ -90,17 +69,9 @@ export class Credentials extends Base {
|
|||||||
{
|
{
|
||||||
title: t('Roles'),
|
title: t('Roles'),
|
||||||
dataIndex: 'roles',
|
dataIndex: 'roles',
|
||||||
render: (roles) => (
|
render: (roles) =>
|
||||||
<Row gutter={[8]} style={{ maxWidth: 300 }}>
|
(roles || []).map((role) => <div key={role.id}>{role.name}</div>),
|
||||||
{roles.map((i) => (
|
stringify: (values) => values.map((i) => i.name).join('\n'),
|
||||||
<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;
|
return ret;
|
||||||
@ -115,6 +86,16 @@ export class Credentials extends Base {
|
|||||||
];
|
];
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFetchParams = (params) => {
|
||||||
|
if (!this.isUserDetail) {
|
||||||
|
return {
|
||||||
|
...params,
|
||||||
|
id: globalRootStore.user.user.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default inject('rootStore')(observer(Credentials));
|
export default inject('rootStore')(observer(Credentials));
|
||||||
|
@ -27,9 +27,9 @@ export class CredentialStore extends Base {
|
|||||||
return client.keystone.users.applicationCredentials;
|
return client.keystone.users.applicationCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
get paramsFuncPage() {
|
get paramsFunc() {
|
||||||
return (params) => {
|
return (params) => {
|
||||||
const { current, id, ...rest } = params;
|
const { current, id, all_projects, ...rest } = params;
|
||||||
return rest;
|
return rest;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user