fix: add feature flag for domain sharding (#11797)
* fix: add feature flag for domain sharding * fix review comment * add comment for speical case
This commit is contained in:
parent
0504cf1a00
commit
4cbf482194
|
|
@ -19,6 +19,7 @@
|
|||
// 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 {
|
||||
ALLOW_DASHBOARD_DOMAIN_SHARDING = 'ALLOW_DASHBOARD_DOMAIN_SHARDING',
|
||||
OMNIBAR = 'OMNIBAR',
|
||||
CLIENT_CACHE = 'CLIENT_CACHE',
|
||||
SCHEDULED_QUERIES = 'SCHEDULED_QUERIES',
|
||||
|
|
@ -49,7 +50,9 @@ declare global {
|
|||
}
|
||||
|
||||
export function initFeatureFlags(featureFlags: FeatureFlagMap) {
|
||||
window.featureFlags = featureFlags || {};
|
||||
if (!window.featureFlags) {
|
||||
window.featureFlags = featureFlags || {};
|
||||
}
|
||||
}
|
||||
|
||||
export function isFeatureEnabled(feature: FeatureFlag) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import {
|
||||
initFeatureFlags,
|
||||
isFeatureEnabled,
|
||||
FeatureFlag,
|
||||
} from 'src/featureFlags';
|
||||
|
||||
function getDomainsConfig() {
|
||||
const appContainer = document.getElementById('app');
|
||||
if (!appContainer) {
|
||||
|
|
@ -23,8 +29,13 @@ function getDomainsConfig() {
|
|||
}
|
||||
|
||||
const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap'));
|
||||
// this module is a little special, it may be loaded before index.jsx,
|
||||
// where window.featureFlags get initialized
|
||||
// eslint-disable-next-line camelcase
|
||||
initFeatureFlags(bootstrapData?.common?.feature_flags);
|
||||
const availableDomains = new Set([window.location.hostname]);
|
||||
if (
|
||||
isFeatureEnabled(FeatureFlag.ALLOW_DASHBOARD_DOMAIN_SHARDING) &&
|
||||
bootstrapData &&
|
||||
bootstrapData.common &&
|
||||
bootstrapData.common.conf &&
|
||||
|
|
|
|||
|
|
@ -298,6 +298,10 @@ LANGUAGES = {}
|
|||
# and FEATURE_FLAGS = { 'BAR': True, 'BAZ': True } in superset_config.py
|
||||
# will result in combined feature flags of { 'FOO': True, 'BAR': True, 'BAZ': True }
|
||||
DEFAULT_FEATURE_FLAGS: Dict[str, bool] = {
|
||||
# allow dashboard to use sub-domains to send chart request
|
||||
# you also need ENABLE_CORS and
|
||||
# SUPERSET_WEBSERVER_DOMAINS for list of domains
|
||||
"ALLOW_DASHBOARD_DOMAIN_SHARDING": True,
|
||||
# Experimental feature introducing a client (browser) cache
|
||||
"CLIENT_CACHE": False,
|
||||
"ENABLE_EXPLORE_JSON_CSRF_PROTECTION": False,
|
||||
|
|
|
|||
Loading…
Reference in New Issue