decentraland-dapps 23.22.0 → 23.23.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LoadingState } from '../loading/reducer';
|
|
2
2
|
import { FeaturesState } from './reducer';
|
|
3
|
-
import { ApplicationName, ApplicationFeatures, StateWithFeatures } from './types';
|
|
3
|
+
import { ApplicationName, ApplicationFeatures, StateWithFeatures, Variant } from './types';
|
|
4
4
|
export declare const getState: (state: StateWithFeatures) => FeaturesState;
|
|
5
5
|
export declare const getData: (state: StateWithFeatures) => Record<ApplicationName, ApplicationFeatures>;
|
|
6
6
|
export declare const getLoading: (state: StateWithFeatures) => LoadingState;
|
|
@@ -22,4 +22,5 @@ export declare const getError: (state: StateWithFeatures) => string | null;
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const getIsFeatureEnabled: (state: StateWithFeatures, app: ApplicationName, feature: string) => boolean;
|
|
24
24
|
export declare const isLoadingFeatureFlags: (state: StateWithFeatures) => boolean;
|
|
25
|
+
export declare const getFeatureVariant: (state: StateWithFeatures, app: ApplicationName, feature: string) => Variant | null;
|
|
25
26
|
export declare const hasLoadedInitialFlags: (state: StateWithFeatures) => boolean;
|
|
@@ -45,6 +45,29 @@ export const getIsFeatureEnabled = (state, app, feature) => {
|
|
|
45
45
|
export const isLoadingFeatureFlags = (state) => {
|
|
46
46
|
return isLoadingType(getLoading(state), FETCH_APPLICATION_FEATURES_REQUEST);
|
|
47
47
|
};
|
|
48
|
+
export const getFeatureVariant = (state, app, feature) => {
|
|
49
|
+
const variant = getVariantFromEnv(app, feature);
|
|
50
|
+
// Return the flag variant if it has been defined in the env.
|
|
51
|
+
// If flag variants are only defined in the env, there is no need to implement the features reducer.
|
|
52
|
+
if (variant !== null) {
|
|
53
|
+
// Build the variant object
|
|
54
|
+
return {
|
|
55
|
+
name: 'Local variant',
|
|
56
|
+
enabled: true,
|
|
57
|
+
payload: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
value: variant
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const appFeatures = getData(state)[app];
|
|
64
|
+
// The app might not be defined in the store because the flag variants might not have been fetched yet.
|
|
65
|
+
// We suggest using isLoadingFeatureFlags and hasLoadedInitialFlags to handle this first.
|
|
66
|
+
if (!appFeatures) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return appFeatures.variants[`${app}-${feature}`] || null;
|
|
70
|
+
};
|
|
48
71
|
export const hasLoadedInitialFlags = (state) => {
|
|
49
72
|
return getState(state).hasLoadedInitialFlags;
|
|
50
73
|
};
|
|
@@ -54,4 +77,10 @@ const getFromEnv = (application, flag) => {
|
|
|
54
77
|
const value = process.env[key];
|
|
55
78
|
return !value || value === '' ? null : value === '1' ? true : false;
|
|
56
79
|
};
|
|
80
|
+
const getVariantFromEnv = (application, flag) => {
|
|
81
|
+
const envify = (word) => word.toUpperCase().replace(/-/g, '_');
|
|
82
|
+
const key = `REACT_APP_FF_VARIANT_${envify(application)}_${envify(flag)}`;
|
|
83
|
+
const value = process.env[key];
|
|
84
|
+
return !value || value === '' ? null : value;
|
|
85
|
+
};
|
|
57
86
|
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/modules/features/selectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/modules/features/selectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,WAAW,CAAA;AAS9D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAwB,EAAiB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