You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2020/11/25 19:47:44 UTC
[incubator-superset] branch master updated: fix: add feature flag
for domain sharding (#11797)
This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 4cbf482 fix: add feature flag for domain sharding (#11797)
4cbf482 is described below
commit 4cbf4821940d1680734fe032e01f41205b6a2fc4
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Wed Nov 25 11:47:18 2020 -0800
fix: add feature flag for domain sharding (#11797)
* fix: add feature flag for domain sharding
* fix review comment
* add comment for speical case
---
superset-frontend/src/featureFlags.ts | 5 ++++-
superset-frontend/src/utils/hostNamesConfig.js | 11 +++++++++++
superset/config.py | 4 ++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/src/featureFlags.ts b/superset-frontend/src/featureFlags.ts
index 1bac02d..8183cfa 100644
--- a/superset-frontend/src/featureFlags.ts
+++ b/superset-frontend/src/featureFlags.ts
@@ -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) {
diff --git a/superset-frontend/src/utils/hostNamesConfig.js b/superset-frontend/src/utils/hostNamesConfig.js
index a216cbe..8a9f208 100644
--- a/superset-frontend/src/utils/hostNamesConfig.js
+++ b/superset-frontend/src/utils/hostNamesConfig.js
@@ -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 &&
diff --git a/superset/config.py b/superset/config.py
index fa5b385..d469b04 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -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,