Merge "feat: add user group info for domain page"

This commit is contained in:
Zuul 2022-06-15 07:37:27 +00:00 committed by Gerrit Code Review
commit 0896ebc917
12 changed files with 97 additions and 54 deletions

View File

@ -17,6 +17,7 @@ import { DomainStore } from 'stores/keystone/domain';
import Base from 'containers/TabDetail'; import Base from 'containers/TabDetail';
import { enabledColumn } from 'resources/keystone/domain'; import { enabledColumn } from 'resources/keystone/domain';
import User from '../../User'; import User from '../../User';
import UserGroup from '../../UserGroup';
import Project from '../../Project'; import Project from '../../Project';
import actionConfigs from '../actions'; import actionConfigs from '../actions';
@ -44,13 +45,17 @@ export class DomainDetail extends Base {
dataIndex: 'name', dataIndex: 'name',
}, },
enabledColumn, enabledColumn,
{
title: t('Project Num'),
dataIndex: 'projectCount',
},
{ {
title: t('User Num'), title: t('User Num'),
dataIndex: 'userCount', dataIndex: 'userCount',
}, },
{ {
title: t('Project Num'), title: t('User Group Num'),
dataIndex: 'projectCount', dataIndex: 'groupCount',
}, },
{ {
title: t('Description'), title: t('Description'),
@ -61,15 +66,20 @@ export class DomainDetail extends Base {
get tabs() { get tabs() {
const tabs = [ const tabs = [
{
title: t('Projects'),
key: 'project',
component: Project,
},
{ {
title: t('Users'), title: t('Users'),
key: 'user', key: 'user',
component: User, component: User,
}, },
{ {
title: t('Projects'), title: t('User Groups'),
key: 'project', key: 'userGroup',
component: Project, component: UserGroup,
}, },
]; ];
return tabs; return tabs;

View File

@ -45,14 +45,19 @@ export class Domains extends Base {
dataIndex: 'name', dataIndex: 'name',
routeName: 'domainDetailAdmin', routeName: 'domainDetailAdmin',
}, },
{
title: t('Project Num'),
dataIndex: 'projectCount',
isHideable: true,
},
{ {
title: t('User Num'), title: t('User Num'),
dataIndex: 'userCount', dataIndex: 'userCount',
isHideable: true, isHideable: true,
}, },
{ {
title: t('Project Num'), title: t('User Group Num'),
dataIndex: 'projectCount', dataIndex: 'groupCount',
isHideable: true, isHideable: true,
}, },
enabledColumn, enabledColumn,

View File

@ -41,23 +41,19 @@ export class Projects extends Base {
} }
get inProject() { get inProject() {
const { pathname } = this.props.location; return this.path.includes('project-admin');
return pathname.includes('project-admin');
} }
get inUserDetail() { get inUserDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('user-admin/detail');
return this.inDetailPage && pathname.includes('user-admin/detail');
} }
get inUserGroupDetail() { get inUserGroupDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('user-group-admin/detail');
return this.inDetailPage && pathname.includes('user-group-admin/detail');
} }
get inDomainDetail() { get inDomainDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('domain-admin/detail');
return this.inDetailPage && pathname.includes('domain-admin/detail');
} }
getUserProjectRole = (record) => { getUserProjectRole = (record) => {
@ -237,11 +233,19 @@ export class Projects extends Base {
getColumns() { getColumns() {
const columns = this.getBaseColumns(); const columns = this.getBaseColumns();
if (this.inProject || this.inDomainDetail) { if (this.inProject) {
return columns.filter( return columns.filter(
(it) => !['userProjectRole', 'groupProjectRole'].includes(it.dataIndex) (it) => !['userProjectRole', 'groupProjectRole'].includes(it.dataIndex)
); );
} }
if (this.inDomainDetail) {
return columns.filter(
(it) =>
!['domainName', 'userProjectRole', 'groupProjectRole'].includes(
it.dataIndex
)
);
}
if (this.inUserDetail) { if (this.inUserDetail) {
return columns.filter( return columns.filter(
(it) => !['num', 'groupProjectRole'].includes(it.dataIndex) (it) => !['num', 'groupProjectRole'].includes(it.dataIndex)

View File

@ -146,7 +146,8 @@ export class User extends Base {
} }
if (this.inDomainDetail) { if (this.inDomainDetail) {
return columns.filter( return columns.filter(
(it) => !['domain', 'projects', 'projectRoles'].includes(it.dataIndex) (it) =>
!['domainName', 'projects', 'projectRoles'].includes(it.dataIndex)
); );
} }
if (this.inRoleDetail) { if (this.inRoleDetail) {

View File

@ -39,18 +39,19 @@ export class UserGroups extends Base {
} }
get inUserDetail() { get inUserDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('user-admin/detail');
return this.inDetailPage && pathname.includes('user-admin/detail'); }
get inDomainDetail() {
return this.inDetailPage && this.path.includes('domain-admin/detail');
} }
get inProjectDetail() { get inProjectDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('project-admin/detail');
return this.inDetailPage && pathname.includes('project-admin/detail');
} }
get inRoleDetail() { get inRoleDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('role-admin/detail');
return this.inDetailPage && pathname.includes('role-admin/detail');
} }
getBaseColumns() { getBaseColumns() {
@ -187,20 +188,31 @@ export class UserGroups extends Base {
getColumns() { getColumns() {
const columns = this.getBaseColumns(); const columns = this.getBaseColumns();
if (!this.inDetailPage || this.inUserDetail) { if (!this.inDetailPage || this.inUserDetail) {
return columns.filter((it) => !it.dataIndex.includes('DetailPage')); return columns.filter(
(it) =>
!['rolesInProjectDetailPage', 'projectsInRoleDetailPage'].includes(
it.dataIndex
)
);
}
if (this.inDomainDetail) {
return columns.filter(
(it) =>
![
'domainName',
'rolesInProjectDetailPage',
'projectsInRoleDetailPage',
].includes(it.dataIndex)
);
} }
if (this.inProjectDetail) { if (this.inProjectDetail) {
return columns.filter( return columns.filter(
(it) => (it) => !['projects', 'projectsInRoleDetailPage'].includes(it.dataIndex)
it.dataIndex !== 'projects' &&
it.dataIndex !== 'projectsInRoleDetailPage'
); );
} }
if (this.inRoleDetail) { if (this.inRoleDetail) {
return columns.filter( return columns.filter(
(it) => (it) => !['projects', 'rolesInProjectDetailPage'].includes(it.dataIndex)
it.dataIndex !== 'rolesInProjectDetailPage' &&
it.dataIndex !== 'projects'
); );
} }
return columns; return columns;
@ -232,6 +244,8 @@ export class UserGroups extends Base {
newParams.projectId = id; newParams.projectId = id;
} else if (this.inRoleDetail) { } else if (this.inRoleDetail) {
newParams.roleId = id; newParams.roleId = id;
} else if (this.inDomainDetail) {
newParams.domainId = id;
} }
return newParams; return newParams;
}; };

View File

@ -52,18 +52,15 @@ export class FloatingIps extends Base {
} }
get inQosDetail() { get inQosDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('qos');
return this.inDetailPage && pathname.includes('qos');
} }
get isRecycleBinDetail() { get isRecycleBinDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('recycle-bin');
return this.inDetailPage && pathname.includes('recycle-bin');
} }
get inInstanceDetail() { get inInstanceDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('instance');
return this.inDetailPage && pathname.includes('instance');
} }
async getData({ silent, ...params } = {}) { async getData({ silent, ...params } = {}) {

View File

@ -35,8 +35,7 @@ export class SecurityGroups extends Base {
} }
get isRecycleBinDetail() { get isRecycleBinDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('recycle-bin');
return pathname.indexOf('recycle-bin') >= 0;
} }
get actionConfigs() { get actionConfigs() {

View File

@ -80,8 +80,7 @@ export class VirtualAdapter extends Base {
} }
get isRecycleBinDetail() { get isRecycleBinDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('recycle-bin');
return pathname.indexOf('recycle-bin') >= 0;
} }
get actionConfigs() { get actionConfigs() {

View File

@ -37,23 +37,19 @@ export class Share extends Base {
} }
get inShareGroupDetailPage() { get inShareGroupDetailPage() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('share-group');
return this.inDetailPage && pathname.includes('share-group');
} }
get inShareTypeDetailPage() { get inShareTypeDetailPage() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('share-type');
return this.inDetailPage && pathname.includes('share-type');
} }
get inShareNetworkDetailPage() { get inShareNetworkDetailPage() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('share-network');
return this.inDetailPage && pathname.includes('share-network');
} }
get inShareServerDetailPage() { get inShareServerDetailPage() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('share-server');
return this.inDetailPage && pathname.includes('share-server');
} }
get isSortByBackend() { get isSortByBackend() {

View File

@ -44,8 +44,7 @@ export class Volume extends Base {
} }
get isRecycleBinDetail() { get isRecycleBinDetail() {
const { pathname } = this.props.location; return this.inDetailPage && this.path.includes('recycle-bin');
return pathname.indexOf('recycle-bin') >= 0;
} }
get actionConfigs() { get actionConfigs() {

View File

@ -28,6 +28,10 @@ export class DomainStore extends Base {
return client.keystone.users; return client.keystone.users;
} }
get userGroupClient() {
return client.keystone.groups;
}
get projectClient() { get projectClient() {
return client.keystone.projects; return client.keystone.projects;
} }
@ -36,9 +40,10 @@ export class DomainStore extends Base {
if (!items.length) { if (!items.length) {
return items; return items;
} }
const [userResult, projectResult] = await Promise.all([ const [userResult, projectResult, userGroupResult] = await Promise.all([
this.userClient.list(), this.userClient.list(),
this.projectClient.list(), this.projectClient.list(),
this.userGroupClient.list(),
]); ]);
return items.map((it) => { return items.map((it) => {
const users = (userResult.users || []).filter( const users = (userResult.users || []).filter(
@ -47,30 +52,39 @@ export class DomainStore extends Base {
const projects = (projectResult.projects || []).filter( const projects = (projectResult.projects || []).filter(
(project) => project.domain_id === it.id (project) => project.domain_id === it.id
); );
const groups = (userGroupResult.groups || []).filter(
(group) => group.domain_id === it.id
);
return { return {
...it, ...it,
users, users,
userCount: users.length, userCount: users.length,
projects, projects,
projectCount: projects.length, projectCount: projects.length,
groups,
groupCount: groups.length,
}; };
}); });
} }
async detailDidFetch(item) { async detailDidFetch(item) {
const { id } = item; const { id } = item;
const [userResult, projectResult] = await Promise.all([ const [userResult, projectResult, groupResult] = await Promise.all([
this.userClient.list({ domain_id: id }), this.userClient.list({ domain_id: id }),
this.projectClient.list({ domain_id: id }), this.projectClient.list({ domain_id: id }),
this.userGroupClient.list({ domain_id: id }),
]); ]);
const { users = [] } = userResult || {}; const { users = [] } = userResult || {};
const { projects = [] } = projectResult || {}; const { projects = [] } = projectResult || {};
const { groups = [] } = groupResult || {};
return { return {
...item, ...item,
users, users,
userCount: users.length, userCount: users.length,
projects, projects,
projectCount: projects.length, projectCount: projects.length,
groups,
groupCount: groups.length,
}; };
} }

View File

@ -62,6 +62,7 @@ export class GroupStore extends Base {
groupId, groupId,
roleId, roleId,
projectId, projectId,
domainId,
withRole, withRole,
all_projects, all_projects,
...rest ...rest
@ -182,7 +183,7 @@ export class GroupStore extends Base {
if (!items.length) { if (!items.length) {
return items; return items;
} }
const { projectId, roleId, withRole = true } = filters; const { projectId, roleId, domainId, withRole = true } = filters;
const params = {}; const params = {};
if (projectId) { if (projectId) {
params['project.id'] = projectId; params['project.id'] = projectId;
@ -201,7 +202,11 @@ export class GroupStore extends Base {
const { domains = [] } = domainResult; const { domains = [] } = domainResult;
const { projects = [] } = projectsResult || {}; const { projects = [] } = projectsResult || {};
const { role_assignments: assigns = [] } = roleAssignmentResult || {}; const { role_assignments: assigns = [] } = roleAssignmentResult || {};
const newItems = items.map((group) => { let newItems = items;
if (domainId) {
newItems = items.filter((it) => it.domain_id === domainId);
}
newItems = newItems.map((group) => {
return this.updateUserGroup(group, assigns, roles, domains, projects); return this.updateUserGroup(group, assigns, roles, domains, projects);
}); });
if (projectId || roleId) { if (projectId || roleId) {