Skip to content

Commit

Permalink
Persist list settings over refresh (cloudfoundry#4405)
Browse files Browse the repository at this point in the history
* WIP

* Add list reset button & list button tooltips

* Few tidy ups, add clear local storage feature

* Tweak profile settings section

* WIP

* WIP

* only store pagination sections from lists

* Fix clear and auto select multi filter/s on reset

* Ingore invalid values

* Super basic encryption of pag section

* fix reset

* Fix max list count & multi-entity selectors stickyness

* tidying up

* Fix linting

* Fix unit tests

* Changes following review #1

* Changes following review #2

* Changes following review no. 3

* Fix warning on first load

* Fix show org/space e2e failures

* improve delete service e2e tests

* Ensure list is card mode before waiting to find a card

* Remove stray line
  • Loading branch information
richard-cox authored Dec 4, 2020
1 parent 51d0d55 commit 463a1c3
Show file tree
Hide file tree
Showing 42 changed files with 799 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ <h1>Applications</h1>
</ng-template>

<app-list class="app-wall" [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"
(initialised)="cfOrgSpaceService.enableAutoSelectors()"
*ngIf="!!(cloudFoundryService.hasRegisteredCFEndpoints$ | async) && !!(cloudFoundryService.hasConnectedCFEndpoints$ | async)">
</app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { animate, query, style, transition, trigger } from '@angular/animations'
import { Component, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { Observable, Subscription } from 'rxjs';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { CFAppState } from '../../../../../cloud-foundry/src/cf-app-state';
import { applicationEntityType } from '../../../../../cloud-foundry/src/cf-entity-types';
import { ListConfig } from '../../../../../core/src/shared/components/list/list.component.types';
import { CfAppConfigService } from '../../../shared/components/list/list-types/app/cf-app-config.service';
import { CfAppsDataSource } from '../../../shared/components/list/list-types/app/cf-apps-data-source';
import { CfOrgSpaceDataService, initCfOrgSpaceService } from '../../../shared/data-services/cf-org-space-service.service';
import { CfOrgSpaceDataService } from '../../../shared/data-services/cf-org-space-service.service';
import { CloudFoundryService } from '../../../shared/data-services/cloud-foundry.service';
import { CfCurrentUserPermissions } from '../../../user-permissions/cf-user-permissions-checkers';
import { goToAppWall } from '../../cf/cf.helpers';
Expand All @@ -22,13 +20,13 @@ import { goToAppWall } from '../../cf/cf.helpers';
animations: [
trigger(
'cardEnter', [
transition('* => *', [
query(':enter', [
style({ opacity: 0, transform: 'translateY(10px)' }),
animate('150ms ease-out', style({ opacity: 1, transform: 'translateY(0)' }))
], { optional: true })
])
]
transition('* => *', [
query(':enter', [
style({ opacity: 0, transform: 'translateY(10px)' }),
animate('150ms ease-out', style({ opacity: 1, transform: 'translateY(0)' }))
], { optional: true })
])
]
)
],
providers: [{
Expand All @@ -40,7 +38,6 @@ import { goToAppWall } from '../../cf/cf.helpers';
})
export class ApplicationWallComponent implements OnDestroy {
public cfIds$: Observable<string[]>;
private initCfOrgSpaceService: Subscription;

public canCreateApplication: string;

Expand All @@ -49,7 +46,7 @@ export class ApplicationWallComponent implements OnDestroy {
constructor(
public cloudFoundryService: CloudFoundryService,
private store: Store<CFAppState>,
private cfOrgSpaceService: CfOrgSpaceDataService,
public cfOrgSpaceService: CfOrgSpaceDataService,
activatedRoute: ActivatedRoute,
) {
// If we have an endpoint ID, select it and redirect
Expand All @@ -67,16 +64,8 @@ export class ApplicationWallComponent implements OnDestroy {
this.haveConnectedCf$ = cloudFoundryService.connectedCFEndpoints$.pipe(
map(endpoints => !!endpoints && endpoints.length > 0)
);

this.initCfOrgSpaceService = initCfOrgSpaceService(this.store,
this.cfOrgSpaceService,
applicationEntityType,
CfAppsDataSource.paginationKey).subscribe();
}

ngOnDestroy(): void {
if (this.initCfOrgSpaceService) {
this.initCfOrgSpaceService.unsubscribe();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Subscription } from 'rxjs';
import { filter, first, tap } from 'rxjs/operators';

import { CFAppState } from '../../../../../cloud-foundry/src/cf-app-state';
import { applicationEntityType } from '../../../../../cloud-foundry/src/cf-entity-types';
import { selectCfPaginationState } from '../../../../../cloud-foundry/src/store/selectors/pagination.selectors';
import { applicationEntityType } from '../../../cf-entity-types';
import { CfAppsDataSource } from '../../../shared/components/list/list-types/app/cf-apps-data-source';
import { CfOrgSpaceDataService } from '../../../shared/data-services/cf-org-space-service.service';
import { selectCfPaginationState } from '../../../store/selectors/pagination.selectors';

@Component({
selector: 'app-create-application',
Expand All @@ -22,14 +22,16 @@ export class CreateApplicationComponent implements OnInit, OnDestroy {

ngOnInit() {
// We will auto select endpoint/org/space that have been selected on the app wall.
this.cfOrgSpaceService.enableAutoSelectors();
// FIXME: This has been broken for a while (setting cf will clear org + space after org and space has been set)
// With new tools (set initial/enable auto) this should be easier to fix
const appWallPaginationState = this.store.select(selectCfPaginationState(applicationEntityType, CfAppsDataSource.paginationKey));
this.paginationStateSub = appWallPaginationState.pipe(filter(pag => !!pag), first(), tap(pag => {
const { cf, org, space } = pag.clientPagination.filter.items;
if (cf) {
this.cfOrgSpaceService.cf.select.next(cf);
}
if (cf && org) {

this.cfOrgSpaceService.org.select.next(org);
}
if (cf && org && space) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ <h1>Services</h1>
</ng-template>

<app-list class="services-wall" [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"
(initialised)="cfOrgSpaceService.enableAutoSelectors()"
*ngIf="!!(cloudFoundryService.hasRegisteredCFEndpoints$ | async) && !!(cloudFoundryService.hasConnectedCFEndpoints$ | async)">
</app-list>
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { Component, OnDestroy } from '@angular/core';
import { Component } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';

import { CFAppState } from '../../../../../cloud-foundry/src/cf-app-state';
import { serviceInstancesEntityType } from '../../../../../cloud-foundry/src/cf-entity-types';
import {
ServiceInstancesWallListConfigService,
} from '../../../../../cloud-foundry/src/shared/components/list/list-types/services-wall/service-instances-wall-list-config.service';
import {
CfOrgSpaceDataService,
initCfOrgSpaceService,
} from '../../../../../cloud-foundry/src/shared/data-services/cf-org-space-service.service';
import { CfOrgSpaceDataService } from '../../../../../cloud-foundry/src/shared/data-services/cf-org-space-service.service';
import { CloudFoundryService } from '../../../../../cloud-foundry/src/shared/data-services/cloud-foundry.service';
import { ListConfig } from '../../../../../core/src/shared/components/list/list.component.types';
import { CSI_CANCEL_URL } from '../../../shared/components/add-service-instance/csi-mode.service';
Expand All @@ -29,7 +25,7 @@ import { CfCurrentUserPermissions } from '../../../user-permissions/cf-user-perm
CfOrgSpaceDataService
]
})
export class ServicesWallComponent implements OnDestroy {
export class ServicesWallComponent {

public haveConnectedCf$: Observable<boolean>;

Expand All @@ -41,7 +37,7 @@ export class ServicesWallComponent implements OnDestroy {
constructor(
public cloudFoundryService: CloudFoundryService,
public store: Store<CFAppState>,
private cfOrgSpaceService: CfOrgSpaceDataService) {
public cfOrgSpaceService: CfOrgSpaceDataService) {

this.canCreateServiceInstance = CfCurrentUserPermissions.SERVICE_INSTANCE_CREATE;
this.cfIds$ = cloudFoundryService.cFEndpoints$.pipe(
Expand All @@ -51,11 +47,6 @@ export class ServicesWallComponent implements OnDestroy {
)
);

this.initCfOrgSpaceService = initCfOrgSpaceService(this.store,
this.cfOrgSpaceService,
serviceInstancesEntityType,
'all').subscribe();

this.haveConnectedCf$ = cloudFoundryService.connectedCFEndpoints$.pipe(
map(endpoints => !!endpoints && endpoints.length > 0)
);
Expand All @@ -64,8 +55,4 @@ export class ServicesWallComponent implements OnDestroy {
[CSI_CANCEL_URL]: `/services`
};
}

ngOnDestroy(): void {
this.initCfOrgSpaceService.unsubscribe();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class CreateApplicationStep1Component implements OnInit, AfterContentInit
space: this.cfOrgSpaceService.space.select.getValue()
}));
return of({ success: true });
}
};

ngOnInit() {
if (this.route.root.snapshot.queryParams.endpointGuid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ export class CfAppConfigService extends ListConfig<APIResource> implements IList

// Apply the initial cf guid to the data source. Normally this is done via applying the selection to the filter... however this is too
// late for maxedResult world
this.initialised$ = this.cfOrgSpaceService.cf.loading$.pipe(
this.initialised$ = this.cfOrgSpaceService.isLoading$.pipe(
filter(isLoading => !isLoading),
switchMap(() => this.cfOrgSpaceService.cf.list$),
first(),
map(cfs => {
const cfGuid = cfs.length === 1 ? cfs[0].guid : null;
this.appsDataSource = new CfAppsDataSource(this.store, this, undefined, undefined, undefined, cfGuid);
this.cfOrgSpaceService.setInitialValuesFromAction(this.appsDataSource.action, 'cf', 'org', 'space');
return true;
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ import {
import { APIResource } from '../../../../../../../store/src/types/api.types';
import { CloudFoundryEndpointService } from '../../../../../features/cf/services/cloud-foundry-endpoint.service';
import { CfCurrentUserPermissions } from '../../../../../user-permissions/cf-user-permissions-checkers';
import {
CfOrgSpaceDataService,
createCfOrgSpaceFilterConfig,
initCfOrgSpaceService,
} from '../../../../data-services/cf-org-space-service.service';
import { CfOrgSpaceDataService, createCfOrgSpaceFilterConfig } from '../../../../data-services/cf-org-space-service.service';
import { CfRoutesDataSource } from './cf-routes-data-source';
import { ListCfRoute } from './cf-routes-data-source-base';
import { CfRoutesListConfigBase } from './cf-routes-list-config-base';
Expand Down Expand Up @@ -76,10 +72,6 @@ export class CfRoutesListConfigService extends CfRoutesListConfigBase implements
createCfOrgSpaceFilterConfig('org', 'Organization', cfOrgSpaceService.org),
];
this.getMultiFiltersConfigs = () => multiFilterConfigs;
initCfOrgSpaceService(store, cfOrgSpaceService,
this.dataSource.masterAction.entityType,
this.dataSource.masterAction.paginationKey).subscribe();
cfOrgSpaceService.cf.select.next(cfService.cfGuid);

this.getInitialised = () => combineLatest(
cfOrgSpaceService.cf.list$,
Expand All @@ -89,5 +81,7 @@ export class CfRoutesListConfigService extends CfRoutesListConfigBase implements
map(loading => !loading),
startWith(true)
);

cfOrgSpaceService.cf.select.next(cfService.cfGuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class ServiceInstancesWallListConfigService extends CfServiceInstancesLis
breadcrumbs: 'service-wall'
};

this.cfOrgSpaceService.setInitialValuesFromAction(this.dataSource.masterAction, 'cf', 'org', 'space');
this.getInitialised = () => combineLatest(
cfOrgSpaceService.cf.list$,
cfOrgSpaceService.org.list$,
Expand Down
Loading

0 comments on commit 463a1c3

Please sign in to comment.