[core/api] switch getItem from bool to enum

This commit is contained in:
Bilawal Hameed
2020-03-26 16:58:00 +01:00
parent 4969c6046b
commit 0b49bad43d
2 changed files with 13 additions and 4 deletions
@@ -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.
+6 -3
View File
@@ -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 {