diff --git a/packages/core/src/api/apis/definitions/featureFlags.ts b/packages/core/src/api/apis/definitions/featureFlags.ts index 750798d4b1..952e2b0121 100644 --- a/packages/core/src/api/apis/definitions/featureFlags.ts +++ b/packages/core/src/api/apis/definitions/featureFlags.ts @@ -30,8 +30,8 @@ import { FeatureFlagName } from '../../plugin/types'; */ export enum FeatureFlagState { - NotEnabled = false, - Enabled = true, + NotEnabled = 0, + Enabled = 1, } export type FeatureFlagsApi = { diff --git a/packages/core/src/api/app/AppBuilder.tsx b/packages/core/src/api/app/AppBuilder.tsx index c8a56876c9..ccd9982249 100644 --- a/packages/core/src/api/app/AppBuilder.tsx +++ b/packages/core/src/api/app/AppBuilder.tsx @@ -91,7 +91,7 @@ export default class AppBuilder { } case 'feature-flag': { registeredFeatureFlags.push({ - pluginId: plugin.config.id, + pluginId: plugin.getId(), name: output.name, }); break; diff --git a/packages/core/src/api/app/FeatureFlags.tsx b/packages/core/src/api/app/FeatureFlags.tsx index 708f4f50fc..74060beb6d 100644 --- a/packages/core/src/api/app/FeatureFlags.tsx +++ b/packages/core/src/api/app/FeatureFlags.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import React, { ComponentType, createContext, FC } from 'react'; +import React, { ReactNode, createContext, FC } from 'react'; import { FeatureFlagName } from '../plugin/types'; import { FeatureFlagState, @@ -37,14 +37,20 @@ class FeatureFlagsImpl implements FeatureFlagsApi { const featureFlagsJson = window.localStorage.getItem( this.localStorageKey, ); - return new Set<>(Object.keys(JSON.parse(featureFlagsJson!))); + return new Set( + Object.keys(JSON.parse(featureFlagsJson!)), + ); } catch (err) { - return new Set<>(); + return new Set(); } } get(name: FeatureFlagName): FeatureFlagState { - return this.getUserEnabledFeatureFlags().has(name) as FeatureFlagState; + if (this.getUserEnabledFeatureFlags().has(name)) { + return FeatureFlagState.Enabled; + } + + return FeatureFlagState.NotEnabled; } set(name: FeatureFlagName, state: FeatureFlagState): void { @@ -83,7 +89,7 @@ export const FeatureFlagsContext = createContext<{ interface Props { registeredFeatureFlags: FeatureFlagsEntry[]; - children: ComponentType; + children: ReactNode; } export const FeatureFlagsContextProvider: FC = ({ diff --git a/packages/core/src/api/plugin/Plugin.tsx b/packages/core/src/api/plugin/Plugin.tsx index aa1ff417b7..ddb95bfff8 100644 --- a/packages/core/src/api/plugin/Plugin.tsx +++ b/packages/core/src/api/plugin/Plugin.tsx @@ -64,6 +64,10 @@ export default class Plugin { constructor(private readonly config: PluginConfig) {} + getId(): string { + return this.config.id; + } + output(): PluginOutput[] { if (this.storedOutput) { return this.storedOutput; diff --git a/packages/core/src/testUtils/index.js b/packages/core/src/testUtils/index.js index 902ba5d92d..a0eab3e72b 100644 --- a/packages/core/src/testUtils/index.js +++ b/packages/core/src/testUtils/index.js @@ -28,7 +28,6 @@ import { render } from '@testing-library/react'; export { default as Keyboard } from './Keyboard'; export { default as mockBreakpoint } from './mockBreakpoint'; export * from './logCollector'; -export * from './decorators'; export function wrapInTestApp(Component, initialRouterEntries) { const Wrapper = Component instanceof Function ? Component : () => Component;