[core/api/plugins] added featureFlags.registerFeatureFlag

This commit is contained in:
Bilawal Hameed
2020-03-26 11:34:30 +01:00
parent 8145ba8b94
commit 45d7e2736f
2 changed files with 28 additions and 2 deletions
+16 -1
View File
@@ -15,7 +15,12 @@
*/
import { ComponentType } from 'react';
import { PluginOutput, RoutePath, RouteOptions } from './types';
import {
PluginOutput,
RoutePath,
RouteOptions,
FeatureFlagName,
} from './types';
import { Widget } from '../widgetView/types';
export type PluginConfig = {
@@ -26,6 +31,7 @@ export type PluginConfig = {
export type PluginHooks = {
router: RouterHooks;
widgets: WidgetHooks;
featureFlags: FeatureFlagsHooks;
};
export type RouterHooks = {
@@ -46,6 +52,10 @@ export type WidgetHooks = {
add(widget: Widget): void;
};
export type FeatureFlagsHooks = {
registerFeatureFlag(name: FeatureFlagName): void;
};
export const registerSymbol = Symbol('plugin-register');
export const outputSymbol = Symbol('plugin-output');
@@ -78,6 +88,11 @@ export default class Plugin {
outputs.push({ type: 'widget', widget });
},
},
featureFlags: {
registerFeatureFlag(name) {
outputs.push({ type: 'feature-flag', name });
},
},
});
this.storedOutput = outputs;
+12 -1
View File
@@ -43,4 +43,15 @@ export type WidgetOutput = {
widget: Widget;
};
export type PluginOutput = RouteOutput | RedirectRouteOutput | WidgetOutput;
export type FeatureFlagName = string;
export type FeatureFlagOutput = {
type: 'feature-flag';
name: FeatureFlagName;
};
export type PluginOutput =
| RouteOutput
| RedirectRouteOutput
| WidgetOutput
| FeatureFlagOutput;