From f6b5b658e5311696a641b71f2f34191c9e9e5e20 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Date: Fri, 31 Mar 2023 11:34:10 +0300 Subject: [PATCH] chore(welcome): harmonize submenu with other routes (#22803) --- superset-frontend/src/SqlLab/App.jsx | 8 +- .../src/SqlLab/actions/sqlLab.js | 4 +- .../components/ShareSqlLabQuery/index.tsx | 4 +- .../src/SqlLab/components/SouthPane/index.tsx | 4 +- .../src/SqlLab/components/SqlEditor/index.jsx | 4 +- .../components/TabbedSqlEditors/index.jsx | 4 +- .../src/components/Chart/Chart.jsx | 11 +- .../src/components/Chart/chartAction.js | 4 +- .../Datasource/DatasourceEditor.jsx | 10 +- .../components/Datasource/DatasourceModal.tsx | 4 +- .../src/components/DynamicPlugins/index.tsx | 3 +- .../src/dashboard/actions/dashboardState.js | 7 +- .../src/dashboard/actions/hydrate.js | 4 +- .../src/dashboard/actions/sliceEntities.js | 4 +- .../DashboardBuilder.test.tsx | 3 +- .../DashboardBuilder/DashboardBuilder.tsx | 3 +- .../components/DashboardBuilder/state.ts | 3 +- .../FiltersBadge/FiltersBadge.test.tsx | 8 +- .../Header/HeaderActionsDropdown/index.jsx | 4 +- .../src/dashboard/components/Header/index.jsx | 3 +- .../components/PropertiesModal/index.tsx | 3 +- .../SliceHeaderControls.test.tsx | 2 +- .../components/SliceHeaderControls/index.tsx | 11 +- .../FilterBar/FilterBar.test.tsx | 3 +- .../FilterBar/FilterControls/FilterValue.tsx | 17 +- .../nativeFilters/FilterBar/Vertical.tsx | 10 +- .../FiltersConfigForm/FiltersConfigForm.tsx | 3 +- superset-frontend/src/dataMask/actions.ts | 9 +- .../DataTablesPane/DataTablesPane.tsx | 4 +- .../test/DataTablesPane.test.tsx | 2 +- .../components/DatasourcePanel/index.tsx | 7 +- .../explore/components/ExploreChartPanel.jsx | 7 +- .../src/explore/components/SaveModal.tsx | 9 +- .../index.tsx | 11 +- .../useExploreAdditionalActionsMenu/index.jsx | 4 +- superset-frontend/src/featureFlags.ts | 5 +- .../src/middleware/asyncEvent.ts | 3 +- .../src/pages/ChartCreation/index.tsx | 11 +- .../src/pages/ChartList/index.tsx | 3 +- .../src/pages/DashboardList/index.tsx | 4 +- .../src/pages/DatabaseList/index.tsx | 4 +- .../pages/DatasetList/DatasetList.test.tsx | 6 +- .../src/pages/DatasetList/index.tsx | 4 +- .../src/pages/Home/Home.test.tsx | 2 +- superset-frontend/src/pages/Home/index.tsx | 198 +++++++++--------- .../src/pages/SavedQueryList/index.tsx | 4 +- superset-frontend/src/pages/Tags/index.tsx | 4 +- .../src/utils/hostNamesConfig.js | 7 +- .../src/views/CRUD/alert/AlertReportModal.tsx | 9 +- .../src/views/CRUD/chart/ChartCard.tsx | 4 +- .../views/CRUD/dashboard/DashboardCard.tsx | 4 +- .../src/views/CRUD/tags/TagCard.tsx | 4 +- 52 files changed, 261 insertions(+), 216 deletions(-) diff --git a/superset-frontend/src/SqlLab/App.jsx b/superset-frontend/src/SqlLab/App.jsx index b75ea5c624..a86228c684 100644 --- a/superset-frontend/src/SqlLab/App.jsx +++ b/superset-frontend/src/SqlLab/App.jsx @@ -21,14 +21,10 @@ import { createStore, compose, applyMiddleware } from 'redux'; import { Provider } from 'react-redux'; import thunkMiddleware from 'redux-thunk'; import { hot } from 'react-hot-loader/root'; -import { ThemeProvider } from '@superset-ui/core'; +import { FeatureFlag, ThemeProvider } from '@superset-ui/core'; import { GlobalStyles } from 'src/GlobalStyles'; import QueryProvider from 'src/views/QueryProvider'; -import { - initFeatureFlags, - isFeatureEnabled, - FeatureFlag, -} from 'src/featureFlags'; +import { initFeatureFlags, isFeatureEnabled } from 'src/featureFlags'; import setupExtensions from 'src/setup/setupExtensions'; import getBootstrapData from 'src/utils/getBootstrapData'; import logger from 'src/middleware/loggerMiddleware'; diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 88c500022b..4b65b59925 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -18,10 +18,10 @@ */ import shortid from 'shortid'; import rison from 'rison'; -import { SupersetClient, t } from '@superset-ui/core'; +import { FeatureFlag, SupersetClient, t } from '@superset-ui/core'; import invert from 'lodash/invert'; import mapKeys from 'lodash/mapKeys'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { now } from 'src/utils/dates'; import { diff --git a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx index 73a7749646..fe9990ad3f 100644 --- a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx +++ b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx @@ -17,14 +17,14 @@ * under the License. */ import React from 'react'; -import { t, useTheme, styled } from '@superset-ui/core'; +import { FeatureFlag, styled, t, useTheme } from '@superset-ui/core'; import Button from 'src/components/Button'; import Icons from 'src/components/Icons'; import withToasts from 'src/components/MessageToasts/withToasts'; import CopyToClipboard from 'src/components/CopyToClipboard'; import { storeQuery } from 'src/utils/common'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; interface ShareSqlLabQueryProps { diff --git a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx index 0b389dfb39..047bfebd65 100644 --- a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx +++ b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx @@ -22,10 +22,10 @@ import shortid from 'shortid'; import Alert from 'src/components/Alert'; import Tabs from 'src/components/Tabs'; import { EmptyStateMedium } from 'src/components/EmptyState'; -import { t, styled } from '@superset-ui/core'; +import { FeatureFlag, styled, t } from '@superset-ui/core'; import { setActiveSouthPaneTab } from 'src/SqlLab/actions/sqlLab'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import Label from 'src/components/Label'; import { SqlLabRootState } from 'src/SqlLab/types'; diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx index c19db43089..83286e5881 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx @@ -29,7 +29,7 @@ import { CSSTransition } from 'react-transition-group'; import { useDispatch, useSelector } from 'react-redux'; import PropTypes from 'prop-types'; import Split from 'react-split'; -import { css, t, styled, useTheme } from '@superset-ui/core'; +import { css, FeatureFlag, styled, t, useTheme } from '@superset-ui/core'; import debounce from 'lodash/debounce'; import throttle from 'lodash/throttle'; import Modal from 'src/components/Modal'; @@ -78,7 +78,7 @@ import { LocalStorageKeys, setItem, } from 'src/utils/localStorageHelpers'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { EmptyStateBig } from 'src/components/EmptyState'; import getBootstrapData from 'src/utils/getBootstrapData'; import { isEmpty } from 'lodash'; diff --git a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx index 1b3e3a999d..1a6aac0bf8 100644 --- a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx +++ b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx @@ -22,8 +22,8 @@ import { EditableTabs } from 'src/components/Tabs'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import URI from 'urijs'; -import { styled, t } from '@superset-ui/core'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { FeatureFlag, styled, t } from '@superset-ui/core'; +import { isFeatureEnabled } from 'src/featureFlags'; import { Tooltip } from 'src/components/Tooltip'; import { detectOS } from 'src/utils/common'; import * as Actions from 'src/SqlLab/actions/sqlLab'; diff --git a/superset-frontend/src/components/Chart/Chart.jsx b/superset-frontend/src/components/Chart/Chart.jsx index e8453ee27b..74bde69c5c 100644 --- a/superset-frontend/src/components/Chart/Chart.jsx +++ b/superset-frontend/src/components/Chart/Chart.jsx @@ -18,9 +18,14 @@ */ import PropTypes from 'prop-types'; import React from 'react'; -import { styled, logging, t, ensureIsArray } from '@superset-ui/core'; - -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { + ensureIsArray, + FeatureFlag, + logging, + styled, + t, +} from '@superset-ui/core'; +import { isFeatureEnabled } from 'src/featureFlags'; import { PLACEHOLDER_DATASOURCE } from 'src/dashboard/constants'; import Loading from 'src/components/Loading'; import { EmptyStateBig } from 'src/components/EmptyState'; diff --git a/superset-frontend/src/components/Chart/chartAction.js b/superset-frontend/src/components/Chart/chartAction.js index 7418a8f8b7..25c3cd1ab8 100644 --- a/superset-frontend/src/components/Chart/chartAction.js +++ b/superset-frontend/src/components/Chart/chartAction.js @@ -19,9 +19,9 @@ /* eslint no-undef: 'error' */ /* eslint no-param-reassign: ["error", { "props": false }] */ import moment from 'moment'; -import { t, SupersetClient, isDefined } from '@superset-ui/core'; +import { FeatureFlag, isDefined, SupersetClient, t } from '@superset-ui/core'; import { getControlsState } from 'src/explore/store'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { getAnnotationJsonUrl, getExploreUrl, diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx index 6f0f8a8486..f4d7e48573 100644 --- a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx +++ b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx @@ -24,7 +24,13 @@ import Card from 'src/components/Card'; import Alert from 'src/components/Alert'; import Badge from 'src/components/Badge'; import shortid from 'shortid'; -import { styled, SupersetClient, t, withTheme } from '@superset-ui/core'; +import { + FeatureFlag, + styled, + SupersetClient, + t, + withTheme, +} from '@superset-ui/core'; import { Select, AsyncSelect, Row, Col } from 'src/components'; import { FormLabel } from 'src/components/Form'; import Button from 'src/components/Button'; @@ -42,7 +48,7 @@ import TextControl from 'src/explore/components/controls/TextControl'; import TextAreaControl from 'src/explore/components/controls/TextAreaControl'; import SpatialControl from 'src/explore/components/controls/SpatialControl'; import withToasts from 'src/components/MessageToasts/withToasts'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import Icons from 'src/components/Icons'; import CollectionTable from './CollectionTable'; import Fieldset from './Fieldset'; diff --git a/superset-frontend/src/components/Datasource/DatasourceModal.tsx b/superset-frontend/src/components/Datasource/DatasourceModal.tsx index b0a0bb9c42..3f5e377463 100644 --- a/superset-frontend/src/components/Datasource/DatasourceModal.tsx +++ b/superset-frontend/src/components/Datasource/DatasourceModal.tsx @@ -19,11 +19,11 @@ import React, { FunctionComponent, useState, useRef } from 'react'; import Alert from 'src/components/Alert'; import Button from 'src/components/Button'; -import { styled, t, SupersetClient } from '@superset-ui/core'; +import { FeatureFlag, styled, SupersetClient, t } from '@superset-ui/core'; import Modal from 'src/components/Modal'; import AsyncEsmComponent from 'src/components/AsyncEsmComponent'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; import withToasts from 'src/components/MessageToasts/withToasts'; diff --git a/superset-frontend/src/components/DynamicPlugins/index.tsx b/superset-frontend/src/components/DynamicPlugins/index.tsx index b11798fbd8..87701d2462 100644 --- a/superset-frontend/src/components/DynamicPlugins/index.tsx +++ b/superset-frontend/src/components/DynamicPlugins/index.tsx @@ -20,11 +20,12 @@ import React, { useContext, useEffect, useReducer } from 'react'; import { ChartMetadata, defineSharedModules, + FeatureFlag, getChartMetadataRegistry, logging, makeApi, } from '@superset-ui/core'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { omitBy } from 'lodash'; const metadataRegistry = getChartMetadataRegistry(); diff --git a/superset-frontend/src/dashboard/actions/dashboardState.js b/superset-frontend/src/dashboard/actions/dashboardState.js index a166e5d4db..ad59ac378c 100644 --- a/superset-frontend/src/dashboard/actions/dashboardState.js +++ b/superset-frontend/src/dashboard/actions/dashboardState.js @@ -21,9 +21,10 @@ import { ActionCreators as UndoActionCreators } from 'redux-undo'; import rison from 'rison'; import { ensureIsArray, - t, - SupersetClient, + FeatureFlag, getSharedLabelColor, + SupersetClient, + t, } from '@superset-ui/core'; import { addChart, @@ -50,7 +51,7 @@ import serializeActiveFilterValues from 'src/dashboard/util/serializeActiveFilte import serializeFilterScopes from 'src/dashboard/util/serializeFilterScopes'; import { getActiveFilters } from 'src/dashboard/util/activeDashboardFilters'; import { safeStringify } from 'src/utils/safeStringify'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { logEvent } from 'src/logger/actions'; import { LOG_ACTIONS_CONFIRM_OVERWRITE_DASHBOARD_METADATA } from 'src/logger/LogUtils'; import { UPDATE_COMPONENTS_PARENTS_LIST } from './dashboardLayout'; diff --git a/superset-frontend/src/dashboard/actions/hydrate.js b/superset-frontend/src/dashboard/actions/hydrate.js index e0b17b737d..4f1b94379b 100644 --- a/superset-frontend/src/dashboard/actions/hydrate.js +++ b/superset-frontend/src/dashboard/actions/hydrate.js @@ -16,6 +16,8 @@ * specific language governing permissions and limitations * under the License. */ +/* eslint-disable camelcase */ +import { FeatureFlag } from '@superset-ui/core'; import { chart } from 'src/components/Chart/chartReducer'; import { initSliceEntities } from 'src/dashboard/reducers/sliceEntities'; import { getInitialState as getInitialNativeFilterState } from 'src/dashboard/reducers/nativeFilters'; @@ -51,7 +53,7 @@ import { TIME_RANGE } from 'src/visualizations/FilterBox/FilterBox'; import { URL_PARAMS } from 'src/constants'; import { getUrlParam } from 'src/utils/urlUtils'; import { ResourceStatus } from 'src/hooks/apiResources/apiResources'; -import { FeatureFlag, isFeatureEnabled } from '../../featureFlags'; +import { isFeatureEnabled } from '../../featureFlags'; import extractUrlParams from '../util/extractUrlParams'; import { updateColorSchema } from './dashboardInfo'; import updateComponentParentsList from '../util/updateComponentParentsList'; diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index 13d7ce45bf..99a0627211 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -17,12 +17,12 @@ * under the License. */ /* eslint camelcase: 0 */ -import { t, SupersetClient } from '@superset-ui/core'; +import { FeatureFlag, SupersetClient, t } from '@superset-ui/core'; import rison from 'rison'; import { addDangerToast } from 'src/components/MessageToasts/actions'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; export const SET_ALL_SLICES = 'SET_ALL_SLICES'; const FETCH_SLICES_PAGE_SIZE = 200; diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx index 3a641660da..388f8ee3c1 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx @@ -21,7 +21,8 @@ import React from 'react'; import fetchMock from 'fetch-mock'; import { render } from 'spec/helpers/testing-library'; import { fireEvent, within } from '@testing-library/react'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { FeatureFlag } from '@superset-ui/core'; +import { isFeatureEnabled } from 'src/featureFlags'; import DashboardBuilder from 'src/dashboard/components/DashboardBuilder/DashboardBuilder'; import useStoredSidebarWidth from 'src/components/ResizableSidebar/useStoredSidebarWidth'; import { diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx index 3c64c2ef1e..07eb85482b 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx @@ -29,6 +29,7 @@ import React, { import { addAlpha, css, + FeatureFlag, JsonObject, styled, t, @@ -57,7 +58,7 @@ import { setDirectPathToChild, setEditMode, } from 'src/dashboard/actions/dashboardState'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { deleteTopLevelTabs, handleComponentDrop, diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts b/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts index 8072282138..d213d292ee 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts @@ -17,7 +17,8 @@ * under the License. */ import { useSelector } from 'react-redux'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { FeatureFlag } from '@superset-ui/core'; +import { isFeatureEnabled } from 'src/featureFlags'; import { useCallback, useEffect, useState } from 'react'; import { URL_PARAMS } from 'src/constants'; import { getUrlParam } from 'src/utils/urlUtils'; diff --git a/superset-frontend/src/dashboard/components/FiltersBadge/FiltersBadge.test.tsx b/superset-frontend/src/dashboard/components/FiltersBadge/FiltersBadge.test.tsx index cae293bd74..058c5329b6 100644 --- a/superset-frontend/src/dashboard/components/FiltersBadge/FiltersBadge.test.tsx +++ b/superset-frontend/src/dashboard/components/FiltersBadge/FiltersBadge.test.tsx @@ -18,7 +18,6 @@ */ import React from 'react'; import { shallow } from 'enzyme'; -import { supersetTheme } from '@superset-ui/core'; import { Provider } from 'react-redux'; import { Store } from 'redux'; import * as SupersetUI from '@superset-ui/core'; @@ -36,7 +35,6 @@ import { import { sliceId } from 'spec/fixtures/mockChartQueries'; import { dashboardFilters } from 'spec/fixtures/mockDashboardFilters'; import { dashboardWithFilter } from 'spec/fixtures/mockDashboardLayout'; -import { FeatureFlag } from 'src/featureFlags'; const defaultStore = getMockStoreWithFilters(); function setup(store: Store = defaultStore) { @@ -60,7 +58,9 @@ describe('FiltersBadge', () => { // shallow rendering in enzyme doesn't propagate contexts correctly, // so we have to mock the hook. // See https://medium.com/7shifts-engineering-blog/testing-usecontext-react-hook-with-enzyme-shallow-da062140fc83 - jest.spyOn(SupersetUI, 'useTheme').mockImplementation(() => supersetTheme); + jest + .spyOn(SupersetUI, 'useTheme') + .mockImplementation(() => SupersetUI.supersetTheme); }); describe('for dashboard filters', () => { @@ -135,7 +135,7 @@ describe('FiltersBadge', () => { it('shows the indicator when filters have been applied', () => { // @ts-ignore global.featureFlags = { - [FeatureFlag.DASHBOARD_NATIVE_FILTERS]: true, + [SupersetUI.FeatureFlag.DASHBOARD_NATIVE_FILTERS]: true, }; const store = getMockStoreWithNativeFilters(); // start with basic dashboard state, dispatch an event to simulate query completion diff --git a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx index ae1e5b8308..7c375caf5b 100644 --- a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx @@ -20,7 +20,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { isEmpty } from 'lodash'; -import { SupersetClient, t } from '@superset-ui/core'; +import { FeatureFlag, SupersetClient, t } from '@superset-ui/core'; import { Menu } from 'src/components/Menu'; import { URL_PARAMS } from 'src/constants'; @@ -37,7 +37,7 @@ import getDashboardUrl from 'src/dashboard/util/getDashboardUrl'; import { getActiveFilters } from 'src/dashboard/util/activeDashboardFilters'; import { getUrlParam } from 'src/utils/urlUtils'; import { LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_IMAGE } from 'src/logger/LogUtils'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; const propTypes = { addSuccessToast: PropTypes.func.isRequired, diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx index 083f566834..72d583ebf2 100644 --- a/superset-frontend/src/dashboard/components/Header/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/index.jsx @@ -23,12 +23,13 @@ import PropTypes from 'prop-types'; import { styled, css, + FeatureFlag, t, getSharedLabelColor, getUiOverrideRegistry, } from '@superset-ui/core'; import { Global } from '@emotion/react'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { LOG_ACTIONS_PERIODIC_RENDER_DASHBOARD, LOG_ACTIONS_FORCE_REFRESH_DASHBOARD, diff --git a/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx b/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx index b12102d324..22b2734761 100644 --- a/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx +++ b/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx @@ -26,6 +26,7 @@ import rison from 'rison'; import { CategoricalColorNamespace, ensureIsArray, + FeatureFlag, getCategoricalSchemeRegistry, getSharedLabelColor, styled, @@ -40,7 +41,7 @@ import ColorSchemeControlWrapper from 'src/dashboard/components/ColorSchemeContr import FilterScopeModal from 'src/dashboard/components/filterscope/FilterScopeModal'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; import withToasts from 'src/components/MessageToasts/withToasts'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import TagType from 'src/types/TagType'; import { addTag, deleteTaggedObjects, fetchTags, OBJECT_TYPES } from 'src/tags'; import { loadTags } from 'src/components/Tags/utils'; diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx index 3a1e305640..26f3a6bbbf 100644 --- a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx @@ -21,7 +21,7 @@ import userEvent from '@testing-library/user-event'; import React from 'react'; import { getMockStore } from 'spec/fixtures/mockStore'; import { render, screen } from 'spec/helpers/testing-library'; -import { FeatureFlag } from 'src/featureFlags'; +import { FeatureFlag } from '@superset-ui/core'; import SliceHeaderControls, { SliceHeaderControlsProps } from '.'; jest.mock('src/components/Dropdown', () => { diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx index 2d82b39d86..71a1585036 100644 --- a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx @@ -30,12 +30,19 @@ import { withRouter, } from 'react-router-dom'; import moment from 'moment'; -import { css, QueryFormData, styled, t, useTheme } from '@superset-ui/core'; +import { + css, + FeatureFlag, + QueryFormData, + styled, + t, + useTheme, +} from '@superset-ui/core'; import { Menu } from 'src/components/Menu'; import { NoAnimationDropdown } from 'src/components/Dropdown'; import ShareMenuItems from 'src/dashboard/components/menu/ShareMenuItems'; import downloadAsImage from 'src/utils/downloadAsImage'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { getSliceHeaderTooltip } from 'src/dashboard/util/getSliceHeaderTooltip'; import { Tooltip } from 'src/components/Tooltip'; import Icons from 'src/components/Icons'; diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx index 7a8106ecbe..d6428e0f00 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx @@ -23,8 +23,7 @@ import userEvent from '@testing-library/user-event'; import { stateWithoutNativeFilters } from 'spec/fixtures/mockStore'; import * as mockCore from '@superset-ui/core'; import { testWithId } from 'src/utils/testUtils'; -import { FeatureFlag } from 'src/featureFlags'; -import { Preset } from '@superset-ui/core'; +import { FeatureFlag, Preset } from '@superset-ui/core'; import { TimeFilterPlugin, SelectFilterPlugin } from 'src/filters/components'; import { DATE_FILTER_TEST_KEY } from 'src/explore/components/controls/DateFilterControl'; import fetchMock from 'fetch-mock'; diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx index 0347d2095e..ad61be7a13 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx @@ -24,22 +24,23 @@ import React, { useState, } from 'react'; import { - QueryFormData, - SuperChart, - DataMask, - t, - styled, - Behavior, ChartDataResponseResult, - JsonObject, + Behavior, + DataMask, + FeatureFlag, getChartMetadataRegistry, + JsonObject, + QueryFormData, + styled, + SuperChart, + t, } from '@superset-ui/core'; import { useDispatch, useSelector } from 'react-redux'; import { isEqual, isEqualWith } from 'lodash'; import { getChartDataRequest } from 'src/components/Chart/chartAction'; import Loading from 'src/components/Loading'; import BasicErrorAlert from 'src/components/ErrorMessage/BasicErrorAlert'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { waitForAsyncData } from 'src/middleware/asyncEvent'; import { ClientErrorObject } from 'src/utils/getClientErrorObject'; import { FilterBarOrientation, RootState } from 'src/dashboard/types'; diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx index 265c5932ac..07b327e3b4 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx @@ -28,10 +28,16 @@ import React, { createContext, } from 'react'; import cx from 'classnames'; -import { HandlerFunction, styled, t, isNativeFilter } from '@superset-ui/core'; +import { + FeatureFlag, + HandlerFunction, + isNativeFilter, + styled, + t, +} from '@superset-ui/core'; import Icons from 'src/components/Icons'; import { AntdTabs } from 'src/components'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import Loading from 'src/components/Loading'; import { EmptyStateSmall } from 'src/components/EmptyState'; import { getFilterBarTestId } from './utils'; diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx index 3b804acd8f..7ffcd3a98b 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx @@ -27,6 +27,7 @@ import { Behavior, ChartDataResponseResult, Column, + FeatureFlag, Filter, GenericDataType, getChartMetadataRegistry, @@ -69,7 +70,7 @@ import { } from 'src/dashboard/types'; import DateFilterControl from 'src/explore/components/controls/DateFilterControl'; import AdhocFilterControl from 'src/explore/components/controls/FilterControl/AdhocFilterControl'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { waitForAsyncData } from 'src/middleware/asyncEvent'; import { ClientErrorObject } from 'src/utils/getClientErrorObject'; import { SingleValueType } from 'src/filters/components/Range/SingleValueType'; diff --git a/superset-frontend/src/dataMask/actions.ts b/superset-frontend/src/dataMask/actions.ts index a26b49f807..89e88ce130 100644 --- a/superset-frontend/src/dataMask/actions.ts +++ b/superset-frontend/src/dataMask/actions.ts @@ -16,8 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import { DataMask, FilterConfiguration, Filters } from '@superset-ui/core'; -import { FeatureFlag, isFeatureEnabled } from '../featureFlags'; +import { + DataMask, + FeatureFlag, + FilterConfiguration, + Filters, +} from '@superset-ui/core'; +import { isFeatureEnabled } from '../featureFlags'; import { getInitialDataMask } from './reducer'; export const CLEAR_DATA_MASK_STATE = 'CLEAR_DATA_MASK_STATE'; diff --git a/superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx b/superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx index 4101911da7..54f222c717 100644 --- a/superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx +++ b/superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx @@ -23,10 +23,10 @@ import React, { useState, MouseEvent, } from 'react'; -import { styled, t, useTheme } from '@superset-ui/core'; +import { FeatureFlag, styled, t, useTheme } from '@superset-ui/core'; import Icons from 'src/components/Icons'; import Tabs from 'src/components/Tabs'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { getItem, setItem, diff --git a/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx b/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx index a27385f51e..4a4a5203f5 100644 --- a/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx +++ b/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import userEvent from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; -import { FeatureFlag } from 'src/featureFlags'; +import { FeatureFlag } from '@superset-ui/core'; import * as copyUtils from 'src/utils/copy'; import { render, diff --git a/superset-frontend/src/explore/components/DatasourcePanel/index.tsx b/superset-frontend/src/explore/components/DatasourcePanel/index.tsx index dedffc1044..efedacd220 100644 --- a/superset-frontend/src/explore/components/DatasourcePanel/index.tsx +++ b/superset-frontend/src/explore/components/DatasourcePanel/index.tsx @@ -19,11 +19,12 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'; import { css, - styled, - t, DatasourceType, + FeatureFlag, Metric, QueryFormData, + styled, + t, } from '@superset-ui/core'; import { ControlConfig, ColumnMeta } from '@superset-ui/chart-controls'; @@ -36,7 +37,7 @@ import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal'; import { getDatasourceAsSaveableDataset } from 'src/utils/datasourceUtils'; import { Input } from 'src/components/Input'; import { FAST_DEBOUNCE } from 'src/constants'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { ExploreActions } from 'src/explore/actions/exploreActions'; import Control from 'src/explore/components/Control'; import DatasourcePanelDragOption from './DatasourcePanelDragOption'; diff --git a/superset-frontend/src/explore/components/ExploreChartPanel.jsx b/superset-frontend/src/explore/components/ExploreChartPanel.jsx index a2f7d05b28..1e57e0750e 100644 --- a/superset-frontend/src/explore/components/ExploreChartPanel.jsx +++ b/superset-frontend/src/explore/components/ExploreChartPanel.jsx @@ -21,18 +21,19 @@ import PropTypes from 'prop-types'; import Split from 'react-split'; import { css, + DatasourceType, ensureIsArray, + FeatureFlag, + getChartMetadataRegistry, styled, SupersetClient, t, useTheme, - getChartMetadataRegistry, - DatasourceType, } from '@superset-ui/core'; import { useResizeDetector } from 'react-resize-detector'; import { chartPropShape } from 'src/dashboard/util/propShapes'; import ChartContainer from 'src/components/Chart/ChartContainer'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { getItem, setItem, diff --git a/superset-frontend/src/explore/components/SaveModal.tsx b/superset-frontend/src/explore/components/SaveModal.tsx index 8d7bd2d895..9e63f10b61 100644 --- a/superset-frontend/src/explore/components/SaveModal.tsx +++ b/superset-frontend/src/explore/components/SaveModal.tsx @@ -25,11 +25,12 @@ import { withRouter, RouteComponentProps } from 'react-router-dom'; import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls'; import { css, - t, - styled, DatasourceType, - isDefined, ensureIsArray, + FeatureFlag, + isDefined, + styled, + t, } from '@superset-ui/core'; import { Input } from 'src/components/Input'; import { Form, FormItem } from 'src/components/Form'; @@ -41,7 +42,7 @@ import { Select } from 'src/components'; import Loading from 'src/components/Loading'; import { setSaveChartModalVisibility } from 'src/explore/actions/saveModalActions'; import { SaveActionType } from 'src/explore/types'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; // Session storage key for recent dashboard const SK_DASHBOARD_ID = 'save_chart_recent_dashboard'; diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx index 84feb448f6..482746acf8 100644 --- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx +++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx @@ -20,12 +20,13 @@ import React, { useEffect, useState } from 'react'; import FormItem from 'src/components/Form/FormItem'; import { Select } from 'src/components'; import { - t, - SupersetClient, - SupersetTheme, - styled, + FeatureFlag, hasGenericChartAxes, isDefined, + styled, + SupersetClient, + SupersetTheme, + t, } from '@superset-ui/core'; import { Operators, @@ -42,7 +43,7 @@ import AdhocFilter from 'src/explore/components/controls/FilterControl/AdhocFilt import { Tooltip } from 'src/components/Tooltip'; import { Input } from 'src/components/Input'; import { optionLabel } from 'src/utils/common'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { ColumnMeta, Dataset, diff --git a/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx b/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx index 445db6dc44..11e242a2e3 100644 --- a/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx +++ b/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx @@ -18,7 +18,7 @@ */ import React, { useCallback, useMemo, useState } from 'react'; import { useSelector } from 'react-redux'; -import { css, styled, t, useTheme } from '@superset-ui/core'; +import { css, FeatureFlag, styled, t, useTheme } from '@superset-ui/core'; import Icons from 'src/components/Icons'; import { Menu } from 'src/components/Menu'; import ModalTrigger from 'src/components/ModalTrigger'; @@ -29,7 +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 { isFeatureEnabled } from 'src/featureFlags'; import ViewQueryModal from '../controls/ViewQueryModal'; import EmbedCodeContent from '../EmbedCodeContent'; import DashboardsSubMenu from './DashboardsSubMenu'; diff --git a/superset-frontend/src/featureFlags.ts b/superset-frontend/src/featureFlags.ts index e71ec82074..d7387f2796 100644 --- a/superset-frontend/src/featureFlags.ts +++ b/superset-frontend/src/featureFlags.ts @@ -16,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { FeatureFlagMap, FeatureFlag } from '@superset-ui/core'; - -export { FeatureFlag } from '@superset-ui/core'; -export type { FeatureFlagMap } from '@superset-ui/core'; +import { FeatureFlag, FeatureFlagMap } from '@superset-ui/core'; export function initFeatureFlags(featureFlags?: FeatureFlagMap) { if (!window.featureFlags) { diff --git a/superset-frontend/src/middleware/asyncEvent.ts b/superset-frontend/src/middleware/asyncEvent.ts index 6966ad6d3f..5d878cef55 100644 --- a/superset-frontend/src/middleware/asyncEvent.ts +++ b/superset-frontend/src/middleware/asyncEvent.ts @@ -18,13 +18,14 @@ */ import { ensureIsArray, + FeatureFlag, makeApi, SupersetClient, logging, } from '@superset-ui/core'; import { SupersetError } from 'src/components/ErrorMessage/types'; import getBootstrapData from 'src/utils/getBootstrapData'; -import { FeatureFlag, isFeatureEnabled } from '../featureFlags'; +import { isFeatureEnabled } from '../featureFlags'; import { getClientErrorObject, parseErrorJson, diff --git a/superset-frontend/src/pages/ChartCreation/index.tsx b/superset-frontend/src/pages/ChartCreation/index.tsx index baa0c78f1a..7ff3442c9d 100644 --- a/superset-frontend/src/pages/ChartCreation/index.tsx +++ b/superset-frontend/src/pages/ChartCreation/index.tsx @@ -20,11 +20,12 @@ import React, { ReactNode } from 'react'; import rison from 'rison'; import querystring from 'query-string'; import { - styled, - t, - SupersetClient, - JsonResponse, + FeatureFlag, isDefined, + JsonResponse, + styled, + SupersetClient, + t, } from '@superset-ui/core'; import { getUrlParam } from 'src/utils/urlUtils'; import { URL_PARAMS } from 'src/constants'; @@ -33,7 +34,7 @@ import Button from 'src/components/Button'; import { AsyncSelect, Steps } from 'src/components'; import { Tooltip } from 'src/components/Tooltip'; import withToasts from 'src/components/MessageToasts/withToasts'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import VizTypeGallery, { MAX_ADVISABLE_VIZ_GALLERY_WIDTH, diff --git a/superset-frontend/src/pages/ChartList/index.tsx b/superset-frontend/src/pages/ChartList/index.tsx index 1da3394fd2..8265604556 100644 --- a/superset-frontend/src/pages/ChartList/index.tsx +++ b/superset-frontend/src/pages/ChartList/index.tsx @@ -18,6 +18,7 @@ */ import { ensureIsArray, + FeatureFlag, getChartMetadataRegistry, JsonResponse, styled, @@ -28,7 +29,7 @@ import React, { useState, useMemo, useCallback } from 'react'; import rison from 'rison'; import { uniqBy } from 'lodash'; import moment from 'moment'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { createErrorHandler, createFetchRelated, diff --git a/superset-frontend/src/pages/DashboardList/index.tsx b/superset-frontend/src/pages/DashboardList/index.tsx index d4c484043d..e0f81e0bf4 100644 --- a/superset-frontend/src/pages/DashboardList/index.tsx +++ b/superset-frontend/src/pages/DashboardList/index.tsx @@ -16,11 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -import { styled, SupersetClient, t } from '@superset-ui/core'; +import { FeatureFlag, styled, SupersetClient, t } from '@superset-ui/core'; import React, { useState, useMemo, useCallback } from 'react'; import { Link } from 'react-router-dom'; import rison from 'rison'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { createFetchRelated, createErrorHandler, diff --git a/superset-frontend/src/pages/DatabaseList/index.tsx b/superset-frontend/src/pages/DatabaseList/index.tsx index c20c3b006b..a9ae567c60 100644 --- a/superset-frontend/src/pages/DatabaseList/index.tsx +++ b/superset-frontend/src/pages/DatabaseList/index.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { SupersetClient, t, styled } from '@superset-ui/core'; +import { FeatureFlag, styled, SupersetClient, t } from '@superset-ui/core'; import React, { useState, useMemo, useEffect } from 'react'; import rison from 'rison'; import { useSelector } from 'react-redux'; @@ -24,7 +24,7 @@ import { useQueryParams, BooleanParam } from 'use-query-params'; import { LocalStorageKeys, setItem } from 'src/utils/localStorageHelpers'; import Loading from 'src/components/Loading'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { useListViewResource } from 'src/views/CRUD/hooks'; import { createErrorHandler, uploadUserPerms } from 'src/views/CRUD/utils'; import withToasts from 'src/components/MessageToasts/withToasts'; diff --git a/superset-frontend/src/pages/DatasetList/DatasetList.test.tsx b/superset-frontend/src/pages/DatasetList/DatasetList.test.tsx index 1ce9a7bc0f..c061d1ab25 100644 --- a/superset-frontend/src/pages/DatasetList/DatasetList.test.tsx +++ b/superset-frontend/src/pages/DatasetList/DatasetList.test.tsx @@ -23,6 +23,7 @@ import fetchMock from 'fetch-mock'; import { Provider } from 'react-redux'; import { styledMount as mount } from 'spec/helpers/theming'; import { render, screen, cleanup } from 'spec/helpers/testing-library'; +import { FeatureFlag } from '@superset-ui/core'; import userEvent from '@testing-library/user-event'; import { QueryParamProvider } from 'use-query-params'; import * as featureFlags from 'src/featureFlags'; @@ -255,10 +256,7 @@ describe('RTL', () => { return mounted; } - let isFeatureEnabledMock: jest.SpyInstance< - boolean, - [feature: featureFlags.FeatureFlag] - >; + let isFeatureEnabledMock: jest.SpyInstance; beforeEach(async () => { isFeatureEnabledMock = jest .spyOn(featureFlags, 'isFeatureEnabled') diff --git a/superset-frontend/src/pages/DatasetList/index.tsx b/superset-frontend/src/pages/DatasetList/index.tsx index bdb2683ad4..68f6c11348 100644 --- a/superset-frontend/src/pages/DatasetList/index.tsx +++ b/superset-frontend/src/pages/DatasetList/index.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { SupersetClient, t, styled } from '@superset-ui/core'; +import { FeatureFlag, styled, SupersetClient, t } from '@superset-ui/core'; import React, { FunctionComponent, useState, @@ -54,7 +54,7 @@ import FacePile from 'src/components/FacePile'; import CertifiedBadge from 'src/components/CertifiedBadge'; import InfoTooltip from 'src/components/InfoTooltip'; import ImportModelsModal from 'src/components/ImportModal/index'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import WarningIconWithTooltip from 'src/components/WarningIconWithTooltip'; import { isUserAdmin } from 'src/dashboard/util/permissionUtils'; import { GenericLink } from 'src/components/GenericLink/GenericLink'; diff --git a/superset-frontend/src/pages/Home/Home.test.tsx b/superset-frontend/src/pages/Home/Home.test.tsx index fd90d1624a..cbf9b00272 100644 --- a/superset-frontend/src/pages/Home/Home.test.tsx +++ b/superset-frontend/src/pages/Home/Home.test.tsx @@ -40,7 +40,7 @@ const chartFavoriteStatusEndpoint = 'glob:*/api/v1/chart/favorite_status?*'; const dashboardsEndpoint = 'glob:*/api/v1/dashboard/?*'; const dashboardInfoEndpoint = 'glob:*/api/v1/dashboard/_info?*'; const dashboardFavoriteStatusEndpoint = - 'glob:*/api/v1/dashboard/favorite_status?*'; + 'glob:*/api/v1/dashboard/favorite_status/?*'; const savedQueryEndpoint = 'glob:*/api/v1/saved_query/?*'; const savedQueryInfoEndpoint = 'glob:*/api/v1/saved_query/_info?*'; const recentActivityEndpoint = 'glob:*/api/v1/log/recent_activity/*'; diff --git a/superset-frontend/src/pages/Home/index.tsx b/superset-frontend/src/pages/Home/index.tsx index fa1d3649c4..6018b38bfa 100644 --- a/superset-frontend/src/pages/Home/index.tsx +++ b/superset-frontend/src/pages/Home/index.tsx @@ -18,6 +18,7 @@ */ import React, { useEffect, useMemo, useState } from 'react'; import { + FeatureFlag, getExtensionsRegistry, JsonObject, styled, @@ -28,26 +29,27 @@ import Collapse from 'src/components/Collapse'; import { User } from 'src/types/bootstrapTypes'; import { reject } from 'lodash'; import { - getItem, dangerouslyGetItemDoNotUse, - setItem, dangerouslySetItemDoNotUse, + getItem, LocalStorageKeys, + setItem, } from 'src/utils/localStorageHelpers'; import ListViewCard from 'src/components/ListViewCard'; import withToasts from 'src/components/MessageToasts/withToasts'; import { + CardContainer, createErrorHandler, getRecentActivityObjs, - mq, - CardContainer, getUserOwnedObjects, loadingCardCount, + mq, } from 'src/views/CRUD/utils'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { AntdSwitch } from 'src/components'; import getBootstrapData from 'src/utils/getBootstrapData'; import { TableTab } from 'src/views/CRUD/types'; +import SubMenu, { SubMenuProps } from 'src/views/components/SubMenu'; import { canUserAccessSqlLab } from 'src/dashboard/util/permissionUtils'; import { WelcomePageLastTab } from 'src/views/CRUD/welcome/types'; import ActivityTable from 'src/views/CRUD/welcome/ActivityTable'; @@ -125,23 +127,14 @@ const WelcomeContainer = styled.div` const WelcomeNav = styled.div` ${({ theme }) => ` - display: flex; - justify-content: space-between; - height: 50px; - background-color: ${theme.colors.grayscale.light5}; - .welcome-header { - font-size: ${theme.typography.sizes.l}px; - padding: ${theme.gridUnit * 4}px ${theme.gridUnit * 2 + 2}px; - margin: 0 ${theme.gridUnit * 2}px; - } .switch { display: flex; flex-direction: row; margin: ${theme.gridUnit * 4}px; span { display: block; - margin: ${theme.gridUnit * 1}px; - line-height: 1; + margin: ${theme.gridUnit}px; + line-height: ${theme.gridUnit * 3.5}px; } } `} @@ -171,7 +164,8 @@ function Welcome({ user, addDangerToast }: WelcomeProps) { const [activeChild, setActiveChild] = useState('Loading'); const userKey = dangerouslyGetItemDoNotUse(id, null); let defaultChecked = false; - if (isFeatureEnabled(FeatureFlag.THUMBNAILS)) { + const isThumbnailsEnabled = isFeatureEnabled(FeatureFlag.THUMBNAILS); + if (isThumbnailsEnabled) { defaultChecked = userKey?.thumbnails === undefined ? true : userKey?.thumbnails; } @@ -334,91 +328,107 @@ function Welcome({ user, addDangerToast }: WelcomeProps) { const isRecentActivityLoading = !activityData?.[TableTab.Other] && !activityData?.[TableTab.Viewed]; - return ( - - {WelcomeMessageExtension && } - {WelcomeTopExtension && } - {WelcomeMainExtension && } - {(!WelcomeTopExtension || !WelcomeMainExtension) && ( - <> + const menuData: SubMenuProps = { + activeChild: 'Home', + name: t('Home'), + }; + + if (isThumbnailsEnabled) { + menuData.buttons = [ + { + name: ( -

{t('Home')}

- {isFeatureEnabled(FeatureFlag.THUMBNAILS) ? ( -
- - {t('Thumbnails')} -
- ) : null} +
+ + {t('Thumbnails')} +
- - - {activityData && - (activityData[TableTab.Viewed] || - activityData[TableTab.Other] || - activityData[TableTab.Created]) && - activeChild !== 'Loading' ? ( - - ) : ( - - )} - - - {!dashboardData || isRecentActivityLoading ? ( - - ) : ( - - )} - - - {!chartData || isRecentActivityLoading ? ( - - ) : ( - - )} - - {canAccessSqlLab && ( - - {!queryData ? ( + ), + onClick: handleToggle, + buttonStyle: 'link', + }, + ]; + } + + return ( + <> + + + {WelcomeMessageExtension && } + {WelcomeTopExtension && } + {WelcomeMainExtension && } + {(!WelcomeTopExtension || !WelcomeMainExtension) && ( + <> + + + {activityData && + (activityData[TableTab.Viewed] || + activityData[TableTab.Other] || + activityData[TableTab.Created]) && + activeChild !== 'Loading' ? ( + + ) : ( + + )} + + + {!dashboardData || isRecentActivityLoading ? ( ) : ( - )} - )} - - - )} - + + {!chartData || isRecentActivityLoading ? ( + + ) : ( + + )} + + {canAccessSqlLab && ( + + {!queryData ? ( + + ) : ( + + )} + + )} + + + )} +
+ ); } diff --git a/superset-frontend/src/pages/SavedQueryList/index.tsx b/superset-frontend/src/pages/SavedQueryList/index.tsx index 5f57de5713..71eedc1de1 100644 --- a/superset-frontend/src/pages/SavedQueryList/index.tsx +++ b/superset-frontend/src/pages/SavedQueryList/index.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { SupersetClient, t, styled } from '@superset-ui/core'; +import { FeatureFlag, styled, SupersetClient, t } from '@superset-ui/core'; import React, { useState, useMemo, useCallback } from 'react'; import rison from 'rison'; import moment from 'moment'; @@ -49,7 +49,7 @@ import { commonMenuData } from 'src/views/CRUD/data/common'; import { SavedQueryObject } from 'src/views/CRUD/types'; import copyTextToClipboard from 'src/utils/copy'; import Tag from 'src/types/TagType'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import ImportModelsModal from 'src/components/ImportModal/index'; import Icons from 'src/components/Icons'; import { BootstrapUser } from 'src/types/bootstrapTypes'; diff --git a/superset-frontend/src/pages/Tags/index.tsx b/superset-frontend/src/pages/Tags/index.tsx index 440e33bf9c..13c3e8ec49 100644 --- a/superset-frontend/src/pages/Tags/index.tsx +++ b/superset-frontend/src/pages/Tags/index.tsx @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import { t } from '@superset-ui/core'; +import { FeatureFlag, t } from '@superset-ui/core'; import React, { useMemo, useCallback } from 'react'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { createFetchRelated, createErrorHandler, diff --git a/superset-frontend/src/utils/hostNamesConfig.js b/superset-frontend/src/utils/hostNamesConfig.js index 2fda95c46a..eabc3b64ee 100644 --- a/superset-frontend/src/utils/hostNamesConfig.js +++ b/superset-frontend/src/utils/hostNamesConfig.js @@ -16,11 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { - initFeatureFlags, - isFeatureEnabled, - FeatureFlag, -} from 'src/featureFlags'; +import { FeatureFlag } from '@superset-ui/core'; +import { initFeatureFlags, isFeatureEnabled } from 'src/featureFlags'; import getBootstrapData from './getBootstrapData'; function getDomainsConfig() { diff --git a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx index 302f9afdd9..9bf6cb6107 100644 --- a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx +++ b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx @@ -24,11 +24,12 @@ import React, { useCallback, } from 'react'; import { - styled, - t, - SupersetClient, css, + FeatureFlag, + styled, + SupersetClient, SupersetTheme, + t, } from '@superset-ui/core'; import rison from 'rison'; import { useSingleViewResource } from 'src/views/CRUD/hooks'; @@ -39,7 +40,7 @@ import Modal from 'src/components/Modal'; import TimezoneSelector from 'src/components/TimezoneSelector'; import { Radio } from 'src/components/Radio'; import { propertyComparator } from 'src/components/Select/utils'; -import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import withToasts from 'src/components/MessageToasts/withToasts'; import Owner from 'src/types/Owner'; import { AntdCheckbox, AsyncSelect, Select } from 'src/components'; diff --git a/superset-frontend/src/views/CRUD/chart/ChartCard.tsx b/superset-frontend/src/views/CRUD/chart/ChartCard.tsx index df9b148567..1a80d34aa8 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartCard.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartCard.tsx @@ -17,9 +17,9 @@ * under the License. */ import React from 'react'; -import { t, useTheme } from '@superset-ui/core'; +import { FeatureFlag, t, useTheme } from '@superset-ui/core'; import { Link, useHistory } from 'react-router-dom'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import ConfirmStatusChange from 'src/components/ConfirmStatusChange'; import Icons from 'src/components/Icons'; import Chart from 'src/types/Chart'; diff --git a/superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx b/superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx index 0a46749a01..8d15939515 100644 --- a/superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx +++ b/superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx @@ -18,9 +18,9 @@ */ import React from 'react'; import { Link, useHistory } from 'react-router-dom'; -import { t, useTheme } from '@superset-ui/core'; +import { FeatureFlag, t, useTheme } from '@superset-ui/core'; +import { isFeatureEnabled } from 'src/featureFlags'; import { CardStyles } from 'src/views/CRUD/utils'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; import { AntdDropdown } from 'src/components'; import { Menu } from 'src/components/Menu'; import ListViewCard from 'src/components/ListViewCard'; diff --git a/superset-frontend/src/views/CRUD/tags/TagCard.tsx b/superset-frontend/src/views/CRUD/tags/TagCard.tsx index 84e600262e..7ed8c1df0d 100644 --- a/superset-frontend/src/views/CRUD/tags/TagCard.tsx +++ b/superset-frontend/src/views/CRUD/tags/TagCard.tsx @@ -18,9 +18,9 @@ */ import React from 'react'; import { Link } from 'react-router-dom'; -import { t, useTheme } from '@superset-ui/core'; +import { FeatureFlag, t, useTheme } from '@superset-ui/core'; import { CardStyles } from 'src/views/CRUD/utils'; -import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; +import { isFeatureEnabled } from 'src/featureFlags'; import { AntdDropdown } from 'src/components'; import { Menu } from 'src/components/Menu'; import ConfirmStatusChange from 'src/components/ConfirmStatusChange';