[core/apis/definitions] added featureFlags definition
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import ApiRef from '../ApiRef';
|
||||
import { FeatureFlagName } from '../../plugin/types';
|
||||
|
||||
/**
|
||||
* The feature flags API is used to toggle functionality to users across plugins and Backstage.
|
||||
*
|
||||
* Plugins can use this API to register feature flags that they have available
|
||||
* for users to enable/disable, and this API will centralize the current user's
|
||||
* state of which feature flags they would like to enable.
|
||||
*
|
||||
* This is ideal for Backstage plugins, as well as your own App, to trial incomplete
|
||||
* 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 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;
|
||||
|
||||
/**
|
||||
* Enable an registered feature flag.
|
||||
*/
|
||||
enable(name: FeatureFlagName): void;
|
||||
|
||||
/**
|
||||
* Disable an registered feature flag.
|
||||
*/
|
||||
disable(name: FeatureFlagName): void;
|
||||
};
|
||||
|
||||
export const featureFlagsApiRef = new ApiRef<FeatureFlagsApi>({
|
||||
id: 'core.featureflags',
|
||||
description: 'Used to toggle functionality in features across Backstage',
|
||||
});
|
||||
@@ -21,3 +21,4 @@
|
||||
// If you think some API definition is missing, please open an Issue or send a PR!
|
||||
|
||||
export * from './error';
|
||||
export * from './featureFlags';
|
||||
|
||||
Reference in New Issue
Block a user