feat: Refactor project list page
1. Refactor project list page 2. Remove useless func Change-Id: I65ae489bf29e61e9745a987c0a42d9aeafc97014
This commit is contained in:
parent
318f7b195d
commit
f50df3da8d
@ -705,29 +705,6 @@ export default class BaseTable extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (searchType === 'keyword') {
|
|
||||||
// const placeholder =
|
|
||||||
// this.props.placeholder || t('Please input a keyword to find');
|
|
||||||
|
|
||||||
// return (
|
|
||||||
// <div className={styles['search-row']}>
|
|
||||||
// <MagicInput
|
|
||||||
// filterParams={searchFilters}
|
|
||||||
// onInputChange={this.handleFilterInput}
|
|
||||||
// initValue={filters}
|
|
||||||
// />
|
|
||||||
// {/* <Input.Search
|
|
||||||
// className={styles['search-input']}
|
|
||||||
// value={keyword}
|
|
||||||
// onSearch={this.handleSearch}
|
|
||||||
// placeholder={placeholder}
|
|
||||||
// allowClear
|
|
||||||
// /> */}
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
return (
|
return (
|
||||||
<div className={styles['search-row']}>
|
<div className={styles['search-row']}>
|
||||||
<Input
|
<Input
|
||||||
|
@ -39,14 +39,6 @@ export default class Domains extends Base {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTableProps() {
|
|
||||||
const baseProps = Base.prototype.getTableProps.call(this);
|
|
||||||
return {
|
|
||||||
...baseProps,
|
|
||||||
searchType: 'keyword',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getColumns = () => [
|
getColumns = () => [
|
||||||
{
|
{
|
||||||
title: t('Domain ID/Name'),
|
title: t('Domain ID/Name'),
|
||||||
|
@ -16,14 +16,18 @@ import React from 'react';
|
|||||||
import { observer, inject } from 'mobx-react';
|
import { observer, inject } from 'mobx-react';
|
||||||
import { Divider, Badge, Tag, Tooltip } from 'antd';
|
import { Divider, Badge, Tag, Tooltip } from 'antd';
|
||||||
import Base from 'containers/List';
|
import Base from 'containers/List';
|
||||||
import globalProjectStore from 'stores/keystone/project';
|
import globalProjectStore, { ProjectStore } from 'stores/keystone/project';
|
||||||
import { yesNoOptions, projectTagsColors } from 'utils/constants';
|
import {
|
||||||
|
yesNoOptions,
|
||||||
|
projectTagsColors,
|
||||||
|
emptyActionConfig,
|
||||||
|
} from 'utils/constants';
|
||||||
import actionConfigs from './actions';
|
import actionConfigs from './actions';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
export class Projects extends Base {
|
export class Projects extends Base {
|
||||||
init() {
|
init() {
|
||||||
this.store = globalProjectStore;
|
this.store = this.inDetailPage ? new ProjectStore() : globalProjectStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
get tabs() {
|
get tabs() {
|
||||||
@ -42,19 +46,23 @@ export class Projects extends Base {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTableProps() {
|
get inProject() {
|
||||||
const baseProps = Base.prototype.getTableProps.call(this);
|
const { pathname } = this.props.location;
|
||||||
return {
|
return pathname.includes('project-admin');
|
||||||
...baseProps,
|
|
||||||
searchType: 'keyword',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getColumns = () => {
|
get inUserDetail() {
|
||||||
const {
|
const { pathname } = this.props.location;
|
||||||
match: { path },
|
return this.inDetailPage && pathname.includes('user-admin/detail');
|
||||||
} = this.props;
|
}
|
||||||
const components = [
|
|
||||||
|
get inUserGroupDetail() {
|
||||||
|
const { pathname } = this.props.location;
|
||||||
|
return this.inDetailPage && pathname.includes('user-group-admin/detail');
|
||||||
|
}
|
||||||
|
|
||||||
|
getColumns() {
|
||||||
|
const columns = [
|
||||||
{
|
{
|
||||||
title: t('Project ID/Name'),
|
title: t('Project ID/Name'),
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
@ -64,17 +72,13 @@ export class Projects extends Base {
|
|||||||
title: t('Role'),
|
title: t('Role'),
|
||||||
dataIndex: 'projectRole',
|
dataIndex: 'projectRole',
|
||||||
render: (roles, value) => {
|
render: (roles, value) => {
|
||||||
const rolesAll = [...(roles || [])];
|
const { groupProjectRole = [] } = value;
|
||||||
if (value.groupProjectRole) {
|
const rolesAll = [...(roles || []), ...(groupProjectRole || [])];
|
||||||
rolesAll.push(...value.groupProjectRole);
|
|
||||||
}
|
|
||||||
return (rolesAll || []).map((it) => <div>{it}</div>);
|
return (rolesAll || []).map((it) => <div>{it}</div>);
|
||||||
},
|
},
|
||||||
stringify: (roles, value) => {
|
stringify: (roles, value) => {
|
||||||
const rolesAll = [...(roles || [])];
|
const { groupProjectRole = [] } = value;
|
||||||
if (value.groupProjectRole) {
|
const rolesAll = [...(roles || []), ...(groupProjectRole || [])];
|
||||||
rolesAll.push(...value.groupProjectRole);
|
|
||||||
}
|
|
||||||
return (rolesAll || []).join(';');
|
return (rolesAll || []).join(';');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -154,26 +158,16 @@ export class Projects extends Base {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (path.indexOf('project-admin') >= 0) {
|
if (this.inProject) {
|
||||||
components.splice(1, 1);
|
return columns.filter((it) => it.dataIndex !== 'projectRole');
|
||||||
}
|
}
|
||||||
|
|
||||||
return components;
|
return columns;
|
||||||
};
|
}
|
||||||
|
|
||||||
get actionConfigs() {
|
get actionConfigs() {
|
||||||
const {
|
if (this.inUserDetail || this.inUserGroupDetail) {
|
||||||
match: { path },
|
return emptyActionConfig;
|
||||||
} = this.props;
|
|
||||||
if (
|
|
||||||
path.indexOf('user-admin/detail') >= 0 ||
|
|
||||||
path.indexOf('user-group-admin/detail') >= 0
|
|
||||||
) {
|
|
||||||
return {
|
|
||||||
batchActions: [],
|
|
||||||
primaryActions: [],
|
|
||||||
rowActions: [],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return actionConfigs;
|
return actionConfigs;
|
||||||
}
|
}
|
||||||
@ -202,15 +196,13 @@ export class Projects extends Base {
|
|||||||
|
|
||||||
async getData({ silent, ...params } = {}) {
|
async getData({ silent, ...params } = {}) {
|
||||||
const { match } = this.props;
|
const { match } = this.props;
|
||||||
const { path } = match;
|
const { id } = match.params || {};
|
||||||
const newParams = { ...params };
|
const newParams = { ...params };
|
||||||
silent && (this.list.silent = true);
|
silent && (this.list.silent = true);
|
||||||
if (path.indexOf('user-admin/detail') >= 0) {
|
if (this.inUserDetail) {
|
||||||
const { id } = match.params;
|
|
||||||
newParams.userId = id;
|
newParams.userId = id;
|
||||||
await this.store.fetchListInUserDetail(newParams);
|
await this.store.fetchListInUserDetail(newParams);
|
||||||
} else if (path.indexOf('user-group-admin/detail') >= 0) {
|
} else if (this.inUserGroupDetail) {
|
||||||
const { id } = match.params;
|
|
||||||
newParams.groupId = id;
|
newParams.groupId = id;
|
||||||
await this.store.fetchListInGroupDetail(newParams);
|
await this.store.fetchListInGroupDetail(newParams);
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,14 +41,6 @@ export default class Role extends Base {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTableProps() {
|
|
||||||
const baseProps = Base.prototype.getTableProps.call(this);
|
|
||||||
return {
|
|
||||||
...baseProps,
|
|
||||||
searchType: 'keyword',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getColumns = () => [
|
getColumns = () => [
|
||||||
{
|
{
|
||||||
title: t('Role Name'),
|
title: t('Role Name'),
|
||||||
|
Loading…
Reference in New Issue
Block a user