Skip to content

Commit

Permalink
allow all zones for beta testers (#1188)
Browse files Browse the repository at this point in the history
* allow all zones for beta testers

* apply feature flagging in zones in NUA key creation
  • Loading branch information
ebrehault authored Dec 12, 2023
1 parent 99d11c9 commit f53d3d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { filter, map, take, tap } from 'rxjs';
import { NUAClient } from '@nuclia/core';
import { SDKService, UserService } from '@flaps/core';
import { SDKService, UserService, Zone, ZoneService } from '@flaps/core';
import { AccountNUAService } from '../account-nua.service';
import { ModalRef } from '@guillotinaweb/pastanaga-angular';

Expand Down Expand Up @@ -53,23 +53,23 @@ export class ClientDialogComponent implements OnInit {
},
};

zones: { id: string; title: string }[] = [];
zones: Zone[] = [];

constructor(
public modal: ModalRef,
private userService: UserService,
private nua: AccountNUAService,
private sdkService: SDKService,
private cdr: ChangeDetectorRef,
private zoneService: ZoneService,
) {
this.editMode = !!this.modal.config.data?.['client'];
}

ngOnInit() {
this.sdkService.nuclia.rest
this.zoneService
.getZones()
.pipe(
map((zoneMap) => Object.entries(zoneMap).map(([key, title]) => ({ id: key, title }))),
tap((zones) => {
this.zones = zones;
this.cdr.detectChanges();
Expand Down
17 changes: 11 additions & 6 deletions libs/core/src/lib/api/zone.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@ export class ZoneService {
) {}

getZones(includeZonesBlocked = false): Observable<Zone[]> {
const isRegionalSystemBetaTester = localStorage.getItem('NUCLIA_NEW_REGIONAL_ENDPOINTS') === 'true';
return this.sdk.nuclia.rest.get<Zone[]>(`/${ZONES}`).pipe(
switchMap((zones) =>
this.featureFlagService.getFeatureBlocklist('zones').pipe(
map((blocklist) => {
return includeZonesBlocked
? zones.map((zone) => ({
...zone,
notAvailableYet: blocklist.includes(zone.slug),
}))
: zones.filter((zone) => !blocklist.includes(zone.slug));
if (isRegionalSystemBetaTester) {
return zones;
} else {
return includeZonesBlocked
? zones.map((zone) => ({
...zone,
notAvailableYet: blocklist.includes(zone.slug),
}))
: zones.filter((zone) => !blocklist.includes(zone.slug));
}
}),
),
),
Expand Down

0 comments on commit f53d3d7

Please sign in to comment.