@softheon/armature 21.0.1 → 21.1.0-alpha
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,27 @@ 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) {
|
|
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;
|
|
6662
6668
|
/** The MFE Queue Lookup Constant Key for Cookie Storage */
|
|
6663
6669
|
this.MFE_QUEUE_LOOKUP = 'mfe.graphql-domain';
|
|
6670
|
+
/** The cookie key for local environment selection */
|
|
6671
|
+
this.LOCAL_ENV_COOKIE = 'localEnvSelected';
|
|
6664
6672
|
/* Open Modal Subject */
|
|
6665
6673
|
this.modalOpenSubject = new BehaviorSubject(false);
|
|
6666
6674
|
/* Disabled Dropdown Subject */
|
|
6667
6675
|
this.disabledDropdownSubject = new BehaviorSubject(false);
|
|
6676
|
+
/** Local Environment Selected Subject */
|
|
6677
|
+
this.localEnvSelectedSubject = new BehaviorSubject(false);
|
|
6678
|
+
/** Local Environment Selection Enabled Subject */
|
|
6679
|
+
this.localEnvSelectionEnabledSubject = new BehaviorSubject(false);
|
|
6668
6680
|
/* Modal Open Observable */
|
|
6669
6681
|
this.modalOpen$ = this.modalOpenSubject.asObservable();
|
|
6670
6682
|
/* Selected Market Observable */
|
|
@@ -6673,6 +6685,10 @@ class MarketSelectionService {
|
|
|
6673
6685
|
this.ephemeralMarket$ = of(null);
|
|
6674
6686
|
/* Disabled Dropdown Observable */
|
|
6675
6687
|
this.disabledDropdown$ = this.disabledDropdownSubject.asObservable();
|
|
6688
|
+
/** Local Environment Selected Observable */
|
|
6689
|
+
this.localEnvSelected$ = this.localEnvSelectedSubject.asObservable();
|
|
6690
|
+
/** Local Environment Selection Enabled Observable */
|
|
6691
|
+
this.localEnvSelectionEnabled$ = this.localEnvSelectionEnabledSubject.asObservable();
|
|
6676
6692
|
/* Favorite Market */
|
|
6677
6693
|
this.favoriteMarket = [];
|
|
6678
6694
|
/** Disabled URLs */
|
|
@@ -6681,6 +6697,10 @@ class MarketSelectionService {
|
|
|
6681
6697
|
this.markets = [];
|
|
6682
6698
|
this.selectedMarket$ = this.selectedMarketContext.selectedMarket$;
|
|
6683
6699
|
this.ephemeralMarket$ = this.selectedMarketContext.ephemeralMarket$;
|
|
6700
|
+
this.oAuthService.loadUserProfile().then((user) => {
|
|
6701
|
+
this.userEmail = user?.info?.email;
|
|
6702
|
+
this.evaluateLocalEnvSelectionEnabled();
|
|
6703
|
+
});
|
|
6684
6704
|
this.router.events.subscribe((event) => {
|
|
6685
6705
|
if (event instanceof NavigationEnd) {
|
|
6686
6706
|
this.disabledDropdownSubject.next(this.isUrlDisabled(event.urlAfterRedirects));
|
|
@@ -6690,6 +6710,7 @@ class MarketSelectionService {
|
|
|
6690
6710
|
if (config && this.isEnabled) {
|
|
6691
6711
|
this.initializeConfig();
|
|
6692
6712
|
this.disabledDropdownSubject.next(this.isUrlDisabled(router.url));
|
|
6713
|
+
this.evaluateLocalEnvSelectionEnabled();
|
|
6693
6714
|
}
|
|
6694
6715
|
});
|
|
6695
6716
|
}
|
|
@@ -6706,6 +6727,7 @@ class MarketSelectionService {
|
|
|
6706
6727
|
* @param selection
|
|
6707
6728
|
*/
|
|
6708
6729
|
updateSelectedMarket(selection) {
|
|
6730
|
+
this.clearLocalEnvSelection();
|
|
6709
6731
|
this.cookieService.delete('selectedMarket', '/');
|
|
6710
6732
|
this.cookieService.set('selectedMarket', JSON.stringify({
|
|
6711
6733
|
name: selection.name
|
|
@@ -6717,14 +6739,8 @@ class MarketSelectionService {
|
|
|
6717
6739
|
else {
|
|
6718
6740
|
window.sessionStorage.removeItem(this.MFE_QUEUE_LOOKUP);
|
|
6719
6741
|
}
|
|
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
6742
|
this.selectedMarketContext.setMarket(selection);
|
|
6743
|
+
this.dispatchRefreshEvents();
|
|
6728
6744
|
}
|
|
6729
6745
|
/**
|
|
6730
6746
|
* Set Ephemeral Market
|
|
@@ -6815,6 +6831,21 @@ class MarketSelectionService {
|
|
|
6815
6831
|
closeModal() {
|
|
6816
6832
|
this.modalOpenSubject.next(false);
|
|
6817
6833
|
}
|
|
6834
|
+
/**
|
|
6835
|
+
* Select Local Environment
|
|
6836
|
+
* Switches to local env, clearing any selected market
|
|
6837
|
+
*/
|
|
6838
|
+
selectLocalEnv() {
|
|
6839
|
+
if (!this.isLocalEnvSelectionEnabled) {
|
|
6840
|
+
return;
|
|
6841
|
+
}
|
|
6842
|
+
this.cookieService.delete('selectedMarket', '/');
|
|
6843
|
+
window.sessionStorage.removeItem(this.MFE_QUEUE_LOOKUP);
|
|
6844
|
+
this.selectedMarketContext.setMarket(null);
|
|
6845
|
+
this.localEnvSelectedSubject.next(true);
|
|
6846
|
+
this.cookieService.set(this.LOCAL_ENV_COOKIE, 'true', { path: '/' });
|
|
6847
|
+
this.dispatchRefreshEvents();
|
|
6848
|
+
}
|
|
6818
6849
|
/**
|
|
6819
6850
|
* Load Favorite Markets from Cookies
|
|
6820
6851
|
*/
|
|
@@ -6828,6 +6859,10 @@ class MarketSelectionService {
|
|
|
6828
6859
|
* Load Market from Cookies
|
|
6829
6860
|
*/
|
|
6830
6861
|
loadMarketFromCookies() {
|
|
6862
|
+
if (this.isLocalEnvSelectionEnabled && this.cookieService.get(this.LOCAL_ENV_COOKIE) === 'true') {
|
|
6863
|
+
this.localEnvSelectedSubject.next(true);
|
|
6864
|
+
return;
|
|
6865
|
+
}
|
|
6831
6866
|
const selectedJson = this.cookieService.get('selectedMarket');
|
|
6832
6867
|
if (selectedJson) {
|
|
6833
6868
|
const selectedMarket = JSON.parse(selectedJson);
|
|
@@ -6840,6 +6875,36 @@ class MarketSelectionService {
|
|
|
6840
6875
|
this.updateSelectedMarket(firstMarket);
|
|
6841
6876
|
}
|
|
6842
6877
|
}
|
|
6878
|
+
/**
|
|
6879
|
+
* Evaluate whether local environment selection should be enabled
|
|
6880
|
+
*/
|
|
6881
|
+
evaluateLocalEnvSelectionEnabled() {
|
|
6882
|
+
const marketConfig = this.config?.config?.marketSelectionConfig;
|
|
6883
|
+
if (!marketConfig?.enableLocalEnvSelection) {
|
|
6884
|
+
this.localEnvSelectionEnabledSubject.next(false);
|
|
6885
|
+
return;
|
|
6886
|
+
}
|
|
6887
|
+
if (marketConfig?.enableLocalEnvSelectionExternally) {
|
|
6888
|
+
this.localEnvSelectionEnabledSubject.next(true);
|
|
6889
|
+
return;
|
|
6890
|
+
}
|
|
6891
|
+
this.localEnvSelectionEnabledSubject.next(!!this.userEmail && this.userEmail.endsWith('@softheon.com'));
|
|
6892
|
+
}
|
|
6893
|
+
/**
|
|
6894
|
+
* Clear local environment selection state and cookie
|
|
6895
|
+
*/
|
|
6896
|
+
clearLocalEnvSelection() {
|
|
6897
|
+
this.localEnvSelectedSubject.next(false);
|
|
6898
|
+
this.cookieService.delete(this.LOCAL_ENV_COOKIE, '/');
|
|
6899
|
+
}
|
|
6900
|
+
/**
|
|
6901
|
+
* Dispatch Refresh Events
|
|
6902
|
+
*/
|
|
6903
|
+
dispatchRefreshEvents() {
|
|
6904
|
+
document.dispatchEvent(new CustomEvent('close-entity-view', { detail: { guid: 'all' } }));
|
|
6905
|
+
document.dispatchEvent(new CustomEvent('refresh-queues'));
|
|
6906
|
+
document.dispatchEvent(new CustomEvent('refresh-table'));
|
|
6907
|
+
}
|
|
6843
6908
|
/**
|
|
6844
6909
|
* Is URL Disabled
|
|
6845
6910
|
* @param currentUrl
|
|
@@ -6903,7 +6968,7 @@ class MarketSelectionService {
|
|
|
6903
6968
|
return undefined;
|
|
6904
6969
|
}
|
|
6905
6970
|
}
|
|
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 }); }
|
|
6971
|
+
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 }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
6907
6972
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MarketSelectionService, providedIn: 'root' }); }
|
|
6908
6973
|
}
|
|
6909
6974
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MarketSelectionService, decorators: [{
|
|
@@ -6911,7 +6976,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
|
|
|
6911
6976
|
args: [{
|
|
6912
6977
|
providedIn: 'root'
|
|
6913
6978
|
}]
|
|
6914
|
-
}], ctorParameters: () => [{ type: i1$a.CookieService }, { type: i1$4.Router }, { type: BaseConfigService }, { type: SelectedMarketContext }, { type: i2$1.TranslateService }] });
|
|
6979
|
+
}], ctorParameters: () => [{ type: i1$a.CookieService }, { type: i1$4.Router }, { type: BaseConfigService }, { type: SelectedMarketContext }, { type: i2$1.TranslateService }, { type: i1$2.OAuthService }] });
|
|
6915
6980
|
|
|
6916
6981
|
/* Market Selection Config */
|
|
6917
6982
|
class MarketSelectionConfig {
|