@equinor/fusion-framework-react-app 4.3.1 → 4.3.2-next-ce5e102136d9a95deeb8e421cefa47b7a50ac733

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.3.2-next-ce5e102136d9a95deeb8e421cefa47b7a50ac733
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1781](https://github.com/equinor/fusion-framework/pull/1781) [`51fc353`](https://github.com/equinor/fusion-framework/commit/51fc353fd7f0f252fb5dd0f658bc86776e58c89d) Thanks [@odinr](https://github.com/odinr)! - Added functionality for enabling feature flagging
8
+
9
+ ```ts
10
+ import { enableFeatureFlag } from `@equinor/fusion-framework-react-app/feature-flag`
11
+ enableFeatureFlag(confgurator, [{
12
+ id: 'my-flag',
13
+ title: 'My flag'
14
+ }])
15
+ ```
16
+
17
+ the user still needs to install `@equinor/fusion-framework-module-feature-flag`
18
+
19
+ - Updated dependencies [[`16335bf`](https://github.com/equinor/fusion-framework/commit/16335bf8092b1198367d3ddb93068a8b575b885b)]:
20
+ - @equinor/fusion-framework-app@8.1.0-next-ce5e102136d9a95deeb8e421cefa47b7a50ac733
21
+
3
22
  ## 4.3.1
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -89,4 +89,37 @@ const App = () => {
89
89
  },[barClient]);
90
90
 
91
91
  }
92
- ```
92
+ ```
93
+
94
+ ## Feature Flag
95
+
96
+ > [!IMPORTANT]
97
+ > `@equinor/fusion-framework-module-feature-flag` must be installed to make this module available
98
+
99
+ ### Simple
100
+ ```ts
101
+ import { enableFeatureFlag } from '@equinor/fusion-framework-react-app/feature-flag';
102
+ export const configure: ModuleInitiator = (appConfigurator, args) => {
103
+ /** provide a list of features that should be available in the application */
104
+ enableFeatureFlag(appConfigurator, [
105
+ {
106
+ key: MyFeatures.MyFlag,
107
+ title: 'this is a flag',
108
+ },
109
+ {
110
+ key: MyFeatures.MyUrlFlag,
111
+ title: 'this feature can be toggled by ?my-url-flag=true',
112
+ allowUrl: true,
113
+ }
114
+ ]);
115
+ }
116
+ ```
117
+
118
+ ### Custom
119
+ ```ts
120
+ export const configure: ModuleInitiator = (appConfigurator, args) => {
121
+ appConfigurator.useFeatureFlags(builder => /** see module for building custom config */);
122
+ }
123
+ ```
124
+
125
+ [see module](../modules/feature-flag/README.md) for more technical information;
@@ -0,0 +1,49 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import { enableFeatureFlagging, } from '@equinor/fusion-framework-module-feature-flag';
22
+ import { createLocalStoragePlugin, createUrlPlugin, } from '@equinor/fusion-framework-module-feature-flag/plugins';
23
+ export function enableFeatureFlag(configurator, flags_cb) {
24
+ switch (typeof flags_cb) {
25
+ case 'function': {
26
+ enableFeatureFlagging(configurator, flags_cb);
27
+ break;
28
+ }
29
+ case 'object': {
30
+ const urlFlags = [];
31
+ const localFlags = (flags_cb !== null && flags_cb !== void 0 ? flags_cb : []).map((flag) => {
32
+ const { allowUrl } = flag, localFlag = __rest(flag, ["allowUrl"]);
33
+ if (allowUrl) {
34
+ urlFlags.push(flag);
35
+ }
36
+ return localFlag;
37
+ });
38
+ enableFeatureFlagging(configurator, (builder) => __awaiter(this, void 0, void 0, function* () {
39
+ var _a;
40
+ builder.addPlugin(createLocalStoragePlugin(localFlags, {
41
+ name: (_a = configurator.env) === null || _a === void 0 ? void 0 : _a.manifest.key,
42
+ }));
43
+ builder.addPlugin(createUrlPlugin(urlFlags));
44
+ }));
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ //# sourceMappingURL=enable-feature-flag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enable-feature-flag.js","sourceRoot":"","sources":["../../../src/feature-flag/enable-feature-flag.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EACH,qBAAqB,GAGxB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EACH,wBAAwB,EACxB,eAAe,GAClB,MAAM,uDAAuD,CAAC;AAiC/D,MAAM,UAAU,iBAAiB,CAC7B,YAA8B,EAC9B,QAEgC;IAEhC,QAAQ,OAAO,QAAQ,EAAE,CAAC;QACtB,KAAK,UAAU,CAAC,CAAC,CAAC;YACd,qBAAqB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YAC9C,MAAM;QACV,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACZ,MAAM,QAAQ,GAAmB,EAAE,CAAC;YACpC,MAAM,UAAU,GAAG,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC7C,MAAM,EAAE,QAAQ,KAAmB,IAAI,EAAlB,SAAS,UAAK,IAAI,EAAjC,YAA0B,CAAO,CAAC;gBACxC,IAAI,QAAQ,EAAE,CAAC;oBACX,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxB,CAAC;gBACD,OAAO,SAAS,CAAC;YACrB,CAAC,CAAC,CAAC;YACH,qBAAqB,CAAC,YAAY,EAAE,CAAO,OAAO,EAAE,EAAE;;gBAClD,OAAO,CAAC,SAAS,CACb,wBAAwB,CAAC,UAAU,EAAE;oBACjC,IAAI,EAAE,MAAC,YAAgC,CAAC,GAAG,0CAAE,QAAQ,CAAC,GAAG;iBAC5D,CAAC,CACL,CAAC;gBACF,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;YACjD,CAAC,CAAA,CAAC,CAAC;YACH,MAAM;QACV,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -1,2 +1,3 @@
1
+ export { enableFeatureFlag } from './enable-feature-flag';
1
2
  export { useFeature } from './useFeature';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-flag/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-flag/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}