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:
Jingwei.Zhang 2022-06-17 11:40:39 +08:00
parent 3be608547c
commit 549e75d011
3 changed files with 16 additions and 40 deletions

View File

@ -19,7 +19,6 @@ import moment from 'moment';
import globalRootStore from 'stores/root';
import { toJS } from 'mobx';
import FileSaver from 'file-saver';
import rolePermission from 'resources/keystone/role';
export class Create extends ModalAction {
static id = 'create-application_credentials';
@ -38,10 +37,6 @@ export class Create extends ModalAction {
return t('Create Application Credentials');
}
get rolePermissions() {
return rolePermission;
}
onSubmit = (values) => {
if (values.expires_at) {
values.expires_at = values.expires_at.clone().endOf('day');
@ -73,7 +68,7 @@ export class Create extends ModalAction {
const roles = toJS(globalRootStore.roles);
return roles.map((i) => ({
label: this.rolePermissions[i.name] || i.name,
label: i.name,
value: i.id,
}));
}

View File

@ -14,11 +14,9 @@
import React from 'react';
import { observer, inject } from 'mobx-react';
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/keystone/role';
import { actionConfigs, detailConfigs } from './actions';
export class Credentials extends Base {
@ -31,25 +29,6 @@ export class Credentials extends Base {
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() {
return 'identity:get_application_credential';
}
@ -90,17 +69,9 @@ export class Credentials extends Base {
{
title: t('Roles'),
dataIndex: 'roles',
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'),
render: (roles) =>
(roles || []).map((role) => <div key={role.id}>{role.name}</div>),
stringify: (values) => values.map((i) => i.name).join('\n'),
},
];
return ret;
@ -115,6 +86,16 @@ export class Credentials extends Base {
];
return filters;
}
updateFetchParams = (params) => {
if (!this.isUserDetail) {
return {
...params,
id: globalRootStore.user.user.id,
};
}
return params;
};
}
export default inject('rootStore')(observer(Credentials));

View File

@ -27,9 +27,9 @@ export class CredentialStore extends Base {
return client.keystone.users.applicationCredentials;
}
get paramsFuncPage() {
get paramsFunc() {
return (params) => {
const { current, id, ...rest } = params;
const { current, id, all_projects, ...rest } = params;
return rest;
};
}