@softheon/armature 21.0.1 → 21.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6645,6 +6645,10 @@ class MarketSelectionService {
6645
6645
  get isEnabled() {
6646
6646
  return !!this.config?.config?.marketSelectionConfig;
6647
6647
  }
6648
+ /** Whether local environment selection is currently enabled */
6649
+ get isLocalEnvSelectionEnabled() {
6650
+ return this.localEnvSelectionEnabledSubject.value;
6651
+ }
6648
6652
  /**
6649
6653
  * Constructor
6650
6654
  * @param cookieService cookie service
@@ -6652,19 +6656,28 @@ class MarketSelectionService {
6652
6656
  * @param config config
6653
6657
  * @param selectedMarketContext selected market context
6654
6658
  * @param translateService translate service
6659
+ * @param userEntityService user entity service
6655
6660
  */
6656
- constructor(cookieService, router, config, selectedMarketContext, translateService) {
6661
+ constructor(cookieService, router, config, selectedMarketContext, translateService, oAuthService, authorizationService) {
6657
6662
  this.cookieService = cookieService;
6658
6663
  this.router = router;
6659
6664
  this.config = config;
6660
6665
  this.selectedMarketContext = selectedMarketContext;
6661
6666
  this.translateService = translateService;
6667
+ this.oAuthService = oAuthService;
6668
+ this.authorizationService = authorizationService;
6662
6669
  /** The MFE Queue Lookup Constant Key for Cookie Storage */
6663
6670
  this.MFE_QUEUE_LOOKUP = 'mfe.graphql-domain';
6671
+ /** The cookie key for local environment selection */
6672
+ this.LOCAL_ENV_COOKIE = 'localEnvSelected';
6664
6673
  /* Open Modal Subject */
6665
6674
  this.modalOpenSubject = new BehaviorSubject(false);
6666
6675
  /* Disabled Dropdown Subject */
6667
6676
  this.disabledDropdownSubject = new BehaviorSubject(false);
6677
+ /** Local Environment Selected Subject */
6678
+ this.localEnvSelectedSubject = new BehaviorSubject(false);
6679
+ /** Local Environment Selection Enabled Subject */
6680
+ this.localEnvSelectionEnabledSubject = new BehaviorSubject(false);
6668
6681
  /* Modal Open Observable */
6669
6682
  this.modalOpen$ = this.modalOpenSubject.asObservable();
6670
6683
  /* Selected Market Observable */
@@ -6673,6 +6686,10 @@ class MarketSelectionService {
6673
6686
  this.ephemeralMarket$ = of(null);
6674
6687
  /* Disabled Dropdown Observable */
6675
6688
  this.disabledDropdown$ = this.disabledDropdownSubject.asObservable();
6689
+ /** Local Environment Selected Observable */
6690
+ this.localEnvSelected$ = this.localEnvSelectedSubject.asObservable();
6691
+ /** Local Environment Selection Enabled Observable */
6692
+ this.localEnvSelectionEnabled$ = this.localEnvSelectionEnabledSubject.asObservable();
6676
6693
  /* Favorite Market */
6677
6694
  this.favoriteMarket = [];
6678
6695
  /** Disabled URLs */
@@ -6681,6 +6698,13 @@ class MarketSelectionService {
6681
6698
  this.markets = [];
6682
6699
  this.selectedMarket$ = this.selectedMarketContext.selectedMarket$;
6683
6700
  this.ephemeralMarket$ = this.selectedMarketContext.ephemeralMarket$;
6701
+ this.authorizationService.isLoggedIn$.subscribe((isLoggedIn) => {
6702
+ if (isLoggedIn) {
6703
+ const claims = this.oAuthService.getIdentityClaims();
6704
+ this.userEmail = claims?.upn || claims?.preferred_username || '';
6705
+ this.evaluateLocalEnvSelectionEnabled();
6706
+ }
6707
+ });
6684
6708
  this.router.events.subscribe((event) => {
6685
6709
  if (event instanceof NavigationEnd) {
6686
6710
  this.disabledDropdownSubject.next(this.isUrlDisabled(event.urlAfterRedirects));
@@ -6690,6 +6714,7 @@ class MarketSelectionService {
6690
6714
  if (config && this.isEnabled) {
6691
6715
  this.initializeConfig();
6692
6716
  this.disabledDropdownSubject.next(this.isUrlDisabled(router.url));
6717
+ this.evaluateLocalEnvSelectionEnabled();
6693
6718
  }
6694
6719
  });
6695
6720
  }
@@ -6706,6 +6731,7 @@ class MarketSelectionService {
6706
6731
  * @param selection
6707
6732
  */
6708
6733
  updateSelectedMarket(selection) {
6734
+ this.clearLocalEnvSelection();
6709
6735
  this.cookieService.delete('selectedMarket', '/');
6710
6736
  this.cookieService.set('selectedMarket', JSON.stringify({
6711
6737
  name: selection.name
@@ -6717,14 +6743,8 @@ class MarketSelectionService {
6717
6743
  else {
6718
6744
  window.sessionStorage.removeItem(this.MFE_QUEUE_LOOKUP);
6719
6745
  }
6720
- document.dispatchEvent(new CustomEvent('close-entity-view', {
6721
- detail: {
6722
- guid: 'all'
6723
- }
6724
- }));
6725
- document.dispatchEvent(new CustomEvent('refresh-queues'));
6726
- document.dispatchEvent(new CustomEvent('refresh-table'));
6727
6746
  this.selectedMarketContext.setMarket(selection);
6747
+ this.dispatchRefreshEvents();
6728
6748
  }
6729
6749
  /**
6730
6750
  * Set Ephemeral Market
@@ -6815,6 +6835,21 @@ class MarketSelectionService {
6815
6835
  closeModal() {
6816
6836
  this.modalOpenSubject.next(false);
6817
6837
  }
6838
+ /**
6839
+ * Select Local Environment
6840
+ * Switches to local env, clearing any selected market
6841
+ */
6842
+ selectLocalEnv() {
6843
+ if (!this.isLocalEnvSelectionEnabled) {
6844
+ return;
6845
+ }
6846
+ this.cookieService.delete('selectedMarket', '/');
6847
+ window.sessionStorage.removeItem(this.MFE_QUEUE_LOOKUP);
6848
+ this.selectedMarketContext.setMarket(null);
6849
+ this.localEnvSelectedSubject.next(true);
6850
+ this.cookieService.set(this.LOCAL_ENV_COOKIE, 'true', { path: '/' });
6851
+ this.dispatchRefreshEvents();
6852
+ }
6818
6853
  /**
6819
6854
  * Load Favorite Markets from Cookies
6820
6855
  */
@@ -6828,6 +6863,10 @@ class MarketSelectionService {
6828
6863
  * Load Market from Cookies
6829
6864
  */
6830
6865
  loadMarketFromCookies() {
6866
+ if (this.isLocalEnvSelectionEnabled && this.cookieService.get(this.LOCAL_ENV_COOKIE) === 'true') {
6867
+ this.localEnvSelectedSubject.next(true);
6868
+ return;
6869
+ }
6831
6870
  const selectedJson = this.cookieService.get('selectedMarket');
6832
6871
  if (selectedJson) {
6833
6872
  const selectedMarket = JSON.parse(selectedJson);
@@ -6840,6 +6879,36 @@ class MarketSelectionService {
6840
6879
  this.updateSelectedMarket(firstMarket);
6841
6880
  }
6842
6881
  }
6882
+ /**
6883
+ * Evaluate whether local environment selection should be enabled
6884
+ */
6885
+ evaluateLocalEnvSelectionEnabled() {
6886
+ const marketConfig = this.config?.config?.marketSelectionConfig;
6887
+ if (!marketConfig?.enableLocalEnvSelection) {
6888
+ this.localEnvSelectionEnabledSubject.next(false);
6889
+ return;
6890
+ }
6891
+ if (marketConfig?.enableLocalEnvSelectionExternally) {
6892
+ this.localEnvSelectionEnabledSubject.next(true);
6893
+ return;
6894
+ }
6895
+ this.localEnvSelectionEnabledSubject.next(!!this.userEmail && this.userEmail.endsWith('@softheon.com'));
6896
+ }
6897
+ /**
6898
+ * Clear local environment selection state and cookie
6899
+ */
6900
+ clearLocalEnvSelection() {
6901
+ this.localEnvSelectedSubject.next(false);
6902
+ this.cookieService.delete(this.LOCAL_ENV_COOKIE, '/');
6903
+ }
6904
+ /**
6905
+ * Dispatch Refresh Events
6906
+ */
6907
+ dispatchRefreshEvents() {
6908
+ document.dispatchEvent(new CustomEvent('close-entity-view', { detail: { guid: 'all' } }));
6909
+ document.dispatchEvent(new CustomEvent('refresh-queues'));
6910
+ document.dispatchEvent(new CustomEvent('refresh-table'));
6911
+ }
6843
6912
  /**
6844
6913
  * Is URL Disabled
6845
6914
  * @param currentUrl
@@ -6903,7 +6972,7 @@ class MarketSelectionService {
6903
6972
  return undefined;
6904
6973
  }
6905
6974
  }
6906
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MarketSelectionService, deps: [{ token: i1$a.CookieService }, { token: i1$4.Router }, { token: BaseConfigService }, { token: SelectedMarketContext }, { token: i2$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
6975
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MarketSelectionService, deps: [{ token: i1$a.CookieService }, { token: i1$4.Router }, { token: BaseConfigService }, { token: SelectedMarketContext }, { token: i2$1.TranslateService }, { token: i1$2.OAuthService }, { token: AuthorizationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
6907
6976
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MarketSelectionService, providedIn: 'root' }); }
6908
6977
  }
6909
6978
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MarketSelectionService, decorators: [{
@@ -6911,7 +6980,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
6911
6980
  args: [{
6912
6981
  providedIn: 'root'
6913
6982
  }]
6914
- }], ctorParameters: () => [{ type: i1$a.CookieService }, { type: i1$4.Router }, { type: BaseConfigService }, { type: SelectedMarketContext }, { type: i2$1.TranslateService }] });
6983
+ }], ctorParameters: () => [{ type: i1$a.CookieService }, { type: i1$4.Router }, { type: BaseConfigService }, { type: SelectedMarketContext }, { type: i2$1.TranslateService }, { type: i1$2.OAuthService }, { type: AuthorizationService }] });
6915
6984
 
6916
6985
  /* Market Selection Config */
6917
6986
  class MarketSelectionConfig {