add feature flag to header bar (#16031)

This commit is contained in:
Elizabeth Thompson 2021-08-02 10:57:29 -07:00 committed by GitHub
parent 39db6a73ee
commit e0576786c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 391 additions and 50507 deletions

File diff suppressed because it is too large Load Diff

View File

@ -67,35 +67,35 @@
"@emotion/babel-preset-css-prop": "^11.2.0",
"@emotion/cache": "^11.1.3",
"@emotion/react": "^11.1.5",
"@superset-ui/chart-controls": "^0.17.74",
"@superset-ui/core": "^0.17.74",
"@superset-ui/legacy-plugin-chart-calendar": "^0.17.74",
"@superset-ui/legacy-plugin-chart-chord": "^0.17.74",
"@superset-ui/legacy-plugin-chart-country-map": "^0.17.74",
"@superset-ui/legacy-plugin-chart-event-flow": "^0.17.74",
"@superset-ui/legacy-plugin-chart-force-directed": "^0.17.74",
"@superset-ui/legacy-plugin-chart-heatmap": "^0.17.74",
"@superset-ui/legacy-plugin-chart-histogram": "^0.17.74",
"@superset-ui/legacy-plugin-chart-horizon": "^0.17.74",
"@superset-ui/legacy-plugin-chart-map-box": "^0.17.74",
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.17.74",
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.17.74",
"@superset-ui/legacy-plugin-chart-partition": "^0.17.74",
"@superset-ui/legacy-plugin-chart-pivot-table": "^0.17.74",
"@superset-ui/legacy-plugin-chart-rose": "^0.17.74",
"@superset-ui/legacy-plugin-chart-sankey": "^0.17.74",
"@superset-ui/legacy-plugin-chart-sankey-loop": "^0.17.74",
"@superset-ui/legacy-plugin-chart-sunburst": "^0.17.74",
"@superset-ui/legacy-plugin-chart-treemap": "^0.17.74",
"@superset-ui/legacy-plugin-chart-world-map": "^0.17.74",
"@superset-ui/legacy-preset-chart-big-number": "^0.17.74",
"@superset-ui/chart-controls": "^0.17.75",
"@superset-ui/core": "^0.17.75",
"@superset-ui/legacy-plugin-chart-calendar": "^0.17.75",
"@superset-ui/legacy-plugin-chart-chord": "^0.17.75",
"@superset-ui/legacy-plugin-chart-country-map": "^0.17.75",
"@superset-ui/legacy-plugin-chart-event-flow": "^0.17.75",
"@superset-ui/legacy-plugin-chart-force-directed": "^0.17.75",
"@superset-ui/legacy-plugin-chart-heatmap": "^0.17.75",
"@superset-ui/legacy-plugin-chart-histogram": "^0.17.75",
"@superset-ui/legacy-plugin-chart-horizon": "^0.17.75",
"@superset-ui/legacy-plugin-chart-map-box": "^0.17.75",
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.17.75",
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.17.75",
"@superset-ui/legacy-plugin-chart-partition": "^0.17.75",
"@superset-ui/legacy-plugin-chart-pivot-table": "^0.17.75",
"@superset-ui/legacy-plugin-chart-rose": "^0.17.75",
"@superset-ui/legacy-plugin-chart-sankey": "^0.17.75",
"@superset-ui/legacy-plugin-chart-sankey-loop": "^0.17.75",
"@superset-ui/legacy-plugin-chart-sunburst": "^0.17.75",
"@superset-ui/legacy-plugin-chart-treemap": "^0.17.75",
"@superset-ui/legacy-plugin-chart-world-map": "^0.17.75",
"@superset-ui/legacy-preset-chart-big-number": "^0.17.75",
"@superset-ui/legacy-preset-chart-deckgl": "^0.4.7",
"@superset-ui/legacy-preset-chart-nvd3": "^0.17.74",
"@superset-ui/plugin-chart-echarts": "^0.17.74",
"@superset-ui/plugin-chart-pivot-table": "^0.17.74",
"@superset-ui/plugin-chart-table": "^0.17.74",
"@superset-ui/plugin-chart-word-cloud": "^0.17.74",
"@superset-ui/preset-chart-xy": "^0.17.74",
"@superset-ui/legacy-preset-chart-nvd3": "^0.17.75",
"@superset-ui/plugin-chart-echarts": "^0.17.75",
"@superset-ui/plugin-chart-pivot-table": "^0.17.75",
"@superset-ui/plugin-chart-table": "^0.17.75",
"@superset-ui/plugin-chart-word-cloud": "^0.17.75",
"@superset-ui/preset-chart-xy": "^0.17.75",
"@vx/responsive": "^0.0.195",
"abortcontroller-polyfill": "^1.1.9",
"antd": "^4.9.4",

View File

@ -23,6 +23,7 @@ import Icons from 'src/components/Icons';
import { Switch } from 'src/components/Switch';
import { AlertObject } from 'src/views/CRUD/alert/types';
import { Menu, NoAnimationDropdown } from 'src/common/components';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import DeleteModal from 'src/components/DeleteModal';
@ -79,7 +80,7 @@ export default function HeaderReportActionsDropDown({
</Menu>
);
return (
return isFeatureEnabled(FeatureFlag.ALERT_REPORTS) ? (
<>
<NoAnimationDropdown
// ref={ref}
@ -110,5 +111,5 @@ export default function HeaderReportActionsDropDown({
/>
)}
</>
);
) : null;
}

View File

@ -19,11 +19,41 @@
import React from 'react';
import userEvent from '@testing-library/user-event';
import { render, screen } from 'spec/helpers/testing-library';
import * as featureFlags from 'src/featureFlags';
import { FeatureFlag } from '@superset-ui/core';
import ReportModal from '.';
let isFeatureEnabledMock: jest.MockInstance<boolean, [string]>;
const NOOP = () => {};
const defaultProps = {
addDangerToast: NOOP,
addSuccessToast: NOOP,
addReport: NOOP,
onHide: NOOP,
onReportAdd: NOOP,
show: true,
userId: 1,
userEmail: 'test@test.com',
dashboardId: 1,
creationMethod: 'charts_dashboards',
};
describe('Email Report Modal', () => {
beforeAll(() => {
isFeatureEnabledMock = jest
.spyOn(featureFlags, 'isFeatureEnabled')
.mockImplementation(
(featureFlag: FeatureFlag) => featureFlag === FeatureFlag.ALERT_REPORTS,
);
});
afterAll(() => {
// @ts-ignore
isFeatureEnabledMock.restore();
});
it('inputs respond correctly', () => {
render(<ReportModal show />, { useRedux: true });
render(<ReportModal {...defaultProps} />, { useRedux: true });
// ----- Report name textbox
// Initial value

View File

@ -28,6 +28,7 @@ import {
LOG_ACTIONS_FORCE_REFRESH_DASHBOARD,
LOG_ACTIONS_TOGGLE_EDIT_DASHBOARD,
} from 'src/logger/LogUtils';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import Icons from 'src/components/Icons';
import Button from 'src/components/Button';
@ -167,7 +168,7 @@ class Header extends React.PureComponent {
componentDidMount() {
const { refreshFrequency, user, dashboardInfo } = this.props;
this.startPeriodicRender(refreshFrequency * 1000);
if (user) {
if (user && isFeatureEnabled(FeatureFlag.ALERT_REPORTS)) {
// this is in case there is an anonymous user.
this.props.fetchUISpecificReport(
user.userId,
@ -382,24 +383,28 @@ class Header extends React.PureComponent {
renderReportModal() {
const attachedReportExists = !!Object.keys(this.props.reports).length;
return attachedReportExists ? (
<HeaderReportActionsDropdown
showReportModal={this.showReportModal}
toggleActive={this.props.toggleActive}
deleteActiveReport={this.props.deleteActiveReport}
/>
) : (
<>
<span
role="button"
title={t('Schedule email report')}
tabIndex={0}
className="action-button"
onClick={this.showReportModal}
>
<Icons.Calendar />
</span>
</>
const canAddReports = isFeatureEnabled(FeatureFlag.ALERT_REPORTS);
return (
(canAddReports || null) &&
(attachedReportExists ? (
<HeaderReportActionsDropdown
showReportModal={this.showReportModal}
toggleActive={this.props.toggleActive}
deleteActiveReport={this.props.deleteActiveReport}
/>
) : (
<>
<span
role="button"
title={t('Schedule email report')}
tabIndex={0}
className="action-button"
onClick={this.showReportModal}
>
<Icons.Calendar />
</span>
</>
))
);
}

View File

@ -29,6 +29,7 @@ import {
toggleActive,
deleteActiveReport,
} from 'src/reports/actions/reports';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import HeaderReportActionsDropdown from 'src/components/ReportModal/HeaderReportActionsDropdown';
import { chartPropShape } from '../../dashboard/util/propShapes';
import ExploreActionButtons from './ExploreActionButtons';
@ -116,7 +117,7 @@ export class ExploreChartHeader extends React.PureComponent {
componentDidMount() {
const { user, chart } = this.props;
if (user) {
if (user && isFeatureEnabled(FeatureFlag.ALERT_REPORTS)) {
// this is in the case that there is an anonymous user.
this.props.fetchUISpecificReport(
user.userId,
@ -163,25 +164,29 @@ export class ExploreChartHeader extends React.PureComponent {
renderReportModal() {
const attachedReportExists = !!Object.keys(this.props.reports).length;
return attachedReportExists ? (
<HeaderReportActionsDropdown
showReportModal={this.showReportModal}
hideReportModal={this.hideReportModal}
toggleActive={this.props.toggleActive}
deleteActiveReport={this.props.deleteActiveReport}
/>
) : (
<>
<span
role="button"
title={t('Schedule email report')}
tabIndex={0}
className="action-button"
onClick={this.showReportModal}
>
<Icons.Calendar />
</span>
</>
const canAddReports = isFeatureEnabled(FeatureFlag.ALERT_REPORTS);
return (
(canAddReports || null) &&
(attachedReportExists ? (
<HeaderReportActionsDropdown
showReportModal={this.showReportModal}
hideReportModal={this.hideReportModal}
toggleActive={this.props.toggleActive}
deleteActiveReport={this.props.deleteActiveReport}
/>
) : (
<>
<span
role="button"
title={t('Schedule email report')}
tabIndex={0}
className="action-button"
onClick={this.showReportModal}
>
<Icons.Calendar />
</span>
</>
))
);
}

View File

@ -348,6 +348,7 @@ const config = {
new RegExp(`${APP_DIR}/src`),
/superset-ui.*\/src/,
new RegExp(`${APP_DIR}/.storybook`),
/@encodable/,
],
use: [babelLoader],
},