Skip to content

Commit 06242a6

Browse files
authored
Merge pull request #559 from SUSE/fix-refresh-maxed-list
Fix application of `maxed` lists following page refresh
2 parents b4438a9 + 69f6a91 commit 06242a6

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ jobs:
3838
- name: Backend Lint
3939
before_script:
4040
- "./deploy/ci/travis/install-go.sh"
41-
- go get -u golang.org/x/lint/golint
41+
- export GO111MODULE=on
42+
- go get golang.org/x/lint/[email protected]
4243
script:
4344
- golint src/jetstream/...
4445
- ./deploy/ci/travis/update-go-report-card.sh

src/frontend/packages/core/src/shared/components/list/list.component.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Store } from '@ngrx/store';
2222
import {
2323
asapScheduler,
2424
BehaviorSubject,
25+
combineLatest,
2526
combineLatest as observableCombineLatest,
2627
isObservable,
2728
Observable,
@@ -39,6 +40,7 @@ import {
3940
refCount,
4041
startWith,
4142
subscribeOn,
43+
switchMap,
4244
takeWhile,
4345
tap,
4446
withLatestFrom,
@@ -468,7 +470,13 @@ export class ListComponent<T> implements OnInit, OnChanges, OnDestroy, AfterView
468470
// - Pass any multi filter changes made by the user to the pagination controller and thus the store
469471
// - If the first multi filter has one value it's not shown, ensure it's automatically selected to ensure other filters are correct
470472
this.multiFilterWidgetObservables = new Array<Subscription>();
471-
this.paginationController.filter$.pipe(
473+
474+
combineLatest(this.multiFilterManagers.map(mfm => {
475+
// Use this instead of filterIsReady$ to ensure the drop downs report as ready even when there's nothing to select
476+
return mfm.filterIsInitialised$;
477+
})).pipe(
478+
filter(firs => firs.every(ready => ready)),
479+
switchMap(() => this.paginationController.filter$),
472480
first(),
473481
tap(() => {
474482
Object.values(this.multiFilterManagers).forEach((filterManager: MultiFilterManager<T>, index: number) => {

src/frontend/packages/core/src/shared/components/list/list.component.types.ts

+26
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,18 @@ export interface IGlobalListAction<T> extends IOptionalAction<T> {
203203
action: () => void;
204204
}
205205

206+
/**
207+
* Class to support a single multi filter entry/drop down
208+
*/
206209
export class MultiFilterManager<T> {
210+
/**
211+
* Supporting dependencies ready and there are items available to select
212+
*/
207213
public filterIsReady$: Observable<boolean>;
214+
/**
215+
* Supporting dependencies ready and the items to select have been fetched (but may be zero)
216+
*/
217+
public filterIsInitialised$: Observable<boolean>;
208218
public filterItems$: Observable<IListMultiFilterConfigItem[]>;
209219
public hasItems$: Observable<boolean>;
210220
public hasOneOrLessItems$: Observable<boolean>;
@@ -225,6 +235,7 @@ export class MultiFilterManager<T> {
225235
this.hasOneOrLessItems$ = this.filterItems$.pipe(map(items => items.length <= 1));
226236
this.hasItems$ = this.filterItems$.pipe(map(items => !!items.length));
227237
this.filterIsReady$ = this.getReadyObservable(multiFilterConfig, dataSource, this.hasItems$);
238+
this.filterIsInitialised$ = this.getInitialisedObservable(multiFilterConfig, dataSource, this.filterItems$);
228239

229240
// Also select the first option if configured
230241
if (multiFilterConfig.autoSelectFirst) {
@@ -251,6 +262,21 @@ export class MultiFilterManager<T> {
251262
);
252263
}
253264

265+
private getInitialisedObservable(
266+
multiFilterConfig: IListMultiFilterConfig,
267+
dataSource: IListDataSource<T>,
268+
filterItems$: Observable<IListMultiFilterConfigItem[]>
269+
) {
270+
return combineLatest(
271+
dataSource.isLoadingPage$,
272+
multiFilterConfig.loading$,
273+
filterItems$,
274+
).pipe(
275+
map(([fetchingListPage, fetchingFilter, filterItems]) => (!fetchingListPage && !fetchingFilter) && !!filterItems),
276+
startWith(false)
277+
);
278+
}
279+
254280
private getItemObservable(multiFilterConfig: IListMultiFilterConfig) {
255281
return multiFilterConfig.list$.pipe(
256282
map(list => list ? list : [])

src/frontend/packages/store/src/helpers/local-storage-service.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ export class LocalStorageService {
173173
params: paginationSection.params,
174174
clientPagination: paginationSection.clientPagination,
175175
isListPagination: paginationSection.isListPagination, // We do not persist any that are false
176-
forcedLocalPage: paginationSection.forcedLocalPage // Value of the multi-entity filter
176+
forcedLocalPage: paginationSection.forcedLocalPage, // Value of the multi-entity filter
177+
// Persist this state, so the console knows to set q params on filter change (means user is stuck in max'd view)
178+
maxedState: paginationSection.maxedState
177179
};
178180
return res2;
179181
}, {});

0 commit comments

Comments
 (0)