Skip to content

Commit

Permalink
Add warning for admin maxed world org/space
Browse files Browse the repository at this point in the history
- Admins at org/space level with maxed users cannot see users without roles
- Add a warning so they don't search for them
  • Loading branch information
richard-cox committed Jan 25, 2019
1 parent ad90d91 commit dc128b2
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RouterModule } from '@angular/router';
import { NgxChartsModule } from '@swimlane/ngx-charts';

import { CoreModule } from '../../core/core.module';
import { CustomImportModule } from '../../custom-import.module';
import {
CFEndpointsListConfigService,
} from '../../shared/components/list/list-types/cf-endpoints/cf-endpoints-list-config.service';
Expand All @@ -27,6 +28,7 @@ import { EditSpaceStepComponent } from './edit-space/edit-space-step/edit-space-
import { EditSpaceComponent } from './edit-space/edit-space.component';
import { CloudFoundryEndpointService } from './services/cloud-foundry-endpoint.service';
import { CloudFoundryOrganizationService } from './services/cloud-foundry-organization.service';
import { CfAdminAddUserWarningComponent } from './tabs/cf-admin-add-user-warning/cf-admin-add-user-warning.component';
import { CloudFoundryBuildPacksComponent } from './tabs/cloud-foundry-build-packs/cloud-foundry-build-packs.component';
import {
CloudFoundryCellAppsComponent,
Expand Down Expand Up @@ -77,6 +79,7 @@ import {
import {
CloudFoundryOrganizationsComponent,
} from './tabs/cloud-foundry-organizations/cloud-foundry-organizations.component';
import { CloudFoundryRoutesComponent } from './tabs/cloud-foundry-routes/cloud-foundry-routes.component';
import {
CloudFoundrySecurityGroupsComponent,
} from './tabs/cloud-foundry-security-groups/cloud-foundry-security-groups.component';
Expand All @@ -85,14 +88,13 @@ import { CloudFoundrySummaryTabComponent } from './tabs/cloud-foundry-summary-ta
import { CloudFoundryUsersComponent } from './tabs/cloud-foundry-users/cloud-foundry-users.component';
import { CfRolesService } from './users/manage-users/cf-roles.service';
import { UsersRolesConfirmComponent } from './users/manage-users/manage-users-confirm/manage-users-confirm.component';
import { ManageUsersFindComponent } from './users/manage-users/manage-users-find/manage-users-find.component';
import { UsersRolesModifyComponent } from './users/manage-users/manage-users-modify/manage-users-modify.component';
import {
SpaceRolesListWrapperComponent,
} from './users/manage-users/manage-users-modify/space-roles-list-wrapper/space-roles-list-wrapper.component';
import { UsersRolesSelectComponent } from './users/manage-users/manage-users-select/manage-users-select.component';
import { UsersRolesComponent } from './users/manage-users/manage-users.component';
import { CustomImportModule } from '../../custom-import.module';
import { CloudFoundryRoutesComponent } from './tabs/cloud-foundry-routes/cloud-foundry-routes.component';

@NgModule({
imports: [
Expand Down Expand Up @@ -145,6 +147,8 @@ import { CloudFoundryRoutesComponent } from './tabs/cloud-foundry-routes/cloud-f
UsersRolesSelectComponent,
UsersRolesConfirmComponent,
CloudFoundryRoutesComponent,
ManageUsersFindComponent,
CfAdminAddUserWarningComponent,
],
providers: [
CFEndpointsListConfigService,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<mat-card *ngIf="show$ | async" class="user-warning">
<mat-icon class="user-warning__icon">warning</mat-icon>There are too many users to show those without roles. To add a user to this {{isOrg ? 'organization' : 'space'}} please use another tool such as the Cloud Foundry CLI
</mat-card>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.user-warning {
align-items: center;
display: flex;
font-size: 14px;
margin-bottom: 12px;
padding: 12px 22px;

&__icon {
font-size: 22px;
margin-right: 13px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CfAdminAddUserWarningComponent } from './cf-admin-add-user-warning.component';

describe('CfAdminAddUserWarningComponent', () => {
let component: CfAdminAddUserWarningComponent;
let fixture: ComponentFixture<CfAdminAddUserWarningComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CfAdminAddUserWarningComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CfAdminAddUserWarningComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@mixin cf-admin-add-user-warning($theme, $app-theme) {
$status-colors: map-get($app-theme, status);
$warning: map-get($status-colors, warning);
.user-warning {
background-color: lighten($warning, 45%);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Component } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { filter, map, switchMap } from 'rxjs/operators';

import { CfUserService } from '../../../../shared/data-services/cf-user.service';
import { GetAllUsersAsAdmin } from '../../../../store/actions/users.actions';
import { AppState } from '../../../../store/app-state';
import { ActiveRouteCfOrgSpace } from '../../cf-page.types';
import { waitForCFPermissions } from '../../cf.helpers';

@Component({
selector: 'app-cf-admin-add-user-warning',
templateUrl: './cf-admin-add-user-warning.component.html',
styleUrls: ['./cf-admin-add-user-warning.component.scss']
})
export class CfAdminAddUserWarningComponent {

isOrg: boolean;
show$: Observable<boolean>;

constructor(
store: Store<AppState>,
activeRouteCfOrgSpace: ActiveRouteCfOrgSpace,
cfUserService: CfUserService
) {
this.isOrg = !activeRouteCfOrgSpace.spaceGuid;
this.show$ = waitForCFPermissions(
store,
activeRouteCfOrgSpace.cfGuid
).pipe(
filter(cf => cf.global.isAdmin),
switchMap(cf => cfUserService.createPaginationAction(
cf.global.isAdmin,
activeRouteCfOrgSpace.cfGuid,
activeRouteCfOrgSpace.orgGuid,
activeRouteCfOrgSpace.spaceGuid)),
map(fetchUsersAction => {
return !GetAllUsersAsAdmin.is(fetchUsersAction);
})
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<app-no-content-message [icon]="'people'" [firstLine]="'There are too many users to show'"></app-no-content-message>
</ng-template>

<app-cf-admin-add-user-warning></app-cf-admin-add-user-warning>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter" [noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
}"></app-no-content-message>
</ng-template>

<app-cf-admin-add-user-warning></app-cf-admin-add-user-warning>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter" [noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
2 changes: 1 addition & 1 deletion src/frontend/app/store/actions/users.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class GetAllUsersAsAdmin extends CFStartAction implements PaginatedAction
'order-direction-field': 'username',
};
flattenPagination = true;
flattenPaginationMax = 600;
flattenPaginationMax = 1000;
static is(action: PaginatedAction): boolean {
return !!action['isGetAllUsersAsAdmin'];
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/sass/_all-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
@import './fonts';
@import './ansi-colors';
@import '../app/shared/components/schema-form/schema-form.component.theme';
@import '../app/features/cloud-foundry/tabs/cf-admin-add-user-warning/cf-admin-add-user-warning.component.theme';
// Defaults
$side-nav-light-text: #fff;
$side-nav-light-bg: #333;
Expand Down Expand Up @@ -124,6 +125,7 @@ $side-nav-light-active: #484848;
@include metrics-chart-theme($theme, $app-theme);
@include metrics-range-selector-theme($theme, $app-theme);
@include app-multiline-title-theme($theme, $app-theme);
@include cf-admin-add-user-warning($theme, $app-theme);
}

@function app-generate-nav-theme($theme, $nav-theme: null) {
Expand Down

0 comments on commit dc128b2

Please sign in to comment.