chore: Feature flag for embedding charts (#20804)

* Add EMBEDDABLE_CHARTS feature flag

* Pretty

* Update test
This commit is contained in:
Geido 2022-07-26 17:55:44 +03:00 committed by GitHub
parent cb9ae38361
commit a69f016bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 17 deletions

View File

@ -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: {

View File

@ -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,

View File

@ -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 = (
<Menu.Item key={MENU_KEYS.SHARE_BY_EMAIL}>
{t('Share chart by email')}
</Menu.Item>
<Menu.Item key={MENU_KEYS.EMBED_CODE}>
<ModalTrigger
triggerNode={
<span data-test="embed-code-button">{t('Embed code')}</span>
}
modalTitle={t('Embed code')}
modalBody={
<EmbedCodeContent
formData={latestQueryFormData}
addDangerToast={addDangerToast}
/>
}
maxWidth={`${theme.gridUnit * 100}px`}
destroyOnClose
responsive
/>
</Menu.Item>
{isFeatureEnabled(FeatureFlag.EMBEDDABLE_CHARTS) ? (
<Menu.Item key={MENU_KEYS.EMBED_CODE}>
<ModalTrigger
triggerNode={
<span data-test="embed-code-button">{t('Embed code')}</span>
}
modalTitle={t('Embed code')}
modalBody={
<EmbedCodeContent
formData={latestQueryFormData}
addDangerToast={addDangerToast}
/>
}
maxWidth={`${theme.gridUnit * 100}px`}
destroyOnClose
responsive
/>
</Menu.Item>
) : null}
</Menu.SubMenu>
<Menu.Divider />
{showReportSubMenu ? (

View File

@ -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.