Add a guard function based on IAM version
Prevent the introspect_projects call unless V2p1 or greater.
import { Injectable } from '@angular/core';
import { HttpErrorResponse } from '@angular/common/http';
+import { Store } from '@ngrx/store';
import { Actions, Effect, ofType } from '@ngrx/effects';
+import { NgrxStateAtom } from 'app/ngrx.reducers';
import { interval as observableInterval, of as observableOf, Observable } from 'rxjs';
-import { catchError, mergeMap, map, tap } from 'rxjs/operators';
+import { catchError, mergeMap, map, tap, withLatestFrom, filter } from 'rxjs/operators';
+import { atLeastV2p1 } from 'app/entities/policies/policy.selectors';
import { Project } from 'app/entities/projects/project.model';
import { ProjectsFilterOption, ProjectsFilterOptionTuple } from './projects-filter.reducer';
import { ProjectsFilterService } from './projects-filter.service';
@@ -21,6 +24,7 @@ import {
export class ProjectsFilterEffects {
constructor(
private actions$: Actions,
+ private store: Store<NgrxStateAtom>,
private projectsFilter: ProjectsFilterService,
private requests: ProjectsFilterRequests
) { }
@@ -28,8 +32,10 @@ export class ProjectsFilterEffects {
private POLLING_INTERVAL_IN_SECONDS = 120; // 2 minutes
@Effect()
- latestOptions$ = observableInterval(1000 * this.POLLING_INTERVAL_IN_SECONDS)
- .pipe(mergeMap(this.loadOptionsAction$()));
+ latestOptions$ = observableInterval(1000 * this.POLLING_INTERVAL_IN_SECONDS).pipe(
+ withLatestFrom(this.store.select(atLeastV2p1)),
+ filter(([_, projectsEnabled]) => projectsEnabled),
+ mergeMap(this.loadOptionsAction$()));
@Effect()
loadOptions$ = this.actions$.pipe(
