2019-01-22 11:21:13 -05:00
|
|
|
/**
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you 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.
|
|
|
|
*/
|
2018-10-24 01:33:51 -04:00
|
|
|
// We can codegen the enum definition based on a list of supported flags that we
|
|
|
|
// check into source control. We're hardcoding the supported flags for now.
|
|
|
|
export enum FeatureFlag {
|
2019-02-02 16:02:08 -05:00
|
|
|
OMNIBAR = 'OMNIBAR',
|
2019-04-23 23:03:57 -04:00
|
|
|
CLIENT_CACHE = 'CLIENT_CACHE',
|
2019-05-03 19:45:19 -04:00
|
|
|
SCHEDULED_QUERIES = 'SCHEDULED_QUERIES',
|
2019-05-15 18:32:40 -04:00
|
|
|
SQL_VALIDATORS_BY_ENGINE = 'SQL_VALIDATORS_BY_ENGINE',
|
2019-09-17 12:09:40 -04:00
|
|
|
ESTIMATE_QUERY_COST = 'ESTIMATE_QUERY_COST',
|
2020-02-19 12:51:50 -05:00
|
|
|
SHARE_QUERIES_VIA_KV_STORE = 'SHARE_QUERIES_VIA_KV_STORE',
|
2019-11-14 12:44:57 -05:00
|
|
|
SQLLAB_BACKEND_PERSISTENCE = 'SQLLAB_BACKEND_PERSISTENCE',
|
2020-08-27 12:40:32 -04:00
|
|
|
THUMBNAILS = 'THUMBNAILS',
|
2020-09-22 21:01:19 -04:00
|
|
|
LISTVIEWS_DEFAULT_CARD_VIEW = 'LISTVIEWS_DEFAULT_CARD_VIEW',
|
2020-10-26 20:31:29 -04:00
|
|
|
ENABLE_REACT_CRUD_VIEWS = 'ENABLE_REACT_CRUD_VIEWS',
|
2020-10-21 18:07:27 -04:00
|
|
|
DISPLAY_MARKDOWN_HTML = 'DISPLAY_MARKDOWN_HTML',
|
|
|
|
ESCAPE_MARKDOWN_HTML = 'ESCAPE_MARKDOWN_HTML',
|
2020-11-04 17:22:12 -05:00
|
|
|
VERSIONED_EXPORT = 'VERSIONED_EXPORT',
|
2020-11-12 16:55:13 -05:00
|
|
|
SIP_34_QUERY_SEARCH_UI = 'SIP_34_QUERY_SEARCH_UI',
|
2018-10-24 01:33:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export type FeatureFlagMap = {
|
|
|
|
[key in FeatureFlag]?: boolean;
|
|
|
|
};
|
|
|
|
|
2020-09-15 18:33:49 -04:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2018-10-24 01:33:51 -04:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
featureFlags: FeatureFlagMap;
|
2020-09-21 18:47:33 -04:00
|
|
|
$: any;
|
|
|
|
jQuery: any;
|
2018-10-24 01:33:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function initFeatureFlags(featureFlags: FeatureFlagMap) {
|
|
|
|
window.featureFlags = featureFlags || {};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isFeatureEnabled(feature: FeatureFlag) {
|
2019-05-03 19:45:19 -04:00
|
|
|
return window && window.featureFlags && !!window.featureFlags[feature];
|
2018-10-24 01:33:51 -04:00
|
|
|
}
|