Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users tables: Only show org/space name in pills when needed #2443

Merged
merged 2 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,26 @@ export class CfOrgPermissionCellComponent extends CfPermissionCell<OrgUserRoleNa
);
}

private setChipConfig(row: APIResource<CfUser>, org: APIResource<IOrganization>): AppChip<ICellPermissionList<OrgUserRoleNames>>[] {
private setChipConfig(row: APIResource<CfUser>, org?: APIResource<IOrganization>): AppChip<ICellPermissionList<OrgUserRoleNames>>[] {
const userRoles = this.cfUserService.getOrgRolesFromUser(row.entity, org);
const userOrgPermInfo = arrayHelper.flatten<ICellPermissionList<OrgUserRoleNames>>(
userRoles.map(orgPerms => this.getOrgPermissions(orgPerms, row))
userRoles.map(orgPerms => this.getOrgPermissions(orgPerms, row, !org))
);
return this.getChipConfig(userOrgPermInfo);
}

private getOrgPermissions(orgPerms: IUserPermissionInOrg, row: APIResource<CfUser>): ICellPermissionList<OrgUserRoleNames>[] {
private getOrgPermissions(
orgPerms: IUserPermissionInOrg,
row: APIResource<CfUser>,
showName: boolean): ICellPermissionList<OrgUserRoleNames>[] {
return getOrgRoles(orgPerms.permissions).map(perm => {
const updatingKey = RemoveUserRole.generateUpdatingKey(
perm.key,
row.metadata.guid
);
return {
...perm,
name: orgPerms.name,
name: showName ? orgPerms.name : null,
guid: orgPerms.orgGuid,
userName: row.entity.username,
userGuid: row.metadata.guid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export abstract class CfPermissionCell<T> extends TableCellCustom<APIResource<Cf
return cellPermissionList.map(perm => {
const chipConfig = new AppChip<ICellPermissionList<T>>();
chipConfig.key = perm;
chipConfig.value = `${perm.name}: ${perm.string}`;
chipConfig.value = perm.name ? `${perm.name}: ${perm.string}` : perm.string;
chipConfig.busy = perm.busy;
chipConfig.clearAction = chip => {
const permission = chip.key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ export class CfSpacePermissionCellComponent extends CfPermissionCell<SpaceUserRo
);
}

private createPermissions(row: APIResource<CfUser>, spaces: APIResource<ISpace>[]): ICellPermissionList<SpaceUserRoleNames>[] {
private createPermissions(row: APIResource<CfUser>, spaces?: APIResource<ISpace>[]): ICellPermissionList<SpaceUserRoleNames>[] {
const userRoles = this.cfUserService.getSpaceRolesFromUser(row.entity, spaces);
return arrayHelper.flatten<ICellPermissionList<SpaceUserRoleNames>>(
userRoles.map(spacePerms => this.getSpacePermissions(spacePerms, row))
userRoles.map(spacePerms => this.getSpacePermissions(spacePerms, row, spaces))
);
}

private getSpacePermissions(spacePerms: IUserPermissionInSpace, row: APIResource<CfUser>) {
private getSpacePermissions(spacePerms: IUserPermissionInSpace, row: APIResource<CfUser>, spaces?: APIResource<ISpace>[]) {
return getSpaceRoles(spacePerms.permissions).map(perm => {
const updatingKey = RemoveUserRole.generateUpdatingKey(
perm.key,
row.metadata.guid
);
return {
...perm,
name: spacePerms.name,
name: !spaces || spaces.length > 1 ? spacePerms.name : '',
guid: spacePerms.spaceGuid,
userName: row.entity.username,
userGuid: row.metadata.guid,
Expand Down