[core/api] switch getItem from bool to enum
This commit is contained in:
@@ -28,13 +28,19 @@ import { FeatureFlagName } from '../../plugin/types';
|
||||
* or unstable upcoming features. Although there will be a common interface for users
|
||||
* to enable and disable feature flags, this API acts as another way to enable/disable.
|
||||
*/
|
||||
|
||||
export enum FeatureFlagState {
|
||||
NotEnabled = false,
|
||||
Enabled = true,
|
||||
}
|
||||
|
||||
export type FeatureFlagsApi = {
|
||||
/**
|
||||
* Get the current user's status of a Feature Flag
|
||||
*
|
||||
* @returns bool True if the current user has enabled the feature flag
|
||||
*/
|
||||
getItem(name: FeatureFlagName): boolean;
|
||||
getItem(name: FeatureFlagName): FeatureFlagState;
|
||||
|
||||
/**
|
||||
* Enable an registered feature flag.
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
import React, { ComponentType, createContext, FC } from 'react';
|
||||
import { FeatureFlagName } from '../plugin/types';
|
||||
import { FeatureFlagsApi } from '../apis/definitions/featureFlags';
|
||||
import {
|
||||
FeatureFlagState,
|
||||
FeatureFlagsApi,
|
||||
} from '../apis/definitions/featureFlags';
|
||||
|
||||
// TODO: figure out where to put implementations of APIs, both inside apps
|
||||
// but also in core/separate package.
|
||||
@@ -55,8 +58,8 @@ class FeatureFlagsImpl implements FeatureFlagsApi {
|
||||
);
|
||||
}
|
||||
|
||||
getItem(name: FeatureFlagName): boolean {
|
||||
return this.getUserEnabledFeatureFlags().has(name);
|
||||
getItem(name: FeatureFlagName): FeatureFlagState {
|
||||
return this.getUserEnabledFeatureFlags().has(name) as FeatureFlagState;
|
||||
}
|
||||
|
||||
enable(name: FeatureFlagName): void {
|
||||
|
||||
Reference in New Issue
Block a user