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 fb994450046b7..703a7fe5e35e6 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 1664afbb0d438..2f55db6129af3 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 e75e91bba7631..66878b6a8ff0f 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 = (