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

Add button to 'maxed' lists to load all entities #4190

Closed
wants to merge 4 commits into from
Closed
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 @@ -22,12 +22,6 @@ <h1>Applications</h1>
}"></app-no-content-message>
</ng-template>

<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'apps'" [firstLine]="'There are too many applications to show'" [secondLine]="{
text: 'Please use the the Cloud Foundry, Organization or Space filters'
}"></app-no-content-message>
</ng-template>
<app-list class="app-wall" [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"
[noEntriesMaxedResults]="noEntriesMaxedResults"
*ngIf="!!(cloudFoundryService.hasRegisteredCFEndpoints$ | async) && !!(cloudFoundryService.hasConnectedCFEndpoints$ | async)">
</app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export function fetchTotalResults(

export const cfOrgSpaceFilter = (entities: APIResource[], paginationState: PaginationEntityState) => {
// Filtering is done remotely when maxedResults are hit (see `setMultiFilter`)
if (!!paginationState.maxedMode) {
if (!!paginationState.maxedState.isMaxedMode) {
return entities;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
}"></app-no-content-message>
</ng-template>

<ng-template #noEntriesMaxedResults>
<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-cloud-foundry-invite-user-link></app-cloud-foundry-invite-user-link>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter" [noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"></app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
}"></app-no-content-message>
</ng-template>

<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'people'" [firstLine]="'There are too many users to show'" [secondLine]="{
text: 'Please navigate to a Space users list'
}"></app-no-content-message>
</ng-template>

<app-cf-admin-add-user-warning></app-cf-admin-add-user-warning>
<app-cloud-foundry-invite-user-link></app-cloud-foundry-invite-user-link>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter" [noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"></app-list>
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'apps'" [firstLine]="'There are too many routes to show'" [secondLine]="{
text: 'Please use the Organization or Space filters'
}"></app-no-content-message>
</ng-template>
<app-list [noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
<app-list></app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,4 @@
}"></app-no-content-message>
</ng-template>

<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'people'" [firstLine]="'There are too many users to show'" [secondLine]="{
text: 'Please navigate to an Organization or Space users list'
}"></app-no-content-message>
</ng-template>

<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"
[noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"></app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { UtilsService } from '../../../../../../../core/src/core/utils.service';
import {
createTableColumnFavorite,
} from '../../../../../../../core/src/shared/components/list/list-table/table-cell-favorite/table-cell-favorite.component';
import { ITableColumn } from '../../../../../../../core/src/shared/components/list/list-table/table.types';
import { ITableColumn, ITableText } from '../../../../../../../core/src/shared/components/list/list-table/table.types';
import {
IListConfig,
IListMultiFilterConfig,
Expand Down Expand Up @@ -136,10 +136,15 @@ export class CfAppConfigService extends ListConfig<APIResource> implements IList
}),
];
viewType = ListViewTypes.BOTH;
text = {
text: ITableText = {
title: '',
filter: 'Search by name',
noEntries: 'There are no applications'
noEntries: 'There are no applications',
maxedResults: {
icon: 'apps',
firstLine: 'There are a lot of applications to fetch',
filterLine: 'Please use the Cloud Foundry, Organization or Space filters'
}
};
enableTextFilter = true;
cardComponent = CardAppComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,24 @@ import {
} from '../../../../../../../cloud-foundry/src/cf-entity-types';
import { createEntityRelationKey } from '../../../../../../../cloud-foundry/src/entity-relations/entity-relations.types';
import { DispatchSequencer, DispatchSequencerAction } from '../../../../../../../core/src/core/dispatch-sequencer';
import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog.service';
import {
distinctPageUntilChanged,
} from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source';
import {
ListPaginationMultiFilterChange,
} from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source-types';
import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types';
import { MultiActionListEntity } from '../../../../../../../store/src/monitors/pagination-monitor';
import { CreatePagination } from '../../../../../../../store/src/actions/pagination.actions';
import { CFListDataSource } from '../../../../cf-list-data-source';
import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog.service';
import { MultiActionListEntity } from '../../../../../../../store/src/monitors/pagination-monitor';
import { APIResource } from '../../../../../../../store/src/types/api.types';
import { PaginationParam } from '../../../../../../../store/src/types/pagination.types';
import { CF_ENDPOINT_TYPE } from '../../../../../cf-types';
import { cfEntityFactory } from '../../../../../cf-entity-factory';
import { CF_ENDPOINT_TYPE } from '../../../../../cf-types';
import { cfOrgSpaceFilter, getRowMetadata } from '../../../../../features/cloud-foundry/cf.helpers';
import { CFListDataSource } from '../../../../cf-list-data-source';
import { createCfOrSpaceMultipleFilterFn } from '../../../../data-services/cf-org-space-service.service';

// export function createGetAllAppAction(paginationKey): GetAllApplications {
// return new GetAllApplications(paginationKey, null, [
// createEntityRelationKey(applicationEntityType, spaceEntityType),
// createEntityRelationKey(spaceEntityType, organizationEntityType),
// createEntityRelationKey(applicationEntityType, routeEntityType),
// ]);
// }

export class CfAppsDataSource extends CFListDataSource<APIResource> {

public static paginationKey = 'applicationWall';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ export class CfOrgUsersListConfigService extends CfUserListConfigService {
(user: CfUser): boolean => cfUserService.hasRolesInOrg(user, activeRouteCfOrgSpace.orgGuid, false),
cfOrgService.org$
);
this.text.maxedResults.firstLine = 'There are a lot of users to fetch';
this.text.maxedResults.filterLine = 'Please navigate to a Space Users list';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { CF_ENDPOINT_TYPE } from '../../../../../cf-types';
import { CFAppState } from '../../../../../../../cloud-foundry/src/cf-app-state';
import { routeEntityType } from '../../../../../../../cloud-foundry/src/cf-entity-types';
import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog.service';
import { ConfirmationDialogConfig } from '../../../../../../../core/src/shared/components/confirmation-dialog.config';
import { ConfirmationDialogService } from '../../../../../../../core/src/shared/components/confirmation-dialog.service';
import { ITableColumn, ITableText } from '../../../../../../../core/src/shared/components/list/list-table/table.types';
Expand All @@ -18,7 +16,9 @@ import {
IMultiListAction,
ListViewTypes,
} from '../../../../../../../core/src/shared/components/list/list.component.types';
import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog.service';
import { APIResource } from '../../../../../../../store/src/types/api.types';
import { CF_ENDPOINT_TYPE } from '../../../../../cf-types';
import {
TableCellRouteAppsAttachedComponent,
} from '../cf-routes/table-cell-route-apps-attached/table-cell-route-apps-attached.component';
Expand Down Expand Up @@ -79,6 +79,11 @@ export abstract class CfRoutesListConfigBase implements IListConfig<APIResource>
title: null,
noEntries: 'There are no routes',
filter: 'Search by Route',
maxedResults: {
icon: 'network_route',
iconFont: 'stratos-icons',
firstLine: 'There are a lot of routes to fetch'
}
};
enableTextFilter = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export class CfRoutesListConfigService extends CfRoutesListConfigBase implements
super(store, confirmDialog, cfService.cfGuid, datePipe, true, true, canEditRoute, observableOf(false));

this.setupList(store, cfService, cfOrgSpaceService);

this.text.maxedResults.firstLine = 'There are a lot of routes to fetch';
this.text.maxedResults.filterLine = 'Please use the Organization filter';
}

private setupList(
Expand All @@ -70,7 +73,6 @@ export class CfRoutesListConfigService extends CfRoutesListConfigBase implements
// Show drop down filters for org and space
const multiFilterConfigs = [
createCfOrgSpaceFilterConfig('org', 'Organization', cfOrgSpaceService.org),
createCfOrgSpaceFilterConfig('space', 'Space', cfOrgSpaceService.space),
];
this.getMultiFiltersConfigs = () => multiFilterConfigs;
initCfOrgSpaceService(store, cfOrgSpaceService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export class CfSpaceUsersListConfigService extends CfUserListConfigService {
cfOrgService.org$,
cfSpaceService.space$,
);
this.text.maxedResults.firstLine = 'There are a lot of users to fetch';
this.text.maxedResults.filterLine = '';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CfUser } from '../../../../../../../cloud-foundry/src/store/types/user.
import { IOrganization, ISpace } from '../../../../../../../core/src/core/cf-api.types';
import { CurrentUserPermissionsChecker } from '../../../../../../../core/src/core/current-user-permissions.checker';
import { CurrentUserPermissionsService } from '../../../../../../../core/src/core/current-user-permissions.service';
import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog.service';
import { ITableColumn } from '../../../../../../../core/src/shared/components/list/list-table/table.types';
import {
IListAction,
Expand All @@ -20,6 +19,7 @@ import {
ListViewTypes,
} from '../../../../../../../core/src/shared/components/list/list.component.types';
import { SetClientFilter } from '../../../../../../../store/src/actions/pagination.actions';
import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog.service';
import { selectPaginationState } from '../../../../../../../store/src/selectors/pagination.selectors';
import { APIResource, EntityInfo } from '../../../../../../../store/src/types/api.types';
import { PaginatedAction } from '../../../../../../../store/src/types/pagination.types';
Expand Down Expand Up @@ -92,7 +92,12 @@ export class CfUserListConfigService extends ListConfig<APIResource<CfUser>> {
text = {
title: null,
filter: 'Search by username',
noEntries: 'There are no users'
noEntries: 'There are no users',
maxedResults: {
icon: 'people',
firstLine: 'There are a lot of users to fetch',
filterLine: 'Please navigate to an Organization or Space users list'
}
};
private initialised: Observable<boolean>;
private multiFilterConfigs: IListMultiFilterConfig[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
UserRoleInSpace,
} from '../../../../cloud-foundry/src/store/types/user.types';
import { IOrganization, ISpace } from '../../../../core/src/core/cf-api.types';
import {
LocalPaginationHelpers,
} from '../../../../core/src/shared/components/list/data-sources-controllers/local-list.helpers';
import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog.service';
import { EntityServiceFactory } from '../../../../store/src/entity-service-factory.service';
import { PaginationMonitorFactory } from '../../../../store/src/monitors/pagination-monitor.factory';
Expand Down Expand Up @@ -76,11 +79,13 @@ export class CfUserService {
if (!currentPage) {
return false;
}
return !currentPage.busy && (!!users || currentPage.error || currentPage.maxed);
const isMaxed = LocalPaginationHelpers.isPaginationMaxed(pagination);
return !currentPage.busy && (!!users || currentPage.error || isMaxed);
}),
map(([users, pagination]) => {
const currentPage = getCurrentPageRequestInfo(pagination, null);
const hasFailed = currentPage.error || currentPage.maxed;
const isMaxed = LocalPaginationHelpers.isPaginationMaxed(pagination);
const hasFailed = currentPage.error || isMaxed;
if (!currentPage || hasFailed) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ describe('CurrentUserPermissionsService', () => {
},
totalResults: 2
},
maxedState: {
isMaxedMode: false
}
}
},
cfFeatureFlag: {
Expand All @@ -545,6 +548,9 @@ describe('CurrentUserPermissionsService', () => {
items: {}
},
totalResults: 13
},
maxedState: {
isMaxedMode: false
}
},
'endpoint-c80420ca-204b-4879-bf69-b6b7a202ad87': {
Expand All @@ -570,6 +576,9 @@ describe('CurrentUserPermissionsService', () => {
items: {}
},
totalResults: 13
},
maxedState: {
isMaxedMode: false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { BehaviorSubject, Observable, ReplaySubject } from 'rxjs';
import { ListFilter, ListSort } from '../../../../../../store/src/actions/list.actions';
import { MetricsAction } from '../../../../../../store/src/actions/metrics.actions';
import { IRequestEntityTypeState } from '../../../../../../store/src/app-state';
import { PaginatedAction, PaginationEntityState, PaginationParam } from '../../../../../../store/src/types/pagination.types';
import { EntityCatalogEntityConfig } from '../../../../../../store/src/entity-catalog/entity-catalog.types';
import { EntitySchema } from '../../../../../../store/src/helpers/entity-schema';
import { PaginatedAction, PaginationEntityState, PaginationParam } from '../../../../../../store/src/types/pagination.types';

export interface IEntitySelectItem {
page: number;
Expand Down Expand Up @@ -124,7 +124,10 @@ export interface IListDataSource<T> extends ICoreListDataSource<T>, EntityCatalo
refresh();

updateMetricsAction(newAction: MetricsAction);

/**
* Ensure that list maxed status is ignored. This will result in all results being shown when previously ignored
*/
showAllAfterMax();
}

export type getRowUniqueId<T> = (T) => string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {

import { ListFilter, ListSort } from '../../../../../../store/src/actions/list.actions';
import { MetricsAction } from '../../../../../../store/src/actions/metrics.actions';
import { SetResultCount } from '../../../../../../store/src/actions/pagination.actions';
import { IgnorePaginationMaxedState, SetResultCount } from '../../../../../../store/src/actions/pagination.actions';
import { AppState } from '../../../../../../store/src/app-state';
import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog.service';
import { EntitySchema } from '../../../../../../store/src/helpers/entity-schema';
Expand Down Expand Up @@ -225,7 +225,7 @@ export abstract class ListDataSource<T, A = T> extends DataSource<T> implements
this.entityKey = this.sourceScheme.key;
this.entityType = this.action.entityType;
this.endpointType = this.action.endpointType;
this.masterAction = this.action as PaginatedAction;
this.masterAction = this.action;
this.setupAction(config);
if (!this.isLocal && this.config.listConfig) {
// This is a non-local data source so the results-per-page should match the initial page size. This will avoid making two calls
Expand All @@ -237,7 +237,7 @@ export abstract class ListDataSource<T, A = T> extends DataSource<T> implements
private setupAction(config: IListDataSourceConfig<A, T>) {
if (config.schema instanceof MultiActionConfig) {
if (!config.isLocal) {
// We cannot do multi action lists for none local lists
// We cannot do multi action lists for non-local lists
this.action = config.schema[0].paginationAction;
this.masterAction = this.action as PaginatedAction;
} else {
Expand Down Expand Up @@ -440,6 +440,14 @@ export abstract class ListDataSource<T, A = T> extends DataSource<T> implements
}
}

public showAllAfterMax() {
this.store.dispatch(new IgnorePaginationMaxedState(
this.masterAction.entityType,
this.masterAction.endpointType,
this.masterAction.paginationKey
));
}

private createSortObservable(): Observable<ListSort> {
return this.pagination$.pipe(
map(pag => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class ListPaginationController<T> implements IListPaginationController<T>
));
}

if (paginationEntityState.maxedMode) {
if (paginationEntityState.maxedState.isMaxedMode) {
this.dataSource.setMultiFilter(changes, paginationEntityState.params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@ export interface ITableColumn<T> {
cellAlignSelf?: string;
}

export interface ITableTextMaxed {
icon: string;
iconFont?: string;
firstLine: string;
filterLine?: string;
}

export interface ITableText {
title?: string;
filter?: string;
noEntries?: string;
maxedResults?: string;
maxedResults?: ITableTextMaxed;
}

export const listTableComponents = [
Expand Down
Loading