From a69f016bca01da7b45feee62b36f4762b9536c51 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Tue, 26 Jul 2022 17:55:44 +0300 Subject: [PATCH] chore: Feature flag for embedding charts (#20804) * Add EMBEDDABLE_CHARTS feature flag * Pretty * Update test --- .../src/utils/featureFlags.ts | 1 + .../ExploreChartHeader.test.tsx | 5 +++ .../useExploreAdditionalActionsMenu/index.jsx | 37 ++++++++++--------- superset/config.py | 2 + 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts index fb99445004..703a7fe5e3 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts @@ -56,6 +56,7 @@ export enum FeatureFlag { GENERIC_CHART_AXES = 'GENERIC_CHART_AXES', USE_ANALAGOUS_COLORS = 'USE_ANALAGOUS_COLORS', DASHBOARD_EDIT_CHART_IN_NEW_TAB = 'DASHBOARD_EDIT_CHART_IN_NEW_TAB', + EMBEDDABLE_CHARTS = 'EMBEDDABLE_CHARTS', } export type ScheduleQueriesProps = { JSONSCHEMA: { diff --git a/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx b/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx index 1664afbb0d..2f55db6129 100644 --- a/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx +++ b/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx @@ -25,12 +25,17 @@ import fetchMock from 'fetch-mock'; import * as chartAction from 'src/components/Chart/chartAction'; import * as downloadAsImage from 'src/utils/downloadAsImage'; import * as exploreUtils from 'src/explore/exploreUtils'; +import { FeatureFlag } from '@superset-ui/core'; import ExploreHeader from '.'; const chartEndpoint = 'glob:*api/v1/chart/*'; fetchMock.get(chartEndpoint, { json: 'foo' }); +window.featureFlags = { + [FeatureFlag.EMBEDDABLE_CHARTS]: true, +}; + const createProps = () => ({ chart: { id: 1, diff --git a/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx b/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx index e75e91bba7..66878b6a8f 100644 --- a/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx +++ b/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx @@ -29,6 +29,7 @@ import downloadAsImage from 'src/utils/downloadAsImage'; import { getChartPermalink } from 'src/utils/urlUtils'; import copyTextToClipboard from 'src/utils/copy'; import HeaderReportDropDown from 'src/components/ReportModal/HeaderReportDropdown'; +import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; import ViewQueryModal from '../controls/ViewQueryModal'; import EmbedCodeContent from '../EmbedCodeContent'; @@ -297,23 +298,25 @@ export const useExploreAdditionalActionsMenu = ( {t('Share chart by email')} - - {t('Embed code')} - } - modalTitle={t('Embed code')} - modalBody={ - - } - maxWidth={`${theme.gridUnit * 100}px`} - destroyOnClose - responsive - /> - + {isFeatureEnabled(FeatureFlag.EMBEDDABLE_CHARTS) ? ( + + {t('Embed code')} + } + modalTitle={t('Embed code')} + modalBody={ + + } + maxWidth={`${theme.gridUnit * 100}px`} + destroyOnClose + responsive + /> + + ) : null} {showReportSubMenu ? ( diff --git a/superset/config.py b/superset/config.py index f30ce37f57..f61dda6a55 100644 --- a/superset/config.py +++ b/superset/config.py @@ -436,6 +436,8 @@ DEFAULT_FEATURE_FLAGS: Dict[str, bool] = { # Enable caching per impersonation key (e.g username) in a datasource where user # impersonation is enabled "CACHE_IMPERSONATION": False, + # Enable sharing charts with embedding + "EMBEDDABLE_CHARTS": True, } # Feature flags may also be set via 'SUPERSET_FEATURE_' prefixed environment vars.