From 19f8405bc07127b5e67118cbbaec5dfce2cd349d Mon Sep 17 00:00:00 2001 From: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Date: Wed, 31 Jan 2024 17:40:44 -0800 Subject: [PATCH] chore: make TS enums strictly PascalCase (#26875) --- superset-frontend/.eslintrc.js | 11 + .../ColumnTypeLabel/ColumnTypeLabel.tsx | 8 +- .../src/constants.ts | 8 +- .../src/fixtures.ts | 10 +- .../src/shared-controls/customControls.tsx | 6 +- .../superset-ui-chart-controls/src/types.ts | 36 ++-- .../src/utils/getColorFormatters.ts | 36 ++-- .../test/components/ColumnOption.test.tsx | 6 +- .../test/components/ColumnTypeLabel.test.tsx | 10 +- .../test/utils/checkColumnType.test.ts | 12 +- .../test/utils/columnChoices.test.tsx | 6 +- .../test/utils/getColorFormatters.test.ts | 44 ++-- .../test/utils/getTemporalColumns.test.ts | 2 +- .../ChartBuildQueryRegistrySingleton.ts | 2 +- .../ChartComponentRegistrySingleton.ts | 2 +- .../ChartMetadataRegistrySingleton.ts | 2 +- .../ChartTransformPropsRegistrySingleton.ts | 2 +- .../superset-ui-core/src/chart/types/Base.ts | 38 ++-- .../src/color/CategoricalColorScale.ts | 4 +- .../src/color/ColorSchemeRegistry.ts | 2 +- .../src/color/SharedLabelColorSingleton.ts | 10 +- .../src/components/SafeMarkdown.tsx | 2 +- .../superset-ui-core/src/models/Registry.ts | 16 +- .../number-format/NumberFormatterRegistry.ts | 2 +- .../src/query/api/v1/types.ts | 24 +-- .../src/query/extractQueryFields.ts | 6 +- .../src/query/types/Dashboard.ts | 12 +- .../superset-ui-core/src/query/types/Query.ts | 56 ++--- .../src/query/types/QueryFormData.ts | 4 +- .../src/query/types/QueryResponse.ts | 8 +- .../src/time-format/TimeFormatterRegistry.ts | 2 +- .../src/utils/featureFlags.ts | 69 +++---- .../test/chart/models/ChartProps.test.ts | 2 +- .../test/color/CategoricalColorScale.test.ts | 8 +- .../color/SharedLabelColorSingleton.test.ts | 10 +- .../superset-ui-core/test/fixtures.ts | 2 +- .../test/models/Registry.test.ts | 8 +- .../test/query/api/v1/handleError.test.ts | 2 +- .../test/query/extractQueryFields.test.ts | 6 +- .../test/query/types/Dashboard.test.ts | 4 +- .../test/utils/featureFlag.test.ts | 6 +- .../plugins/plugin-chart-table/testData.ts | 8 +- .../src/transformProps.js | 4 +- .../src/WorldMap.js | 2 +- .../src/controlPanel.ts | 10 +- .../src/index.js | 6 +- .../src/utils.ts | 4 +- .../src/utilities/Shared_DeckGL.jsx | 4 +- .../src/Area/index.js | 2 +- .../legacy-preset-chart-nvd3/src/Bar/index.js | 2 +- .../src/Bubble/index.js | 2 +- .../src/DistBar/index.js | 2 +- .../src/Line/index.js | 2 +- .../legacy-preset-chart-nvd3/src/Pie/index.js | 2 +- .../BigNumber/BigNumberTotal/controlPanel.ts | 2 +- .../src/BigNumber/BigNumberTotal/index.ts | 2 +- .../BigNumberTotal/transformProps.ts | 4 +- .../BigNumber/BigNumberWithTrendline/index.ts | 2 +- .../BigNumberWithTrendline/transformProps.ts | 4 +- .../plugin-chart-echarts/src/BoxPlot/index.ts | 6 +- .../plugin-chart-echarts/src/Bubble/index.ts | 2 +- .../src/Bubble/transformProps.ts | 4 +- .../src/Funnel/controlPanel.tsx | 11 +- .../plugin-chart-echarts/src/Funnel/index.ts | 6 +- .../src/Funnel/transformProps.ts | 6 +- .../plugin-chart-echarts/src/Funnel/types.ts | 6 +- .../plugin-chart-echarts/src/Gauge/index.ts | 6 +- .../plugin-chart-echarts/src/Graph/index.ts | 6 +- .../EchartsMixedTimeseries.tsx | 4 +- .../src/MixedTimeseries/index.ts | 6 +- .../src/MixedTimeseries/transformProps.ts | 7 +- .../plugin-chart-echarts/src/Pie/index.ts | 6 +- .../src/Radar/controlPanel.tsx | 2 +- .../plugin-chart-echarts/src/Radar/index.ts | 6 +- .../src/Sunburst/index.ts | 6 +- .../src/Timeseries/Area/index.ts | 6 +- .../src/Timeseries/EchartsTimeseries.tsx | 4 +- .../Timeseries/Regular/Bar/controlPanel.tsx | 12 +- .../src/Timeseries/Regular/Bar/index.ts | 6 +- .../src/Timeseries/Regular/Line/index.ts | 6 +- .../src/Timeseries/Regular/Scatter/index.ts | 6 +- .../Timeseries/Regular/SmoothLine/index.ts | 6 +- .../src/Timeseries/Step/index.ts | 6 +- .../src/Timeseries/constants.ts | 2 +- .../src/Timeseries/index.ts | 6 +- .../src/Timeseries/transformProps.ts | 10 +- .../src/Timeseries/types.ts | 4 +- .../plugin-chart-echarts/src/Treemap/index.ts | 6 +- .../src/Waterfall/index.ts | 2 +- .../src/Waterfall/transformProps.ts | 2 +- .../src/utils/annotation.ts | 4 +- .../plugin-chart-echarts/src/utils/series.ts | 16 +- .../test/Funnel/transformProps.test.ts | 20 +- .../test/utils/annotation.test.ts | 6 +- .../test/utils/series.test.ts | 42 ++-- .../src/plugin/controls/queryMode.tsx | 4 +- .../src/plugin/controls/shared.ts | 8 +- .../src/PivotTableChart.tsx | 4 +- .../src/plugin/index.ts | 6 +- .../src/plugin/transformProps.ts | 2 +- .../src/DataTable/hooks/useSticky.tsx | 10 +- .../plugin-chart-table/src/TableChart.tsx | 4 +- .../plugin-chart-table/src/buildQuery.ts | 10 +- .../plugin-chart-table/src/controlPanel.tsx | 14 +- .../plugins/plugin-chart-table/src/index.ts | 6 +- .../plugin-chart-table/src/transformProps.ts | 12 +- .../src/utils/formatValue.ts | 2 +- .../test/buildQuery.test.ts | 12 +- .../plugin-chart-table/test/testData.ts | 18 +- .../spec/fixtures/mockDashboardInfo.js | 2 +- .../spec/fixtures/mockNativeFilters.ts | 4 +- superset-frontend/spec/fixtures/mockStore.js | 4 +- .../src/SqlLab/actions/sqlLab.js | 28 +-- .../KeyboardShortcutButton/index.tsx | 56 ++--- .../src/SqlLab/components/ResultSet/index.tsx | 37 ++-- .../components/SaveDatasetModal/index.tsx | 10 +- .../components/ShareSqlLabQuery/index.tsx | 4 +- .../src/SqlLab/components/SouthPane/index.tsx | 2 +- .../src/SqlLab/components/SqlEditor/index.tsx | 65 +++--- .../components/SqlEditorLeftBar/index.tsx | 4 +- .../components/TabbedSqlEditors/index.jsx | 4 +- .../TableElement/TableElement.test.tsx | 2 +- superset-frontend/src/SqlLab/fixtures.ts | 28 +-- .../middlewares/persistSqlLabStateEnhancer.js | 2 +- .../src/SqlLab/reducers/getInitialState.ts | 2 +- .../src/SqlLab/reducers/sqlLab.js | 24 +-- .../src/SqlLab/reducers/sqlLab.test.js | 6 +- superset-frontend/src/SqlLab/types.ts | 8 +- .../src/components/Chart/Chart.jsx | 4 +- .../ChartContextMenu/ChartContextMenu.tsx | 8 +- .../ChartContextMenu/useContextMenu.test.tsx | 6 +- .../src/components/Chart/ChartRenderer.jsx | 8 +- .../Chart/DrillBy/DrillByMenuItems.test.tsx | 2 +- .../Chart/DrillBy/DrillByMenuItems.tsx | 2 +- .../DrillDetail/DrillDetailMenuItems.tsx | 2 +- .../Chart/DrillDetail/DrillDetailPane.tsx | 8 +- .../src/components/Chart/chartAction.js | 4 +- .../src/components/Chart/chartReducer.ts | 2 +- .../components/Datasource/CollectionTable.tsx | 16 +- .../Datasource/DatasourceEditor.jsx | 10 +- .../components/Datasource/DatasourceModal.tsx | 2 +- .../src/components/Dropdown/index.tsx | 10 +- .../src/components/DynamicPlugins/index.tsx | 4 +- .../getErrorMessageComponentRegistry.ts | 2 +- .../src/components/FilterableTable/index.tsx | 2 +- .../src/components/ListView/types.ts | 56 ++--- .../src/components/MessageToasts/Toast.tsx | 6 +- .../src/components/MessageToasts/actions.ts | 8 +- .../getToastsFromPyFlashMessages.js | 4 +- .../getToastsFromPyFlashMessages.test.js | 6 +- .../MessageToasts/mockMessageToasts.js | 4 +- .../src/components/MessageToasts/types.ts | 8 +- .../components/MetadataBar/ContentConfig.tsx | 16 +- .../src/components/MetadataBar/ContentType.ts | 32 +-- .../MetadataBar/MetadataBar.stories.mdx | 32 +-- .../MetadataBar/MetadataBar.stories.tsx | 10 +- .../MetadataBar/MetadataBar.test.tsx | 16 +- .../useStoredSidebarWidth.test.ts | 6 +- .../ResizableSidebar/useStoredSidebarWidth.ts | 4 +- .../src/components/Table/Table.stories.tsx | 46 ++--- .../src/components/Table/Table.test.tsx | 2 +- .../src/components/Table/VirtualTable.tsx | 4 +- .../Table/cell-renderers/ActionCell/index.tsx | 2 +- .../NumericCell/NumericCell.stories.tsx | 4 +- .../NumericCell/NumericCell.test.tsx | 4 +- .../cell-renderers/NumericCell/index.tsx | 99 ++++----- .../src/components/Table/index.tsx | 26 +-- .../src/dashboard/actions/dashboardState.js | 8 +- .../src/dashboard/actions/datasources.ts | 12 +- .../src/dashboard/actions/hydrate.js | 8 +- .../AddSliceCard/AddSliceCard.test.tsx | 4 +- .../components/AddSliceCard/AddSliceCard.tsx | 2 +- .../src/dashboard/components/Dashboard.jsx | 2 +- .../DashboardBuilder/DashboardBuilder.tsx | 22 +- .../src/dashboard/components/Header/index.jsx | 2 +- .../components/PropertiesModal/index.tsx | 12 +- .../src/dashboard/components/SliceAdder.jsx | 7 +- .../SliceHeaderControls.test.tsx | 18 +- .../components/SliceHeaderControls/index.tsx | 8 +- .../SyncDashboardState.test.tsx | 2 +- .../components/SyncDashboardState/index.tsx | 4 +- .../components/gridComponents/Row.jsx | 2 +- .../FilterBar/ActionButtons/index.tsx | 4 +- .../CrossFilters/CrossFilter.test.tsx | 2 +- .../FilterBar/CrossFilters/CrossFilter.tsx | 6 +- .../CrossFilters/CrossFilterTag.test.tsx | 2 +- .../FilterBar/CrossFilters/CrossFilterTag.tsx | 2 +- .../CrossFilters/CrossFilterTitle.test.tsx | 2 +- .../CrossFilters/CrossFilterTitle.tsx | 2 +- .../CrossFilters/VerticalCollapse.tsx | 2 +- .../FilterBar/FilterBar.test.tsx | 2 +- .../FilterBarSettings.test.tsx | 28 +-- .../FilterBar/FilterBarSettings/index.tsx | 10 +- .../FilterControls/FilterControl.tsx | 8 +- .../FilterControls/FilterControls.tsx | 12 +- .../FilterControls/FilterDivider.stories.tsx | 2 +- .../FilterControls/FilterDivider.test.tsx | 8 +- .../FilterControls/FilterDivider.tsx | 4 +- .../FilterBar/FilterControls/FilterValue.tsx | 6 +- .../FiltersDropdownContent/index.tsx | 4 +- .../nativeFilters/FilterBar/Horizontal.tsx | 2 +- .../FilterBar/HorizontalFilterBar.test.tsx | 2 +- .../nativeFilters/FilterBar/Vertical.tsx | 2 +- .../nativeFilters/FilterBar/index.tsx | 4 +- .../FilterCard/FilterCard.test.tsx | 6 +- .../FiltersConfigModal/DividerConfigForm.tsx | 2 +- .../FiltersConfigModal/FilterTitlePane.tsx | 4 +- .../FiltersConfigForm/DefaultValue.tsx | 4 +- .../FilterScope/FilterScope.tsx | 20 +- .../FiltersConfigForm/FilterScope/types.ts | 4 +- .../FiltersConfigForm/FiltersConfigForm.tsx | 10 +- .../FiltersConfigForm/constants.ts | 16 +- .../getControlItemsMap.test.tsx | 2 +- .../FiltersConfigForm/utils.ts | 2 +- .../nativeFilters/FiltersConfigModal/state.ts | 2 +- .../nativeFilters/FiltersConfigModal/types.ts | 4 +- .../nativeFilters/FiltersConfigModal/utils.ts | 6 +- .../components/nativeFilters/selectors.ts | 6 +- .../components/nativeFilters/utils.test.ts | 14 +- .../components/nativeFilters/utils.ts | 8 +- .../dashboard/containers/DashboardPage.tsx | 4 +- .../dashboard/fixtures/mockNativeFilters.ts | 2 +- .../src/dashboard/reducers/datasources.ts | 4 +- superset-frontend/src/dashboard/types.ts | 4 +- .../src/dashboard/util/constants.ts | 8 +- .../src/dashboard/util/crossFilters.test.ts | 10 +- .../src/dashboard/util/crossFilters.ts | 6 +- .../dashboard/util/getDashboardUrl.test.js | 12 +- .../dashboard/util/permissionUtils.test.ts | 4 +- .../src/dashboard/util/permissionUtils.ts | 2 +- superset-frontend/src/dataMask/reducer.ts | 2 +- .../src/explore/actions/saveModalActions.js | 6 +- .../src/explore/components/ChartPills.tsx | 11 +- .../components/ControlPanelsContainer.tsx | 10 +- .../components/DataTableControl/index.tsx | 6 +- .../DataTableControl/useTableColumns.test.ts | 12 +- .../components/DataTableControl/utils.ts | 15 +- .../DataTablesPane/DataTablesPane.tsx | 8 +- .../components/DataTableControls.tsx | 2 +- .../test/DataTablesPane.test.tsx | 4 +- .../components/DatasourcePanel/fixtures.tsx | 6 +- .../ExploreChartHeader.test.tsx | 2 +- .../components/ExploreChartHeader/index.jsx | 8 +- .../ExploreChartPanel.test.jsx | 2 +- .../components/ExploreChartPanel/index.jsx | 10 +- .../components/ExploreViewContainer/index.jsx | 12 +- .../components/ExportToCSVDropdown/index.tsx | 14 +- .../components/PropertiesModal/index.tsx | 8 +- .../ColumnConfigPopover.tsx | 2 +- .../ColumnConfigControl/constants.tsx | 8 +- .../ConditionalFormattingControl.tsx | 20 +- .../FormattingPopoverContent.tsx | 40 ++-- .../ConditionalFormattingControl/types.ts | 25 +-- .../ContourControl/ContourPopoverControl.tsx | 20 +- .../DateFilterControl/DateFilterLabel.tsx | 14 +- .../components/CommonFrame.tsx | 7 +- .../tests/DateFilterLabel.test.tsx | 10 +- .../DateFilterControl/utils/constants.ts | 14 +- .../DndFilterSelect.test.tsx | 6 +- .../DndFilterSelect.tsx | 42 ++-- .../DndMetricSelect.tsx | 8 +- .../AdhocFilter/AdhocFilter.test.js | 92 ++++----- .../FilterControl/AdhocFilter/index.js | 27 ++- .../AdhocFilterControl.test.jsx | 28 +-- .../AdhocFilterControl/index.jsx | 20 +- .../AdhocFilterEditPopover.test.jsx | 14 +- .../AdhocFilterEditPopover/index.jsx | 6 +- ...FilterEditPopoverSimpleTabContent.test.tsx | 84 ++++---- .../index.tsx | 62 +++--- ...hocFilterEditPopoverSqlTabContent.test.jsx | 10 +- .../index.jsx | 8 +- .../AdhocFilterOption.test.tsx | 6 +- .../AdhocFilterPopoverTrigger.test.tsx | 6 +- .../controls/FilterControl/adhocFilterType.js | 10 +- .../controls/FilterControl/types.ts | 12 +- .../FilterControl/utils/translateToSQL.ts | 2 +- .../utils/useGetTimeRangeLabel.test.ts | 30 +-- .../utils/useGetTimeRangeLabel.tsx | 12 +- .../VizTypeControl/VizTypeGallery.tsx | 35 ++-- .../useExploreAdditionalActionsMenu/index.jsx | 2 +- superset-frontend/src/explore/constants.ts | 99 ++++----- .../exploreUtils/exploreUtils.test.jsx | 2 +- .../getSimpleSQLExpression.test.ts | 4 +- .../src/explore/exploreUtils/index.js | 2 +- .../src/features/alerts/AlertReportModal.tsx | 2 +- .../src/features/alerts/types.ts | 4 +- .../src/features/charts/ChartCard.tsx | 2 +- .../src/features/dashboards/DashboardCard.tsx | 2 +- .../DatabaseConnectionForm/EncryptedField.tsx | 12 +- .../databases/DatabaseModal/SSHTunnelForm.tsx | 10 +- .../DatabaseModal/SSHTunnelSwitch.tsx | 2 +- .../databases/DatabaseModal/index.test.tsx | 60 +++--- .../databases/DatabaseModal/index.tsx | 191 +++++++++--------- .../src/features/databases/types.ts | 8 +- .../AddDataset/DatasetPanel/DatasetPanel.tsx | 4 +- .../AddDataset/EditDataset/UsageTab/index.tsx | 4 +- .../datasets/AddDataset/Header/index.tsx | 2 +- .../datasets/AddDataset/LeftPanel/index.tsx | 8 +- .../features/datasets/AddDataset/types.tsx | 16 +- .../metadataBar/useDatasetMetadataBar.tsx | 18 +- .../src/features/home/ActivityTable.tsx | 6 +- .../src/features/home/ChartTable.tsx | 8 +- .../src/features/home/DashboardTable.tsx | 8 +- superset-frontend/src/features/home/Menu.tsx | 16 +- .../src/features/home/RightMenu.test.tsx | 6 +- .../src/features/home/RightMenu.tsx | 10 +- superset-frontend/src/features/home/types.ts | 6 +- .../queries/QueryPreviewModal.test.tsx | 2 +- .../HeaderReportDropdown/index.test.tsx | 2 +- .../HeaderReportDropdown/index.tsx | 12 +- .../reports/ReportModal/ReportModal.test.tsx | 2 +- .../features/reports/ReportModal/index.tsx | 16 +- .../src/features/reports/types.ts | 8 +- .../rls/RowLevelSecurityModal.test.tsx | 6 +- .../features/rls/RowLevelSecurityModal.tsx | 4 +- superset-frontend/src/features/rls/types.ts | 4 +- .../src/features/tags/TagCard.tsx | 2 +- .../Range/RangeFilterPlugin.stories.tsx | 4 +- .../Range/RangeFilterPlugin.test.tsx | 8 +- .../components/Range/RangeFilterPlugin.tsx | 6 +- .../filters/components/Range/buildQuery.ts | 4 +- .../src/filters/components/Range/index.ts | 2 +- .../Select/SelectFilterPlugin.test.tsx | 2 +- .../components/Select/SelectFilterPlugin.tsx | 6 +- .../components/Select/buildQuery.test.ts | 4 +- .../filters/components/Select/buildQuery.ts | 4 +- .../src/filters/components/Select/index.ts | 2 +- .../src/filters/components/Time/index.ts | 2 +- .../TimeColumn/TimeColumnFilterPlugin.tsx | 2 +- .../filters/components/TimeColumn/index.ts | 2 +- .../src/filters/components/TimeGrain/index.ts | 2 +- superset-frontend/src/filters/utils.test.ts | 88 ++++---- superset-frontend/src/filters/utils.ts | 14 +- .../hooks/apiResources/apiResources.test.ts | 16 +- .../src/hooks/apiResources/apiResources.ts | 22 +- .../src/middleware/asyncEvent.ts | 2 +- .../src/pages/AlertReportList/index.tsx | 12 +- .../src/pages/AllEntities/index.tsx | 6 +- .../src/pages/AnnotationLayerList/index.tsx | 6 +- .../src/pages/Chart/Chart.test.tsx | 2 +- superset-frontend/src/pages/Chart/index.tsx | 6 +- .../src/pages/ChartList/index.tsx | 32 +-- .../src/pages/CssTemplateList/index.tsx | 6 +- .../src/pages/DashboardList/index.tsx | 26 +-- .../src/pages/DatabaseList/index.tsx | 12 +- .../src/pages/DatasetCreation/index.tsx | 8 +- .../src/pages/DatasetList/index.tsx | 16 +- superset-frontend/src/pages/Home/index.tsx | 8 +- .../QueryHistoryList.test.tsx | 2 +- .../src/pages/QueryHistoryList/index.tsx | 52 ++--- .../src/pages/RowLevelSecurityList/index.tsx | 10 +- .../src/pages/SavedQueryList/index.tsx | 16 +- superset-frontend/src/pages/SqlLab/index.tsx | 2 +- superset-frontend/src/pages/Tags/index.tsx | 10 +- .../utils/isDashboardVirtualizationEnabled.ts | 14 +- .../src/utils/localStorageHelpers.test.ts | 6 +- .../src/utils/localStorageHelpers.ts | 32 +-- .../src/utils/simpleFilterToAdhoc.ts | 8 +- superset-frontend/src/views/CRUD/types.ts | 36 ++-- superset-frontend/src/views/routes.tsx | 2 +- superset-frontend/src/views/store.ts | 2 +- .../src/visualizations/presets/MainPreset.js | 2 +- 362 files changed, 2002 insertions(+), 2032 deletions(-) diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js index 5d15f87e4..45274955e 100644 --- a/superset-frontend/.eslintrc.js +++ b/superset-frontend/.eslintrc.js @@ -93,6 +93,17 @@ module.exports = { '@typescript-eslint/ban-ts-ignore': 0, '@typescript-eslint/ban-ts-comment': 0, // disabled temporarily '@typescript-eslint/ban-types': 0, // disabled temporarily + '@typescript-eslint/naming-convention': [ + 'error', + { + selector: 'enum', + format: ['PascalCase'], + }, + { + selector: 'enumMember', + format: ['PascalCase'], + }, + ], '@typescript-eslint/no-empty-function': 0, '@typescript-eslint/no-explicit-any': 0, '@typescript-eslint/no-use-before-define': 1, // disabled temporarily diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnTypeLabel/ColumnTypeLabel.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnTypeLabel/ColumnTypeLabel.tsx index 19ae7bd78..5962e9427 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnTypeLabel/ColumnTypeLabel.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnTypeLabel/ColumnTypeLabel.tsx @@ -57,13 +57,13 @@ export function ColumnTypeLabel({ type }: ColumnTypeLabelProps) { if (type === '' || type === 'expression') { typeIcon = ; - } else if (type === GenericDataType.STRING) { + } else if (type === GenericDataType.String) { typeIcon = ; - } else if (type === GenericDataType.NUMERIC) { + } else if (type === GenericDataType.Numeric) { typeIcon = ; - } else if (type === GenericDataType.BOOLEAN) { + } else if (type === GenericDataType.Boolean) { typeIcon = ; - } else if (type === GenericDataType.TEMPORAL) { + } else if (type === GenericDataType.Temporal) { typeIcon = ; } diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/constants.ts b/superset-frontend/packages/superset-ui-chart-controls/src/constants.ts index 1aefc2546..4230d6683 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/constants.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/constants.ts @@ -43,7 +43,7 @@ export const DATASET_TIME_COLUMN_OPTION: ColumnMeta = { verbose_name: COLUMN_NAME_ALIASES[DTTM_ALIAS], column_name: DTTM_ALIAS, type: 'TIMESTAMP', - type_generic: GenericDataType.TEMPORAL, + type_generic: GenericDataType.Temporal, description: t( 'A reference to the [Time] configuration, taking granularity into account', ), @@ -53,12 +53,12 @@ export const QUERY_TIME_COLUMN_OPTION: QueryColumn = { column_name: DTTM_ALIAS, is_dttm: true, type: 'TIMESTAMP', - type_generic: GenericDataType.TEMPORAL, + type_generic: GenericDataType.Temporal, }; export const QueryModeLabel = { - [QueryMode.aggregate]: t('Aggregate'), - [QueryMode.raw]: t('Raw records'), + [QueryMode.Aggregate]: t('Aggregate'), + [QueryMode.Raw]: t('Raw records'), }; export const DEFAULT_SORT_SERIES_DATA: SortSeriesData = { diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/fixtures.ts b/superset-frontend/packages/superset-ui-chart-controls/src/fixtures.ts index b12d5be04..efdfef6c4 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/fixtures.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/fixtures.ts @@ -37,7 +37,7 @@ export const TestDataset: Dataset = { is_dttm: false, python_date_format: null, type: 'BIGINT', - type_generic: GenericDataType.NUMERIC, + type_generic: GenericDataType.Numeric, verbose_name: null, warning_markdown: null, }, @@ -55,7 +55,7 @@ export const TestDataset: Dataset = { is_dttm: false, python_date_format: null, type: 'VARCHAR(16)', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, verbose_name: '', warning_markdown: null, }, @@ -73,7 +73,7 @@ export const TestDataset: Dataset = { is_dttm: false, python_date_format: null, type: 'VARCHAR(10)', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, verbose_name: null, warning_markdown: null, }, @@ -91,7 +91,7 @@ export const TestDataset: Dataset = { is_dttm: true, python_date_format: null, type: 'TIMESTAMP WITHOUT TIME ZONE', - type_generic: GenericDataType.TEMPORAL, + type_generic: GenericDataType.Temporal, verbose_name: null, warning_markdown: null, }, @@ -109,7 +109,7 @@ export const TestDataset: Dataset = { is_dttm: false, python_date_format: null, type: 'VARCHAR(255)', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, verbose_name: null, warning_markdown: null, }, diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx index b0f300635..7fb4f9a8b 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx @@ -60,7 +60,7 @@ function isForcedCategorical(controls: ControlStateMapping): boolean { checkColumnType( getColumnLabel(controls?.x_axis?.value as QueryFormColumn), controls?.datasource?.datasource, - [GenericDataType.NUMERIC], + [GenericDataType.Numeric], ) && !!controls?.xAxisForceCategorical?.value ); } @@ -71,7 +71,7 @@ function isSortable(controls: ControlStateMapping): boolean { checkColumnType( getColumnLabel(controls?.x_axis?.value as QueryFormColumn), controls?.datasource?.datasource, - [GenericDataType.STRING, GenericDataType.BOOLEAN], + [GenericDataType.String, GenericDataType.Boolean], ) ); } @@ -173,7 +173,7 @@ export const xAxisForceCategoricalControl = { checkColumnType( getColumnLabel(controls?.x_axis?.value as QueryFormColumn), controls?.datasource?.datasource, - [GenericDataType.NUMERIC], + [GenericDataType.Numeric], ), shouldMapStateToProps: () => true, }, diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/types.ts b/superset-frontend/packages/superset-ui-chart-controls/src/types.ts index 8aa475a7f..546936ee7 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/types.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/types.ts @@ -420,29 +420,29 @@ export type SectionOverrides = { // Ref: // - superset-frontend/src/explore/components/ConditionalFormattingControl.tsx -export enum COMPARATOR { - NONE = 'None', - GREATER_THAN = '>', - LESS_THAN = '<', - GREATER_OR_EQUAL = '≥', - LESS_OR_EQUAL = '≤', - EQUAL = '=', - NOT_EQUAL = '≠', - BETWEEN = '< x <', - BETWEEN_OR_EQUAL = '≤ x ≤', - BETWEEN_OR_LEFT_EQUAL = '≤ x <', - BETWEEN_OR_RIGHT_EQUAL = '< x ≤', +export enum Comparator { + None = 'None', + GreaterThan = '>', + LessThan = '<', + GreaterOrEqual = '≥', + LessOrEqual = '≤', + Equal = '=', + NotEqual = '≠', + Between = '< x <', + BetweenOrEqual = '≤ x ≤', + BetweenOrLeftEqual = '≤ x <', + BetweenOrRightEqual = '< x ≤', } -export const MULTIPLE_VALUE_COMPARATORS = [ - COMPARATOR.BETWEEN, - COMPARATOR.BETWEEN_OR_EQUAL, - COMPARATOR.BETWEEN_OR_LEFT_EQUAL, - COMPARATOR.BETWEEN_OR_RIGHT_EQUAL, +export const MultipleValueComparators = [ + Comparator.Between, + Comparator.BetweenOrEqual, + Comparator.BetweenOrLeftEqual, + Comparator.BetweenOrRightEqual, ]; export type ConditionalFormattingConfig = { - operator?: COMPARATOR; + operator?: Comparator; targetValue?: number; targetValueLeft?: number; targetValueRight?: number; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/utils/getColorFormatters.ts b/superset-frontend/packages/superset-ui-chart-controls/src/utils/getColorFormatters.ts index 1a6aa140a..4e5e89fe4 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/utils/getColorFormatters.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/utils/getColorFormatters.ts @@ -20,9 +20,9 @@ import memoizeOne from 'memoize-one'; import { addAlpha, DataRecord } from '@superset-ui/core'; import { ColorFormatters, - COMPARATOR, + Comparator, ConditionalFormattingConfig, - MULTIPLE_VALUE_COMPARATORS, + MultipleValueComparators, } from '../types'; export const round = (num: number, precision = 0) => @@ -75,20 +75,20 @@ export const getColorFunction = ( return () => undefined; } if ( - MULTIPLE_VALUE_COMPARATORS.includes(operator) && + MultipleValueComparators.includes(operator) && (targetValueLeft === undefined || targetValueRight === undefined) ) { return () => undefined; } if ( - operator !== COMPARATOR.NONE && - !MULTIPLE_VALUE_COMPARATORS.includes(operator) && + operator !== Comparator.None && + !MultipleValueComparators.includes(operator) && targetValue === undefined ) { return () => undefined; } switch (operator) { - case COMPARATOR.NONE: + case Comparator.None: minOpacity = MIN_OPACITY_UNBOUNDED; comparatorFunction = (value: number, allValues: number[]) => { const cutoffValue = Math.min(...allValues); @@ -98,37 +98,37 @@ export const getColorFunction = ( : false; }; break; - case COMPARATOR.GREATER_THAN: + case Comparator.GreaterThan: comparatorFunction = (value: number, allValues: number[]) => value > targetValue! ? { cutoffValue: targetValue!, extremeValue: Math.max(...allValues) } : false; break; - case COMPARATOR.LESS_THAN: + case Comparator.LessThan: comparatorFunction = (value: number, allValues: number[]) => value < targetValue! ? { cutoffValue: targetValue!, extremeValue: Math.min(...allValues) } : false; break; - case COMPARATOR.GREATER_OR_EQUAL: + case Comparator.GreaterOrEqual: comparatorFunction = (value: number, allValues: number[]) => value >= targetValue! ? { cutoffValue: targetValue!, extremeValue: Math.max(...allValues) } : false; break; - case COMPARATOR.LESS_OR_EQUAL: + case Comparator.LessOrEqual: comparatorFunction = (value: number, allValues: number[]) => value <= targetValue! ? { cutoffValue: targetValue!, extremeValue: Math.min(...allValues) } : false; break; - case COMPARATOR.EQUAL: + case Comparator.Equal: comparatorFunction = (value: number) => value === targetValue! ? { cutoffValue: targetValue!, extremeValue: targetValue! } : false; break; - case COMPARATOR.NOT_EQUAL: + case Comparator.NotEqual: comparatorFunction = (value: number, allValues: number[]) => { if (value === targetValue!) { return false; @@ -144,25 +144,25 @@ export const getColorFunction = ( }; }; break; - case COMPARATOR.BETWEEN: + case Comparator.Between: comparatorFunction = (value: number) => value > targetValueLeft! && value < targetValueRight! ? { cutoffValue: targetValueLeft!, extremeValue: targetValueRight! } : false; break; - case COMPARATOR.BETWEEN_OR_EQUAL: + case Comparator.BetweenOrEqual: comparatorFunction = (value: number) => value >= targetValueLeft! && value <= targetValueRight! ? { cutoffValue: targetValueLeft!, extremeValue: targetValueRight! } : false; break; - case COMPARATOR.BETWEEN_OR_LEFT_EQUAL: + case Comparator.BetweenOrLeftEqual: comparatorFunction = (value: number) => value >= targetValueLeft! && value < targetValueRight! ? { cutoffValue: targetValueLeft!, extremeValue: targetValueRight! } : false; break; - case COMPARATOR.BETWEEN_OR_RIGHT_EQUAL: + case Comparator.BetweenOrRightEqual: comparatorFunction = (value: number) => value > targetValueLeft! && value <= targetValueRight! ? { cutoffValue: targetValueLeft!, extremeValue: targetValueRight! } @@ -197,9 +197,9 @@ export const getColorFormatters = memoizeOne( (acc: ColorFormatters, config: ConditionalFormattingConfig) => { if ( config?.column !== undefined && - (config?.operator === COMPARATOR.NONE || + (config?.operator === Comparator.None || (config?.operator !== undefined && - (MULTIPLE_VALUE_COMPARATORS.includes(config?.operator) + (MultipleValueComparators.includes(config?.operator) ? config?.targetValueLeft !== undefined && config?.targetValueRight !== undefined : config?.targetValue !== undefined))) diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnOption.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnOption.test.tsx index b1fb4b265..ff146862b 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnOption.test.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnOption.test.tsx @@ -65,7 +65,7 @@ describe('ColumnOption', () => { column: { column_name: 'foo', type: 'VARCHAR', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, }, }), ); @@ -92,11 +92,11 @@ describe('ColumnOption', () => { it('dttm column has correct column label if showType is true', () => { props.showType = true; props.column.expression = undefined; - props.column.type_generic = GenericDataType.TEMPORAL; + props.column.type_generic = GenericDataType.Temporal; wrapper = shallow(factory(props)); expect(wrapper.find(ColumnTypeLabel)).toHaveLength(1); expect(wrapper.find(ColumnTypeLabel).props().type).toBe( - GenericDataType.TEMPORAL, + GenericDataType.Temporal, ); }); }); diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnTypeLabel.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnTypeLabel.test.tsx index 8369a7909..07cbfa7a2 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnTypeLabel.test.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnTypeLabel.test.tsx @@ -25,7 +25,7 @@ import { ColumnTypeLabel, ColumnTypeLabelProps } from '../../src'; describe('ColumnOption', () => { const defaultProps = { - type: GenericDataType.STRING, + type: GenericDataType.String, }; const props = { ...defaultProps }; @@ -40,15 +40,15 @@ describe('ColumnOption', () => { ); }); it('string type shows ABC icon', () => { - renderColumnTypeLabel({ type: GenericDataType.STRING }); + renderColumnTypeLabel({ type: GenericDataType.String }); expect(screen.getByLabelText('string type icon')).toBeVisible(); }); it('int type shows # icon', () => { - renderColumnTypeLabel({ type: GenericDataType.NUMERIC }); + renderColumnTypeLabel({ type: GenericDataType.Numeric }); expect(screen.getByLabelText('numeric type icon')).toBeVisible(); }); it('bool type shows 1|0 icon', () => { - renderColumnTypeLabel({ type: GenericDataType.BOOLEAN }); + renderColumnTypeLabel({ type: GenericDataType.Boolean }); expect(screen.getByLabelText('boolean type icon')).toBeVisible(); }); it('expression type shows function icon', () => { @@ -60,7 +60,7 @@ describe('ColumnOption', () => { expect(screen.getByLabelText('unknown type icon')).toBeVisible(); }); it('datetime type displays', () => { - renderColumnTypeLabel({ type: GenericDataType.TEMPORAL }); + renderColumnTypeLabel({ type: GenericDataType.Temporal }); expect(screen.getByLabelText('temporal type icon')).toBeVisible(); }); }); diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/utils/checkColumnType.test.ts b/superset-frontend/packages/superset-ui-chart-controls/test/utils/checkColumnType.test.ts index 44ebbf605..71b95f154 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/utils/checkColumnType.test.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/test/utils/checkColumnType.test.ts @@ -21,25 +21,25 @@ import { checkColumnType, TestDataset } from '../../src'; test('checkColumnType columns from a Dataset', () => { expect( - checkColumnType('num', TestDataset, [GenericDataType.NUMERIC]), + checkColumnType('num', TestDataset, [GenericDataType.Numeric]), ).toEqual(true); - expect(checkColumnType('num', TestDataset, [GenericDataType.STRING])).toEqual( + expect(checkColumnType('num', TestDataset, [GenericDataType.String])).toEqual( false, ); expect( - checkColumnType('gender', TestDataset, [GenericDataType.STRING]), + checkColumnType('gender', TestDataset, [GenericDataType.String]), ).toEqual(true); expect( - checkColumnType('gender', TestDataset, [GenericDataType.NUMERIC]), + checkColumnType('gender', TestDataset, [GenericDataType.Numeric]), ).toEqual(false); }); test('checkColumnType from a QueryResponse', () => { expect( - checkColumnType('Column 1', testQueryResponse, [GenericDataType.STRING]), + checkColumnType('Column 1', testQueryResponse, [GenericDataType.String]), ).toEqual(true); expect( - checkColumnType('Column 1', testQueryResponse, [GenericDataType.NUMERIC]), + checkColumnType('Column 1', testQueryResponse, [GenericDataType.Numeric]), ).toEqual(false); }); diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/utils/columnChoices.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/utils/columnChoices.test.tsx index de5bb1ab6..2fac0e60e 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/utils/columnChoices.test.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/test/utils/columnChoices.test.tsx @@ -36,19 +36,19 @@ describe('columnChoices()', () => { { column_name: 'fiz', type: 'INT', - type_generic: GenericDataType.NUMERIC, + type_generic: GenericDataType.Numeric, }, { column_name: 'about', verbose_name: 'right', type: 'VARCHAR', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, }, { column_name: 'foo', verbose_name: undefined, type: 'TIMESTAMP', - type_generic: GenericDataType.TEMPORAL, + type_generic: GenericDataType.Temporal, }, ], verbose_map: {}, diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts b/superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts index 7daa3f968..6551e815d 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts @@ -18,7 +18,7 @@ */ import { configure } from '@superset-ui/core'; import { - COMPARATOR, + Comparator, getOpacity, round, getColorFormatters, @@ -60,7 +60,7 @@ describe('getColorFunction()', () => { it('getColorFunction GREATER_THAN', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.GREATER_THAN, + operator: Comparator.GreaterThan, targetValue: 50, colorScheme: '#FF0000', column: 'count', @@ -74,7 +74,7 @@ describe('getColorFunction()', () => { it('getColorFunction LESS_THAN', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.LESS_THAN, + operator: Comparator.LessThan, targetValue: 100, colorScheme: '#FF0000', column: 'count', @@ -88,7 +88,7 @@ describe('getColorFunction()', () => { it('getColorFunction GREATER_OR_EQUAL', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.GREATER_OR_EQUAL, + operator: Comparator.GreaterOrEqual, targetValue: 50, colorScheme: '#FF0000', column: 'count', @@ -103,7 +103,7 @@ describe('getColorFunction()', () => { it('getColorFunction LESS_OR_EQUAL', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.LESS_OR_EQUAL, + operator: Comparator.LessOrEqual, targetValue: 100, colorScheme: '#FF0000', column: 'count', @@ -118,7 +118,7 @@ describe('getColorFunction()', () => { it('getColorFunction EQUAL', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.EQUAL, + operator: Comparator.Equal, targetValue: 100, colorScheme: '#FF0000', column: 'count', @@ -132,7 +132,7 @@ describe('getColorFunction()', () => { it('getColorFunction NOT_EQUAL', () => { let colorFunction = getColorFunction( { - operator: COMPARATOR.NOT_EQUAL, + operator: Comparator.NotEqual, targetValue: 60, colorScheme: '#FF0000', column: 'count', @@ -145,7 +145,7 @@ describe('getColorFunction()', () => { colorFunction = getColorFunction( { - operator: COMPARATOR.NOT_EQUAL, + operator: Comparator.NotEqual, targetValue: 90, colorScheme: '#FF0000', column: 'count', @@ -160,7 +160,7 @@ describe('getColorFunction()', () => { it('getColorFunction BETWEEN', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.BETWEEN, + operator: Comparator.Between, targetValueLeft: 75, targetValueRight: 125, colorScheme: '#FF0000', @@ -175,7 +175,7 @@ describe('getColorFunction()', () => { it('getColorFunction BETWEEN_OR_EQUAL', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.BETWEEN_OR_EQUAL, + operator: Comparator.BetweenOrEqual, targetValueLeft: 50, targetValueRight: 100, colorScheme: '#FF0000', @@ -191,7 +191,7 @@ describe('getColorFunction()', () => { it('getColorFunction BETWEEN_OR_EQUAL without opacity', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.BETWEEN_OR_EQUAL, + operator: Comparator.BetweenOrEqual, targetValueLeft: 50, targetValueRight: 100, colorScheme: '#FF0000', @@ -210,7 +210,7 @@ describe('getColorFunction()', () => { it('getColorFunction BETWEEN_OR_LEFT_EQUAL', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.BETWEEN_OR_LEFT_EQUAL, + operator: Comparator.BetweenOrLeftEqual, targetValueLeft: 50, targetValueRight: 100, colorScheme: '#FF0000', @@ -225,7 +225,7 @@ describe('getColorFunction()', () => { it('getColorFunction BETWEEN_OR_RIGHT_EQUAL', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.BETWEEN_OR_RIGHT_EQUAL, + operator: Comparator.BetweenOrRightEqual, targetValueLeft: 50, targetValueRight: 100, colorScheme: '#FF0000', @@ -240,7 +240,7 @@ describe('getColorFunction()', () => { it('getColorFunction GREATER_THAN with target value undefined', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.GREATER_THAN, + operator: Comparator.GreaterThan, targetValue: undefined, colorScheme: '#FF0000', column: 'count', @@ -254,7 +254,7 @@ describe('getColorFunction()', () => { it('getColorFunction BETWEEN with target value left undefined', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.BETWEEN, + operator: Comparator.Between, targetValueLeft: undefined, targetValueRight: 100, colorScheme: '#FF0000', @@ -269,7 +269,7 @@ describe('getColorFunction()', () => { it('getColorFunction BETWEEN with target value right undefined', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.BETWEEN, + operator: Comparator.Between, targetValueLeft: 50, targetValueRight: undefined, colorScheme: '#FF0000', @@ -299,7 +299,7 @@ describe('getColorFunction()', () => { it('getColorFunction with operator None', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.NONE, + operator: Comparator.None, colorScheme: '#FF0000', column: 'count', }, @@ -329,7 +329,7 @@ describe('getColorFunction()', () => { it('getColorFunction with colorScheme undefined', () => { const colorFunction = getColorFunction( { - operator: COMPARATOR.GREATER_THAN, + operator: Comparator.GreaterThan, targetValue: 150, colorScheme: undefined, column: 'count', @@ -345,26 +345,26 @@ describe('getColorFormatters()', () => { it('correct column config', () => { const columnConfig = [ { - operator: COMPARATOR.GREATER_THAN, + operator: Comparator.GreaterThan, targetValue: 50, colorScheme: '#FF0000', column: 'count', }, { - operator: COMPARATOR.LESS_THAN, + operator: Comparator.LessThan, targetValue: 300, colorScheme: '#FF0000', column: 'sum', }, { - operator: COMPARATOR.BETWEEN, + operator: Comparator.Between, targetValueLeft: 75, targetValueRight: 125, colorScheme: '#FF0000', column: 'count', }, { - operator: COMPARATOR.GREATER_THAN, + operator: Comparator.GreaterThan, targetValue: 150, colorScheme: '#FF0000', column: undefined, diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/utils/getTemporalColumns.test.ts b/superset-frontend/packages/superset-ui-chart-controls/test/utils/getTemporalColumns.test.ts index f0a6529de..0379e0594 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/utils/getTemporalColumns.test.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/test/utils/getTemporalColumns.test.ts @@ -61,7 +61,7 @@ test('get temporal columns from a QueryResponse', () => { column_name: 'Column 2', is_dttm: true, type: 'TIMESTAMP', - type_generic: GenericDataType.TEMPORAL, + type_generic: GenericDataType.Temporal, }, ], defaultTemporalColumn: 'Column 2', diff --git a/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartBuildQueryRegistrySingleton.ts b/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartBuildQueryRegistrySingleton.ts index 1c5a5ca02..d94f2b37a 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartBuildQueryRegistrySingleton.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartBuildQueryRegistrySingleton.ts @@ -43,7 +43,7 @@ export type BuildQuery = ( class ChartBuildQueryRegistry extends Registry { constructor() { - super({ name: 'ChartBuildQuery', overwritePolicy: OverwritePolicy.WARN }); + super({ name: 'ChartBuildQuery', overwritePolicy: OverwritePolicy.Warn }); } } diff --git a/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartComponentRegistrySingleton.ts b/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartComponentRegistrySingleton.ts index ce7eba5b3..0375a19bd 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartComponentRegistrySingleton.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartComponentRegistrySingleton.ts @@ -22,7 +22,7 @@ import { ChartType } from '../models/ChartPlugin'; class ChartComponentRegistry extends Registry { constructor() { - super({ name: 'ChartComponent', overwritePolicy: OverwritePolicy.WARN }); + super({ name: 'ChartComponent', overwritePolicy: OverwritePolicy.Warn }); } } diff --git a/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartMetadataRegistrySingleton.ts b/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartMetadataRegistrySingleton.ts index bebcb5c5e..8c8766158 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartMetadataRegistrySingleton.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartMetadataRegistrySingleton.ts @@ -22,7 +22,7 @@ import ChartMetadata from '../models/ChartMetadata'; class ChartMetadataRegistry extends Registry { constructor() { - super({ name: 'ChartMetadata', overwritePolicy: OverwritePolicy.WARN }); + super({ name: 'ChartMetadata', overwritePolicy: OverwritePolicy.Warn }); } } diff --git a/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartTransformPropsRegistrySingleton.ts b/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartTransformPropsRegistrySingleton.ts index 15542ad9c..6bc11fc42 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartTransformPropsRegistrySingleton.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/registries/ChartTransformPropsRegistrySingleton.ts @@ -24,7 +24,7 @@ class ChartTransformPropsRegistry extends Registry> { constructor() { super({ name: 'ChartTransformProps', - overwritePolicy: OverwritePolicy.WARN, + overwritePolicy: OverwritePolicy.Warn, }); } } diff --git a/superset-frontend/packages/superset-ui-core/src/chart/types/Base.ts b/superset-frontend/packages/superset-ui-core/src/chart/types/Base.ts index b3884a848..b24e5e850 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/types/Base.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/types/Base.ts @@ -23,15 +23,15 @@ import { JsonObject } from '../..'; export type HandlerFunction = (...args: unknown[]) => void; export enum Behavior { - INTERACTIVE_CHART = 'INTERACTIVE_CHART', - NATIVE_FILTER = 'NATIVE_FILTER', + InteractiveChart = 'INTERACTIVE_CHART', + NativeFilter = 'NATIVE_FILTER', /** * Include `DRILL_TO_DETAIL` behavior if plugin handles `contextmenu` event * when dimensions are right-clicked on. */ - DRILL_TO_DETAIL = 'DRILL_TO_DETAIL', - DRILL_BY = 'DRILL_BY', + DrillToDetail = 'DRILL_TO_DETAIL', + DrillBy = 'DRILL_BY', } export interface ContextMenuFilters { @@ -48,11 +48,11 @@ export interface ContextMenuFilters { } export enum AppSection { - EXPLORE = 'EXPLORE', - DASHBOARD = 'DASHBOARD', - FILTER_BAR = 'FILTER_BAR', - FILTER_CONFIG_MODAL = 'FILTER_CONFIG_MODAL', - EMBEDDED = 'EMBEDDED', + Explore = 'EXPLORE', + Dashboard = 'DASHBOARD', + FilterBar = 'FILTER_BAR', + FilterConfigModal = 'FILTER_CONFIG_MODAL', + Embedded = 'EMBEDDED', } export type FilterState = { value?: any; [key: string]: any }; @@ -73,31 +73,31 @@ export interface PlainObject { } export enum ChartLabel { - DEPRECATED = 'DEPRECATED', - FEATURED = 'FEATURED', + Deprecated = 'DEPRECATED', + Featured = 'FEATURED', } export const chartLabelExplanations: Record = { - [ChartLabel.DEPRECATED]: + [ChartLabel.Deprecated]: 'This chart uses features or modules which are no longer actively maintained. It will eventually be replaced or removed.', - [ChartLabel.FEATURED]: + [ChartLabel.Featured]: 'This chart was tested and verified, so the overall experience should be stable.', }; export const chartLabelWeight: Record = { - [ChartLabel.DEPRECATED]: { + [ChartLabel.Deprecated]: { weight: -0.1, }, - [ChartLabel.FEATURED]: { + [ChartLabel.Featured]: { weight: 0.1, }, }; export enum AxisType { - category = 'category', - value = 'value', - time = 'time', - log = 'log', + Category = 'category', + Value = 'value', + Time = 'time', + Log = 'log', } export interface LegendState { diff --git a/superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts b/superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts index 5004dce2d..8b8cd0251 100644 --- a/superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts +++ b/superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts @@ -106,7 +106,7 @@ class CategoricalColorScale extends ExtensibleFunction { this.forcedColors?.[cleanedValue] || sharedColor; - if (isFeatureEnabled(FeatureFlag.USE_ANALAGOUS_COLORS)) { + if (isFeatureEnabled(FeatureFlag.UseAnalagousColors)) { const multiple = Math.floor( this.domain().length / this.originColors.length, ); @@ -119,7 +119,7 @@ class CategoricalColorScale extends ExtensibleFunction { const newColor = this.scale(cleanedValue); if (!color) { color = newColor; - if (isFeatureEnabled(FeatureFlag.AVOID_COLORS_COLLISION)) { + if (isFeatureEnabled(FeatureFlag.AvoidColorsCollision)) { this.removeSharedLabelColorFromRange(sharedColorMap, cleanedValue); color = this.scale(cleanedValue); } diff --git a/superset-frontend/packages/superset-ui-core/src/color/ColorSchemeRegistry.ts b/superset-frontend/packages/superset-ui-core/src/color/ColorSchemeRegistry.ts index e270ff6f0..2601be82e 100644 --- a/superset-frontend/packages/superset-ui-core/src/color/ColorSchemeRegistry.ts +++ b/superset-frontend/packages/superset-ui-core/src/color/ColorSchemeRegistry.ts @@ -23,7 +23,7 @@ export default class ColorSchemeRegistry extends RegistryWithDefaultKey { constructor() { super({ name: 'ColorScheme', - overwritePolicy: OverwritePolicy.WARN, + overwritePolicy: OverwritePolicy.Warn, setFirstItemAsDefault: true, }); } diff --git a/superset-frontend/packages/superset-ui-core/src/color/SharedLabelColorSingleton.ts b/superset-frontend/packages/superset-ui-core/src/color/SharedLabelColorSingleton.ts index bc417e603..4837d0f36 100644 --- a/superset-frontend/packages/superset-ui-core/src/color/SharedLabelColorSingleton.ts +++ b/superset-frontend/packages/superset-ui-core/src/color/SharedLabelColorSingleton.ts @@ -21,8 +21,8 @@ import { CategoricalColorNamespace } from '.'; import { makeSingleton } from '../utils'; export enum SharedLabelColorSource { - dashboard, - explore, + Dashboard, + Explore, } export class SharedLabelColor { sliceLabelMap: Map; @@ -35,7 +35,7 @@ export class SharedLabelColor { // { sliceId1: [label1, label2, ...], sliceId2: [label1, label2, ...] } this.sliceLabelMap = new Map(); this.colorMap = new Map(); - this.source = SharedLabelColorSource.dashboard; + this.source = SharedLabelColorSource.Dashboard; } updateColorMap(colorNamespace?: string, colorScheme?: string) { @@ -59,7 +59,7 @@ export class SharedLabelColor { addSlice(label: string, color: string, sliceId?: number) { if ( - this.source !== SharedLabelColorSource.dashboard || + this.source !== SharedLabelColorSource.Dashboard || sliceId === undefined ) return; @@ -72,7 +72,7 @@ export class SharedLabelColor { } removeSlice(sliceId: number) { - if (this.source !== SharedLabelColorSource.dashboard) return; + if (this.source !== SharedLabelColorSource.Dashboard) return; this.sliceLabelMap.delete(sliceId); const newColorMap = new Map(); this.sliceLabelMap.forEach(labels => { diff --git a/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx b/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx index 2b36802d4..e7fbe9ee5 100644 --- a/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx @@ -44,7 +44,7 @@ function SafeMarkdown({ htmlSanitization = true, htmlSchemaOverrides = {}, }: SafeMarkdownProps) { - const escapeHtml = isFeatureEnabled(FeatureFlag.ESCAPE_MARKDOWN_HTML); + const escapeHtml = isFeatureEnabled(FeatureFlag.EscapeMarkdownHtml); const rehypePlugins = useMemo(() => { const rehypePlugins: any = []; diff --git a/superset-frontend/packages/superset-ui-core/src/models/Registry.ts b/superset-frontend/packages/superset-ui-core/src/models/Registry.ts index e876bc2b5..53aff08c4 100644 --- a/superset-frontend/packages/superset-ui-core/src/models/Registry.ts +++ b/superset-frontend/packages/superset-ui-core/src/models/Registry.ts @@ -17,9 +17,9 @@ * under the License. */ export enum OverwritePolicy { - ALLOW = 'ALLOW', - PROHIBIT = 'PROHIBIT', - WARN = 'WARN', + Allow = 'ALLOW', + Prohibit = 'PROHIBIT', + Warn = 'WARN', } interface ItemWithValue { @@ -89,7 +89,7 @@ export default class Registry< listeners: Set; constructor(config: RegistryConfig = {}) { - const { name = '', overwritePolicy = OverwritePolicy.ALLOW } = config; + const { name = '', overwritePolicy = OverwritePolicy.Allow } = config; this.name = name; this.overwritePolicy = overwritePolicy; this.items = {}; @@ -119,12 +119,12 @@ export default class Registry< this.has(key) && (('value' in item && item.value !== value) || 'loader' in item); if (willOverwrite) { - if (this.overwritePolicy === OverwritePolicy.WARN) { + if (this.overwritePolicy === OverwritePolicy.Warn) { // eslint-disable-next-line no-console console.warn( `Item with key "${key}" already exists. You are assigning a new value.`, ); - } else if (this.overwritePolicy === OverwritePolicy.PROHIBIT) { + } else if (this.overwritePolicy === OverwritePolicy.Prohibit) { throw new Error( `Item with key "${key}" already exists. Cannot overwrite.`, ); @@ -145,12 +145,12 @@ export default class Registry< this.has(key) && (('loader' in item && item.loader !== loader) || 'value' in item); if (willOverwrite) { - if (this.overwritePolicy === OverwritePolicy.WARN) { + if (this.overwritePolicy === OverwritePolicy.Warn) { // eslint-disable-next-line no-console console.warn( `Item with key "${key}" already exists. You are assigning a new value.`, ); - } else if (this.overwritePolicy === OverwritePolicy.PROHIBIT) { + } else if (this.overwritePolicy === OverwritePolicy.Prohibit) { throw new Error( `Item with key "${key}" already exists. Cannot overwrite.`, ); diff --git a/superset-frontend/packages/superset-ui-core/src/number-format/NumberFormatterRegistry.ts b/superset-frontend/packages/superset-ui-core/src/number-format/NumberFormatterRegistry.ts index e64796ad3..db3ab11ce 100644 --- a/superset-frontend/packages/superset-ui-core/src/number-format/NumberFormatterRegistry.ts +++ b/superset-frontend/packages/superset-ui-core/src/number-format/NumberFormatterRegistry.ts @@ -33,7 +33,7 @@ export default class NumberFormatterRegistry extends RegistryWithDefaultKey< constructor() { super({ name: 'NumberFormatter', - overwritePolicy: OverwritePolicy.WARN, + overwritePolicy: OverwritePolicy.Warn, }); this.registerValue( diff --git a/superset-frontend/packages/superset-ui-core/src/query/api/v1/types.ts b/superset-frontend/packages/superset-ui-core/src/query/api/v1/types.ts index 09ef1bc7d..37cc002c4 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/api/v1/types.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/api/v1/types.ts @@ -47,25 +47,25 @@ export interface SupersetApiRequestOptions { */ export enum SupersetApiErrorType { // Generic unknown error - UNKNOWN_ERROR = 'UNKNOWN_ERROR', + UnknownError = 'UNKNOWN_ERROR', // Frontend errors - FRONTEND_CSRF_ERROR = 'FRONTEND_CSRF_ERROR', - FRONTEND_NETWORK_ERROR = 'FRONTEND_NETWORK_ERROR', - FRONTEND_TIMEOUT_ERROR = 'FRONTEND_TIMEOUT_ERROR', + FrontendCsrfError = 'FRONTEND_CSRF_ERROR', + FrontendNetworkError = 'FRONTEND_NETWORK_ERROR', + FrontendTimeoutError = 'FRONTEND_TIMEOUT_ERROR', // DB Engine errors, - GENERIC_DB_ENGINE_ERROR = 'GENERIC_DB_ENGINE_ERROR', + GenericDbEngineError = 'GENERIC_DB_ENGINE_ERROR', // Viz errors, - VIZ_GET_DF_ERROR = 'VIZ_GET_DF_ERROR', - UNKNOWN_DATASOURCE_TYPE_ERROR = 'UNKNOWN_DATASOURCE_TYPE_ERROR', - FAILED_FETCHING_DATASOURCE_INFO_ERROR = 'FAILED_FETCHING_DATASOURCE_INFO_ERROR', + VizGetDfError = 'VIZ_GET_DF_ERROR', + UnknownDatasourceTypeError = 'UNKNOWN_DATASOURCE_TYPE_ERROR', + FailedFetchingDatasourceInfoError = 'FAILED_FETCHING_DATASOURCE_INFO_ERROR', // Security access errors, - TABLE_SECURITY_ACCESS_ERROR = 'TABLE_SECURITY_ACCESS_ERROR', - DATASOURCE_SECURITY_ACCESS_ERROR = 'DATASOURCE_SECURITY_ACCESS_ERROR', - MISSING_OWNERSHIP_ERROR = 'MISSING_OWNERSHIP_ERROR', + TableSecurityAccessError = 'TABLE_SECURITY_ACCESS_ERROR', + DatasourceSecurityAccessError = 'DATASOURCE_SECURITY_ACCESS_ERROR', + MissingOwnershipError = 'MISSING_OWNERSHIP_ERROR', } /** @@ -129,7 +129,7 @@ export class SupersetApiError extends Error { ].join('\n') : this.stack; this.name = 'SupersetApiError'; - this.errorType = errorType || SupersetApiErrorType.UNKNOWN_ERROR; + this.errorType = errorType || SupersetApiErrorType.UnknownError; this.extra = extra || {}; if (link) { this.extra.link = link; diff --git a/superset-frontend/packages/superset-ui-core/src/query/extractQueryFields.ts b/superset-frontend/packages/superset-ui-core/src/query/extractQueryFields.ts index bbd173e61..6cb0af8ee 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/extractQueryFields.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/extractQueryFields.ts @@ -73,13 +73,13 @@ export default function extractQueryFields( // For charts that support both aggregate and raw records mode, // we store both `groupby` and `columns` in `formData`, so users can // switch between modes while retaining the selected options for each. - if (queryMode === QueryMode.aggregate && normalizedKey === 'columns') { + if (queryMode === QueryMode.Aggregate && normalizedKey === 'columns') { return; } // for the same reason, ignore groupby and metrics in raw records mode if ( - queryMode === QueryMode.raw && + queryMode === QueryMode.Raw && (normalizedKey === 'groupby' || normalizedKey === 'metrics') ) { return; @@ -106,7 +106,7 @@ export default function extractQueryFields( getColumnLabel, ), metrics: - queryMode === QueryMode.raw + queryMode === QueryMode.Raw ? undefined : removeDuplicates(metrics, getMetricLabel), orderby: diff --git a/superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts b/superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts index 40939a1f5..cb299c3ac 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts @@ -40,8 +40,8 @@ export interface NativeFilterTarget { } export enum NativeFilterType { - NATIVE_FILTER = 'NATIVE_FILTER', - DIVIDER = 'DIVIDER', + NativeFilter = 'NATIVE_FILTER', + Divider = 'DIVIDER', } export enum DataMaskType { @@ -76,7 +76,7 @@ export type Filter = { requiredFirst?: boolean; tabsInScope?: string[]; chartsInScope?: number[]; - type: typeof NativeFilterType.NATIVE_FILTER; + type: typeof NativeFilterType.NativeFilter; description: string; }; @@ -86,13 +86,13 @@ export type Divider = Partial> & { id: string; title: string; description: string; - type: typeof NativeFilterType.DIVIDER; + type: typeof NativeFilterType.Divider; }; export function isNativeFilter( filterElement: Filter | Divider, ): filterElement is Filter { - return filterElement.type === NativeFilterType.NATIVE_FILTER; + return filterElement.type === NativeFilterType.NativeFilter; } export function isNativeFilterWithDataMask( @@ -107,7 +107,7 @@ export function isNativeFilterWithDataMask( export function isFilterDivider( filterElement: Filter | Divider, ): filterElement is Divider { - return filterElement.type === NativeFilterType.DIVIDER; + return filterElement.type === NativeFilterType.Divider; } export type FilterConfiguration = Array; diff --git a/superset-frontend/packages/superset-ui-core/src/query/types/Query.ts b/superset-frontend/packages/superset-ui-core/src/query/types/Query.ts index 1271be2ff..488caaa60 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/types/Query.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/types/Query.ts @@ -257,32 +257,32 @@ export type QueryColumn = { // Possible states of a query object for processing on the server export enum QueryState { - STARTED = 'started', - STOPPED = 'stopped', - FAILED = 'failed', - PENDING = 'pending', - RUNNING = 'running', - SCHEDULED = 'scheduled', - SUCCESS = 'success', - FETCHING = 'fetching', - TIMED_OUT = 'timed_out', + Started = 'started', + Stopped = 'stopped', + Failed = 'failed', + Pending = 'pending', + Running = 'running', + Scheduled = 'scheduled', + Success = 'success', + Fetching = 'fetching', + TimedOut = 'timed_out', } // Inidcates a Query's state is still processing export const runningQueryStateList: QueryState[] = [ - QueryState.RUNNING, - QueryState.STARTED, - QueryState.PENDING, - QueryState.FETCHING, - QueryState.SCHEDULED, + QueryState.Running, + QueryState.Started, + QueryState.Pending, + QueryState.Fetching, + QueryState.Scheduled, ]; // Indicates a Query's state has completed processing regardless of success / failure export const concludedQueryStateList: QueryState[] = [ - QueryState.STOPPED, - QueryState.FAILED, - QueryState.SUCCESS, - QueryState.TIMED_OUT, + QueryState.Stopped, + QueryState.Failed, + QueryState.Success, + QueryState.TimedOut, ]; export type Query = { @@ -359,7 +359,7 @@ export const testQuery: Query = { isDataPreview: false, progress: 0, resultsKey: null, - state: QueryState.SUCCESS, + state: QueryState.Success, tempSchema: null, trackingUrl: null, templateParams: null, @@ -385,19 +385,19 @@ export const testQuery: Query = { column_name: 'Column 1', type: 'STRING', is_dttm: false, - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, }, { column_name: 'Column 3', type: 'STRING', is_dttm: false, - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, }, { column_name: 'Column 2', type: 'TIMESTAMP', is_dttm: true, - type_generic: GenericDataType.TEMPORAL, + type_generic: GenericDataType.Temporal, }, ], }; @@ -409,19 +409,19 @@ export const testQueryResults = { { column_name: 'Column 1', type: 'STRING', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, is_dttm: false, }, { column_name: 'Column 3', type: 'STRING', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, is_dttm: false, }, { column_name: 'Column 2', type: 'TIMESTAMP', - type_generic: GenericDataType.TEMPORAL, + type_generic: GenericDataType.Temporal, is_dttm: true, }, ], @@ -433,19 +433,19 @@ export const testQueryResults = { { column_name: 'Column 1', type: 'STRING', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, is_dttm: false, }, { column_name: 'Column 3', type: 'STRING', - type_generic: GenericDataType.STRING, + type_generic: GenericDataType.String, is_dttm: false, }, { column_name: 'Column 2', type: 'TIMESTAMP', - type_generic: GenericDataType.TEMPORAL, + type_generic: GenericDataType.Temporal, is_dttm: true, }, ], diff --git a/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts b/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts index 1806f567e..ea2f0d082 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts @@ -59,8 +59,8 @@ export interface FormDataResidual { } export enum QueryMode { - aggregate = 'aggregate', - raw = 'raw', + Aggregate = 'aggregate', + Raw = 'raw', } /** diff --git a/superset-frontend/packages/superset-ui-core/src/query/types/QueryResponse.ts b/superset-frontend/packages/superset-ui-core/src/query/types/QueryResponse.ts index e4869805f..1705814df 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/types/QueryResponse.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/types/QueryResponse.ts @@ -24,10 +24,10 @@ import { AnnotationData } from './AnnotationLayer'; * Generic data types, see enum of the same name in superset/utils/core.py. */ export enum GenericDataType { - NUMERIC = 0, - STRING = 1, - TEMPORAL = 2, - BOOLEAN = 3, + Numeric = 0, + String = 1, + Temporal = 2, + Boolean = 3, } /** diff --git a/superset-frontend/packages/superset-ui-core/src/time-format/TimeFormatterRegistry.ts b/superset-frontend/packages/superset-ui-core/src/time-format/TimeFormatterRegistry.ts index 1df169630..e99517e8d 100644 --- a/superset-frontend/packages/superset-ui-core/src/time-format/TimeFormatterRegistry.ts +++ b/superset-frontend/packages/superset-ui-core/src/time-format/TimeFormatterRegistry.ts @@ -29,7 +29,7 @@ export default class TimeFormatterRegistry extends RegistryWithDefaultKey< super({ initialDefaultKey: TimeFormats.DATABASE_DATETIME, name: 'TimeFormatter', - overwritePolicy: OverwritePolicy.WARN, + overwritePolicy: OverwritePolicy.Warn, }); } 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 f21d20650..d913a0ad1 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts @@ -22,41 +22,42 @@ import logger from './logging'; // check into source control. We're hardcoding the supported flags for now. export enum FeatureFlag { // PLEASE KEEP THE LIST SORTED ALPHABETICALLY - ALERTS_ATTACH_REPORTS = 'ALERTS_ATTACH_REPORTS', - ALERT_REPORTS = 'ALERT_REPORTS', - ALLOW_FULL_CSV_EXPORT = 'ALLOW_FULL_CSV_EXPORT', - AVOID_COLORS_COLLISION = 'AVOID_COLORS_COLLISION', - CHART_PLUGINS_EXPERIMENTAL = 'CHART_PLUGINS_EXPERIMENTAL', - CONFIRM_DASHBOARD_DIFF = 'CONFIRM_DASHBOARD_DIFF', + AlertsAttachReports = 'ALERTS_ATTACH_REPORTS', + AlertReports = 'ALERT_REPORTS', + AllowFullCsvExport = 'ALLOW_FULL_CSV_EXPORT', + AvoidColorsCollision = 'AVOID_COLORS_COLLISION', + ChartPluginsExperimental = 'ChartPluginsExperimental', + ConfirmDashboardDiff = 'CONFIRM_DASHBOARD_DIFF', /** @deprecated */ - DASHBOARD_CROSS_FILTERS = 'DASHBOARD_CROSS_FILTERS', - DASHBOARD_VIRTUALIZATION = 'DASHBOARD_VIRTUALIZATION', - DASHBOARD_RBAC = 'DASHBOARD_RBAC', - DATAPANEL_CLOSED_BY_DEFAULT = 'DATAPANEL_CLOSED_BY_DEFAULT', - DISABLE_LEGACY_DATASOURCE_EDITOR = 'DISABLE_LEGACY_DATASOURCE_EDITOR', - DRILL_TO_DETAIL = 'DRILL_TO_DETAIL', - DRILL_BY = 'DRILL_BY', - DYNAMIC_PLUGINS = 'DYNAMIC_PLUGINS', - EMBEDDABLE_CHARTS = 'EMBEDDABLE_CHARTS', - EMBEDDED_SUPERSET = 'EMBEDDED_SUPERSET', - ENABLE_ADVANCED_DATA_TYPES = 'ENABLE_ADVANCED_DATA_TYPES', + DashboardCrossFilters = 'DASHBOARD_CROSS_FILTERS', + DashboardVirtualization = 'DASHBOARD_VIRTUALIZATION', + DashboardRbac = 'DASHBOARD_RBAC', + DatapanelClosedByDefault = 'DATAPANEL_CLOSED_BY_DEFAULT', + DisableLegacyDatasourceEditor = 'DISABLE_LEGACY_DATASOURCE_EDITOR', + DrillToDetail = 'DRILL_TO_DETAIL', + DrillBy = 'DRILL_BY', + DynamicPlugins = 'DYNAMIC_PLUGINS', + EmbeddableCharts = 'EMBEDDABLE_CHARTS', + EmbeddedSuperset = 'EMBEDDED_SUPERSET', + EnableAdvancedDataTypes = 'ENABLE_ADVANCED_DATA_TYPES', /** @deprecated */ - ENABLE_JAVASCRIPT_CONTROLS = 'ENABLE_JAVASCRIPT_CONTROLS', - ENABLE_TEMPLATE_PROCESSING = 'ENABLE_TEMPLATE_PROCESSING', - ESCAPE_MARKDOWN_HTML = 'ESCAPE_MARKDOWN_HTML', - ESTIMATE_QUERY_COST = 'ESTIMATE_QUERY_COST', - GLOBAL_ASYNC_QUERIES = 'GLOBAL_ASYNC_QUERIES', - HORIZONTAL_FILTER_BAR = 'HORIZONTAL_FILTER_BAR', - LISTVIEWS_DEFAULT_CARD_VIEW = 'LISTVIEWS_DEFAULT_CARD_VIEW', - SCHEDULED_QUERIES = 'SCHEDULED_QUERIES', - SHARE_QUERIES_VIA_KV_STORE = 'SHARE_QUERIES_VIA_KV_STORE', - SQLLAB_BACKEND_PERSISTENCE = 'SQLLAB_BACKEND_PERSISTENCE', - SQL_VALIDATORS_BY_ENGINE = 'SQL_VALIDATORS_BY_ENGINE', - SSH_TUNNELING = 'SSH_TUNNELING', - TAGGING_SYSTEM = 'TAGGING_SYSTEM', - THUMBNAILS = 'THUMBNAILS', - USE_ANALAGOUS_COLORS = 'USE_ANALAGOUS_COLORS', + EnableJavascriptControls = 'ENABLE_JAVASCRIPT_CONTROLS', + EnableTemplateProcessing = 'ENABLE_TEMPLATE_PROCESSING', + EscapeMarkdownHtml = 'ESCAPE_MARKDOWN_HTML', + EstimateQueryCost = 'ESTIMATE_QUERY_COST', + GlobalAsyncQueries = 'GLOBAL_ASYNC_QUERIES', + HorizontalFilterBar = 'HORIZONTAL_FILTER_BAR', + ListviewsDefaultCardView = 'LISTVIEWS_DEFAULT_CARD_VIEW', + ScheduledQueries = 'SCHEDULED_QUERIES', + ShareQueriesViaKvStore = 'SHARE_QUERIES_VIA_KV_STORE', + SqllabBackendPersistence = 'SQLLAB_BACKEND_PERSISTENCE', + SqlValidatorsByEngine = 'SQL_VALIDATORS_BY_ENGINE', + SshTunneling = 'SSH_TUNNELING', + TaggingSystem = 'TAGGING_SYSTEM', + Thumbnails = 'THUMBNAILS', + UseAnalagousColors = 'USE_ANALAGOUS_COLORS', } + export type ScheduleQueriesProps = { JSONSCHEMA: { [key: string]: string; @@ -69,9 +70,9 @@ export type ScheduleQueriesProps = { }; }; export type FeatureFlagMap = { - [key in Exclude]?: boolean; + [key in Exclude]?: boolean; } & { - SCHEDULED_QUERIES?: ScheduleQueriesProps; + ScheduledQueries?: ScheduleQueriesProps; }; // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/superset-frontend/packages/superset-ui-core/test/chart/models/ChartProps.test.ts b/superset-frontend/packages/superset-ui-core/test/chart/models/ChartProps.test.ts index ca7bcf94b..f9bd7d76a 100644 --- a/superset-frontend/packages/superset-ui-core/test/chart/models/ChartProps.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/chart/models/ChartProps.test.ts @@ -29,7 +29,7 @@ const RAW_DATASOURCE = { const QUERY_DATA = { data: {} }; const QUERIES_DATA = [QUERY_DATA]; -const BEHAVIORS = [Behavior.NATIVE_FILTER, Behavior.INTERACTIVE_CHART]; +const BEHAVIORS = [Behavior.NativeFilter, Behavior.InteractiveChart]; describe('ChartProps', () => { it('exists', () => { diff --git a/superset-frontend/packages/superset-ui-core/test/color/CategoricalColorScale.test.ts b/superset-frontend/packages/superset-ui-core/test/color/CategoricalColorScale.test.ts index 0d98198de..48e43d835 100644 --- a/superset-frontend/packages/superset-ui-core/test/color/CategoricalColorScale.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/color/CategoricalColorScale.test.ts @@ -83,7 +83,7 @@ describe('CategoricalColorScale', () => { }); it('recycles colors when number of items exceed available colors', () => { window.featureFlags = { - [FeatureFlag.USE_ANALAGOUS_COLORS]: false, + [FeatureFlag.UseAnalagousColors]: false, }; const colorSet: { [key: string]: number } = {}; const scale = new CategoricalColorScale(['blue', 'red', 'green']); @@ -109,7 +109,7 @@ describe('CategoricalColorScale', () => { }); it('get analogous colors when number of items exceed available colors', () => { window.featureFlags = { - [FeatureFlag.USE_ANALAGOUS_COLORS]: true, + [FeatureFlag.UseAnalagousColors]: true, }; const scale = new CategoricalColorScale(['blue', 'red', 'green']); scale.getColor('pig'); @@ -123,7 +123,7 @@ describe('CategoricalColorScale', () => { it('should remove shared color from range if avoid colors collision enabled', () => { window.featureFlags = { - [FeatureFlag.AVOID_COLORS_COLLISION]: true, + [FeatureFlag.AvoidColorsCollision]: true, }; const scale = new CategoricalColorScale(['blue', 'red', 'green']); const color1 = scale.getColor('a', 1); @@ -136,7 +136,7 @@ describe('CategoricalColorScale', () => { expect(scale.range()).toHaveLength(1); }); window.featureFlags = { - [FeatureFlag.AVOID_COLORS_COLLISION]: false, + [FeatureFlag.AvoidColorsCollision]: false, }; }); describe('.setColor(value, forcedColor)', () => { diff --git a/superset-frontend/packages/superset-ui-core/test/color/SharedLabelColorSingleton.test.ts b/superset-frontend/packages/superset-ui-core/test/color/SharedLabelColorSingleton.test.ts index 88610874d..8f89ae8a6 100644 --- a/superset-frontend/packages/superset-ui-core/test/color/SharedLabelColorSingleton.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/color/SharedLabelColorSingleton.test.ts @@ -53,7 +53,7 @@ describe('SharedLabelColor', () => { }); beforeEach(() => { - getSharedLabelColor().source = SharedLabelColorSource.dashboard; + getSharedLabelColor().source = SharedLabelColorSource.Dashboard; getSharedLabelColor().clear(); }); @@ -95,7 +95,7 @@ describe('SharedLabelColor', () => { it('should do nothing when source is not dashboard', () => { const sharedLabelColor = getSharedLabelColor(); - sharedLabelColor.source = SharedLabelColorSource.explore; + sharedLabelColor.source = SharedLabelColorSource.Explore; sharedLabelColor.addSlice('a', 'red'); expect(Object.fromEntries(sharedLabelColor.sliceLabelMap)).toEqual({}); }); @@ -127,7 +127,7 @@ describe('SharedLabelColor', () => { it('should do nothing when source is not dashboard', () => { const sharedLabelColor = getSharedLabelColor(); sharedLabelColor.addSlice('a', 'red', 1); - sharedLabelColor.source = SharedLabelColorSource.explore; + sharedLabelColor.source = SharedLabelColorSource.Explore; sharedLabelColor.removeSlice(1); expect(sharedLabelColor.sliceLabelMap.has(1)).toEqual(true); }); @@ -151,7 +151,7 @@ describe('SharedLabelColor', () => { it('should use recycle colors', () => { window.featureFlags = { - [FeatureFlag.USE_ANALAGOUS_COLORS]: false, + [FeatureFlag.UseAnalagousColors]: false, }; const sharedLabelColor = getSharedLabelColor(); sharedLabelColor.addSlice('a', 'red', 1); @@ -166,7 +166,7 @@ describe('SharedLabelColor', () => { it('should use analagous colors', () => { window.featureFlags = { - [FeatureFlag.USE_ANALAGOUS_COLORS]: true, + [FeatureFlag.UseAnalagousColors]: true, }; const sharedLabelColor = getSharedLabelColor(); sharedLabelColor.addSlice('a', 'red', 1); diff --git a/superset-frontend/packages/superset-ui-core/test/fixtures.ts b/superset-frontend/packages/superset-ui-core/test/fixtures.ts index c4d3cc6d1..c2c791531 100644 --- a/superset-frontend/packages/superset-ui-core/test/fixtures.ts +++ b/superset-frontend/packages/superset-ui-core/test/fixtures.ts @@ -24,7 +24,7 @@ export const NUM_METRIC: AdhocMetric = { column: { id: 336, type: 'BIGINT', - type_generic: GenericDataType.NUMERIC, + type_generic: GenericDataType.Numeric, column_name: 'num', verbose_name: null, description: null, diff --git a/superset-frontend/packages/superset-ui-core/test/models/Registry.test.ts b/superset-frontend/packages/superset-ui-core/test/models/Registry.test.ts index 11c2e65eb..6f2067eec 100644 --- a/superset-frontend/packages/superset-ui-core/test/models/Registry.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/models/Registry.test.ts @@ -336,7 +336,7 @@ describe('Registry', () => { it('warns when overwrite', () => { const restoreConsole = mockConsole(); const registry = new Registry({ - overwritePolicy: OverwritePolicy.WARN, + overwritePolicy: OverwritePolicy.Warn, }); registry.registerValue('a', 'testValue'); expect(() => registry.registerValue('a', 'testValue2')).not.toThrow(); @@ -349,7 +349,7 @@ describe('Registry', () => { it('warns when overwrite', () => { const restoreConsole = mockConsole(); const registry = new Registry({ - overwritePolicy: OverwritePolicy.WARN, + overwritePolicy: OverwritePolicy.Warn, }); registry.registerLoader('a', () => 'testValue'); expect(() => @@ -365,7 +365,7 @@ describe('Registry', () => { describe('.registerValue(key, value)', () => { it('throws error when overwrite', () => { const registry = new Registry({ - overwritePolicy: OverwritePolicy.PROHIBIT, + overwritePolicy: OverwritePolicy.Prohibit, }); registry.registerValue('a', 'testValue'); expect(() => registry.registerValue('a', 'testValue2')).toThrow(); @@ -374,7 +374,7 @@ describe('Registry', () => { describe('.registerLoader(key, loader)', () => { it('warns when overwrite', () => { const registry = new Registry({ - overwritePolicy: OverwritePolicy.PROHIBIT, + overwritePolicy: OverwritePolicy.Prohibit, }); registry.registerLoader('a', () => 'testValue'); expect(() => diff --git a/superset-frontend/packages/superset-ui-core/test/query/api/v1/handleError.test.ts b/superset-frontend/packages/superset-ui-core/test/query/api/v1/handleError.test.ts index eec7a47b9..72b1a0f41 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/api/v1/handleError.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/api/v1/handleError.test.ts @@ -105,7 +105,7 @@ describe('handleError()', () => { const mockError = { error: { message: 'Request timeout', - error_type: SupersetApiErrorType.FRONTEND_TIMEOUT_ERROR, + error_type: SupersetApiErrorType.FrontendTimeoutError, }, }; await testHandleError(mockError, { diff --git a/superset-frontend/packages/superset-ui-core/test/query/extractQueryFields.test.ts b/superset-frontend/packages/superset-ui-core/test/query/extractQueryFields.test.ts index 56004a06e..4e2901371 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/extractQueryFields.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/extractQueryFields.test.ts @@ -124,7 +124,7 @@ describe('extractQueryFields', () => { columns: ['a'], groupby: ['b'], metric: ['m'], - query_mode: QueryMode.raw, + query_mode: QueryMode.Raw, }), ).toEqual({ columns: ['a'], @@ -139,7 +139,7 @@ describe('extractQueryFields', () => { columns: ['a'], groupby: [], metric: ['m'], - query_mode: QueryMode.aggregate, + query_mode: QueryMode.Aggregate, }), ).toEqual({ metrics: ['m'], @@ -151,7 +151,7 @@ describe('extractQueryFields', () => { columns: ['a'], groupby: ['b'], metric: ['m'], - query_mode: QueryMode.aggregate, + query_mode: QueryMode.Aggregate, }), ).toEqual({ metrics: ['m'], diff --git a/superset-frontend/packages/superset-ui-core/test/query/types/Dashboard.test.ts b/superset-frontend/packages/superset-ui-core/test/query/types/Dashboard.test.ts index f72bff490..79d798094 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/types/Dashboard.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/types/Dashboard.test.ts @@ -35,7 +35,7 @@ const filter: Filter = { filterType: 'filter_type', targets: [{}], controlValues: {}, - type: NativeFilterType.NATIVE_FILTER, + type: NativeFilterType.NativeFilter, description: 'Filter description.', }; @@ -46,7 +46,7 @@ const filterWithDataMask: FilterWithDataMask = { const filterDivider: Divider = { id: 'divider_id', - type: NativeFilterType.DIVIDER, + type: NativeFilterType.Divider, title: 'Divider title', description: 'Divider description.', }; diff --git a/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts b/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts index bad77690a..12a644c06 100644 --- a/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts @@ -51,7 +51,7 @@ it('returns false and raises console error if feature flags have not been initia Object.defineProperty(window, 'featureFlags', { value: undefined, }); - expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DRILL_BY)).toEqual(false); + expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DrillBy)).toEqual(false); expect(uiCore.logging.error).toHaveBeenCalled(); expect(logging).toHaveBeenCalledWith('Failed to query feature flag DRILL_BY'); }); @@ -60,7 +60,7 @@ it('returns false for unset feature flag', () => { Object.defineProperty(window, 'featureFlags', { value: {}, }); - expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DRILL_BY)).toEqual(false); + expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DrillBy)).toEqual(false); }); it('returns true for set feature flag', () => { @@ -69,5 +69,5 @@ it('returns true for set feature flag', () => { DRILL_BY: true, }, }); - expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DRILL_BY)).toEqual(true); + expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DrillBy)).toEqual(true); }); diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts index fd5245f69..0ae466efd 100644 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts @@ -45,10 +45,10 @@ export const basicFormData: TableChartFormData = { export const basicData: Partial = { colnames: ['name', 'sum__num', 'MAX(ds)', 'Abc.com'], coltypes: [ - GenericDataType.STRING, - GenericDataType.NUMERIC, - GenericDataType.TEMPORAL, - GenericDataType.STRING, + GenericDataType.String, + GenericDataType.Numeric, + GenericDataType.Temporal, + GenericDataType.String, ], data: [ { diff --git a/superset-frontend/plugins/legacy-plugin-chart-heatmap/src/transformProps.js b/superset-frontend/plugins/legacy-plugin-chart-heatmap/src/transformProps.js index fa531ef9d..0ec12b6c4 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-heatmap/src/transformProps.js +++ b/superset-frontend/plugins/legacy-plugin-chart-heatmap/src/transformProps.js @@ -55,11 +55,11 @@ export default function transformProps(chartProps) { currencyFormat, ); const xAxisFormatter = - coltypes[0] === GenericDataType.TEMPORAL + coltypes[0] === GenericDataType.Temporal ? getTimeFormatter(timeFormat) : String; const yAxisFormatter = - coltypes[1] === GenericDataType.TEMPORAL + coltypes[1] === GenericDataType.Temporal ? getTimeFormatter(timeFormat) : String; return { diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js index 540097be2..6b69c6b2d 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js @@ -86,7 +86,7 @@ function WorldMap(element, props) { let processedData; let colorScale; - if (colorBy === ColorBy.country) { + if (colorBy === ColorBy.Country) { colorScale = CategoricalColorNamespace.getScale(colorScheme); processedData = filteredData.map(d => ({ diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts index 2ca11373f..82d8dcb1e 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts @@ -112,10 +112,10 @@ const config: ControlPanelConfig = { config: { type: 'RadioButtonControl', label: t('Color by'), - default: ColorBy.metric, + default: ColorBy.Metric, options: [ - [ColorBy.metric, t('Metric')], - [ColorBy.country, t('Country')], + [ColorBy.Metric, t('Metric')], + [ColorBy.Country, t('Country')], ], description: t( 'Choose whether a country should be shaded by the metric, or assigned a color based on a categorical color palette', @@ -148,12 +148,12 @@ const config: ControlPanelConfig = { linear_color_scheme: { label: t('Country Color Scheme'), visibility: ({ controls }) => - Boolean(controls?.color_by.value === ColorBy.metric), + Boolean(controls?.color_by.value === ColorBy.Metric), }, color_scheme: { label: t('Country Color Scheme'), visibility: ({ controls }) => - Boolean(controls?.color_by.value === ColorBy.country), + Boolean(controls?.color_by.value === ColorBy.Country), }, }, formDataOverrides: formData => ({ diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/index.js b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/index.js index 95eb6b59f..8c2cf10d4 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/index.js +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/index.js @@ -46,9 +46,9 @@ const metadata = new ChartMetadata({ thumbnail, useLegacyApi: true, behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], }); diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/utils.ts b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/utils.ts index b558b15b9..e8ac50e09 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/utils.ts +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/utils.ts @@ -18,6 +18,6 @@ */ export enum ColorBy { - metric = 'metric', - country = 'country', + Metric = 'metric', + Country = 'country', } diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx index 5b307efd9..723407c5a 100644 --- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx +++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx @@ -72,12 +72,12 @@ function jsFunctionControl( {extraDescr} ), - warning: !isFeatureEnabled(FeatureFlag.ENABLE_JAVASCRIPT_CONTROLS) + warning: !isFeatureEnabled(FeatureFlag.EnableJavascriptControls) ? t( 'This functionality is disabled in your environment for security reasons.', ) : null, - readOnly: !isFeatureEnabled(FeatureFlag.ENABLE_JAVASCRIPT_CONTROLS), + readOnly: !isFeatureEnabled(FeatureFlag.EnableJavascriptControls), }; } diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Area/index.js b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Area/index.js index ba20a958c..b85a64579 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Area/index.js +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Area/index.js @@ -38,7 +38,7 @@ const metadata = new ChartMetadata({ { url: example3, caption: t('Video game consoles') }, { url: example4, caption: t('Vehicle Types') }, ], - label: ChartLabel.DEPRECATED, + label: ChartLabel.Deprecated, name: t('Area Chart (legacy)'), supportedAnnotationTypes: [ANNOTATION_TYPES.INTERVAL, ANNOTATION_TYPES.EVENT], tags: [ diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Bar/index.js b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Bar/index.js index 33436be14..d2f14b4b7 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Bar/index.js +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Bar/index.js @@ -32,7 +32,7 @@ const metadata = new ChartMetadata({ 'Visualize how a metric changes over time using bars. Add a group by column to visualize group level metrics and how they change over time.', ), exampleGallery: [{ url: example1 }, { url: example2 }, { url: example3 }], - label: ChartLabel.DEPRECATED, + label: ChartLabel.Deprecated, name: t('Time-series Bar Chart (legacy)'), supportedAnnotationTypes: [ANNOTATION_TYPES.INTERVAL, ANNOTATION_TYPES.EVENT], tags: [ diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Bubble/index.js b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Bubble/index.js index c2916c7a4..f3cf1f243 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Bubble/index.js +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Bubble/index.js @@ -29,7 +29,7 @@ const metadata = new ChartMetadata({ 'Visualizes a metric across three dimensions of data in a single chart (X axis, Y axis, and bubble size). Bubbles from the same group can be showcased using bubble color.', ), exampleGallery: [{ url: example }], - label: ChartLabel.DEPRECATED, + label: ChartLabel.Deprecated, name: t('Bubble Chart (legacy)'), tags: [ t('Multi-Dimensions'), diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/DistBar/index.js b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/DistBar/index.js index 66b98e4cc..b29277f8c 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/DistBar/index.js +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/DistBar/index.js @@ -35,7 +35,7 @@ const metadata = new ChartMetadata({ { url: example2, caption: 'Grouped style' }, { url: example3 }, ], - label: ChartLabel.DEPRECATED, + label: ChartLabel.Deprecated, name: t('Bar Chart (legacy)'), tags: [ t('Additive'), diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Line/index.js b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Line/index.js index 51db67edf..c848e7acc 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Line/index.js +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Line/index.js @@ -35,7 +35,7 @@ const metadata = new ChartMetadata({ { url: example2 }, { url: battery, caption: t('Battery level over time') }, ], - label: ChartLabel.DEPRECATED, + label: ChartLabel.Deprecated, name: t('Line Chart (legacy)'), supportedAnnotationTypes: [ ANNOTATION_TYPES.TIME_SERIES, diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Pie/index.js b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Pie/index.js index 75b66fb93..408656ea1 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Pie/index.js +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/Pie/index.js @@ -24,7 +24,7 @@ import controlPanel from './controlPanel'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], description: '', - label: ChartLabel.DEPRECATED, + label: ChartLabel.Deprecated, name: t('Pie Chart (legacy)'), thumbnail, useLegacyApi: true, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/controlPanel.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/controlPanel.ts index 39b97bfd3..f949182a5 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/controlPanel.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/controlPanel.ts @@ -113,7 +113,7 @@ export default { ? colnames .filter( (colname: string, index: number) => - coltypes[index] === GenericDataType.NUMERIC, + coltypes[index] === GenericDataType.Numeric, ) .map(colname => ({ value: colname, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/index.ts index d92283d7c..5137f8192 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/index.ts @@ -46,7 +46,7 @@ const metadata = { t('Description'), ], thumbnail, - behaviors: [Behavior.DRILL_TO_DETAIL], + behaviors: [Behavior.DrillToDetail], }; export default class BigNumberTotalChartPlugin extends EchartsChartPlugin< diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/transformProps.ts index 4a68e1ff9..757ecd3e6 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/transformProps.ts @@ -85,8 +85,8 @@ export default function transformProps( ); const headerFormatter = - coltypes[0] === GenericDataType.TEMPORAL || - coltypes[0] === GenericDataType.STRING || + coltypes[0] === GenericDataType.Temporal || + coltypes[0] === GenericDataType.String || forceTimestampFormatting ? formatTime : numberFormatter; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/index.ts index 80a21ad22..2f8da6ef0 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/index.ts @@ -45,7 +45,7 @@ const metadata = { t('Trend'), ], thumbnail, - behaviors: [Behavior.DRILL_TO_DETAIL], + behaviors: [Behavior.DrillToDetail], }; export default class BigNumberWithTrendlineChartPlugin extends EchartsChartPlugin< diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts index ce35b6576..c5e9e7042 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts @@ -185,8 +185,8 @@ export default function transformProps( ); const headerFormatter = - metricColtype === GenericDataType.TEMPORAL || - metricColtype === GenericDataType.STRING || + metricColtype === GenericDataType.Temporal || + metricColtype === GenericDataType.String || forceTimestampFormatting ? formatTime : numberFormatter; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/index.ts index dc9930481..abe6fcd67 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/index.ts @@ -46,9 +46,9 @@ export default class EchartsBoxPlotChartPlugin extends EchartsChartPlugin< loadChart: () => import('./EchartsBoxPlot'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Distribution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Bubble/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Bubble/index.ts index c07776c4a..362e75556 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Bubble/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Bubble/index.ts @@ -35,7 +35,7 @@ export default class EchartsBubbleChartPlugin extends ChartPlugin< controlPanel, loadChart: () => import('./EchartsBubble'), metadata: new ChartMetadata({ - behaviors: [Behavior.INTERACTIVE_CHART], + behaviors: [Behavior.InteractiveChart], category: t('Correlation'), credits: ['https://echarts.apache.org'], description: t( diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Bubble/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Bubble/transformProps.ts index 754b26003..7731e095e 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Bubble/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Bubble/transformProps.ts @@ -158,7 +158,7 @@ export default function transformProps(chartProps: EchartsBubbleChartProps) { convertInteger(xAxisTitleMargin), ); - const xAxisType = logXAxis ? AxisType.log : AxisType.value; + const xAxisType = logXAxis ? AxisType.Log : AxisType.Value; const echartOptions: EChartsCoreOption = { series, xAxis: { @@ -196,7 +196,7 @@ export default function transformProps(chartProps: EchartsBubbleChartProps) { nameGap: convertInteger(yAxisTitleMargin), min: yAxisMin, max: yAxisMax, - type: logYAxis ? AxisType.log : AxisType.value, + type: logYAxis ? AxisType.Log : AxisType.Value, }, legend: { ...getLegendProps(legendType, legendOrientation, showLegend, theme), diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx index da0b06675..9cad10bf1 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx @@ -82,11 +82,14 @@ const config: ControlPanelConfig = { 'Display percents in the label and tooltip as the percent of the total value, from the first step of the funnel, or from the previous step in the funnel.', ), choices: [ - [PercentCalcType.FIRST_STEP, t('Calculate from first step')], - [PercentCalcType.PREV_STEP, t('Calculate from previous step')], - [PercentCalcType.TOTAL, t('Percent of total')], + [PercentCalcType.FirstStep, t('Calculate from first step')], + [ + PercentCalcType.PreviousStep, + t('Calculate from previous step'), + ], + [PercentCalcType.Total, t('Percent of total')], ], - default: PercentCalcType.FIRST_STEP, + default: PercentCalcType.FirstStep, renderTrigger: true, }, }, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/index.ts index 9660f5257..d679aa150 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/index.ts @@ -46,9 +46,9 @@ export default class EchartsFunnelChartPlugin extends EchartsChartPlugin< loadChart: () => import('./EchartsFunnel'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('KPI'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts index df43fe0a8..dbfb33b2e 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts @@ -54,7 +54,7 @@ export function formatFunnelLabel({ params, labelType, numberFormatter, - percentCalculationType = PercentCalcType.FIRST_STEP, + percentCalculationType = PercentCalcType.FirstStep, sanitizeName = false, }: { params: Pick; @@ -72,9 +72,9 @@ export function formatFunnelLabel({ }; let percent; - if (percentCalculationType === PercentCalcType.TOTAL) { + if (percentCalculationType === PercentCalcType.Total) { percent = (totalPercent ?? 0) / 100; - } else if (percentCalculationType === PercentCalcType.PREV_STEP) { + } else if (percentCalculationType === PercentCalcType.PreviousStep) { percent = prevStepPercent ?? 0; } else { percent = firstStepPercent ?? 0; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/types.ts index 515956223..18a40267c 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/types.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/types.ts @@ -82,7 +82,7 @@ export type FunnelChartTransformedProps = ContextMenuTransformedProps; export enum PercentCalcType { - TOTAL = 'total', - PREV_STEP = 'prev_step', - FIRST_STEP = 'first_step', + Total = 'total', + PreviousStep = 'prev_step', + FirstStep = 'first_step', } diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/index.ts index 78f6c386c..2d2418568 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/index.ts @@ -37,9 +37,9 @@ export default class EchartsGaugeChartPlugin extends EchartsChartPlugin< loadChart: () => import('./EchartsGauge'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('KPI'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Graph/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Graph/index.ts index d95f3dd98..bdab9b6da 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Graph/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Graph/index.ts @@ -50,9 +50,9 @@ export default class EchartsGraphChartPlugin extends EchartsChartPlugin { ], thumbnail, behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], }, transformProps, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx index 9c871407f..0d04de15b 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx @@ -142,7 +142,7 @@ export default function EchartsMixedTimeseries({ ...(eventParams.name ? [eventParams.name] : []), ...(isFirst ? labelMap : labelMapB)[eventParams.seriesName], ]; - if (data && xAxis.type === AxisType.time) { + if (data && xAxis.type === AxisType.Time) { drillToDetailFilters.push({ col: xAxis.label === DTTM_ALIAS @@ -155,7 +155,7 @@ export default function EchartsMixedTimeseries({ }); } [ - ...(data && xAxis.type === AxisType.category ? [xAxis.label] : []), + ...(data && xAxis.type === AxisType.Category ? [xAxis.label] : []), ...(isFirst ? formData.groupby : formData.groupbyB), ].forEach((dimension, i) => drillToDetailFilters.push({ diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts index f87d84132..3ebc7c4f0 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts @@ -49,9 +49,9 @@ export default class EchartsTimeseriesChartPlugin extends EchartsChartPlugin< loadChart: () => import('./EchartsMixedTimeseries'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Evolution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts index 1d4eceb33..cbe821d93 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -20,6 +20,7 @@ import { invert } from 'lodash'; import { AnnotationLayer, + AxisType, buildCustomFormatters, CategoricalColorNamespace, CurrencyFormatter, @@ -460,11 +461,11 @@ export default function transformProps( } const tooltipFormatter = - xAxisDataType === GenericDataType.TEMPORAL + xAxisDataType === GenericDataType.Temporal ? getTooltipTimeFormatter(tooltipTimeFormat) : String; const xAxisFormatter = - xAxisDataType === GenericDataType.TEMPORAL + xAxisDataType === GenericDataType.Temporal ? getXAxisFormatter(xAxisTimeFormat) : String; @@ -503,7 +504,7 @@ export default function transformProps( }, minorTick: { show: minorTicks }, minInterval: - xAxisType === 'time' && timeGrainSqla + xAxisType === AxisType.Time && timeGrainSqla ? TIMEGRAIN_TO_TIMESTAMP[timeGrainSqla] : 0, ...getMinAndMaxFromBounds( diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts index 7380f575e..6c022ec72 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts @@ -49,9 +49,9 @@ export default class EchartsPieChartPlugin extends EchartsChartPlugin< loadChart: () => import('./EchartsPie'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Part of a Whole'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Radar/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Radar/controlPanel.tsx index 3b423c512..628939743 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Radar/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Radar/controlPanel.tsx @@ -165,7 +165,7 @@ const config: ControlPanelConfig = { description: t('Further customize how to display each metric'), renderTrigger: true, configFormLayout: { - [GenericDataType.NUMERIC]: [[radarMetricMaxValue]], + [GenericDataType.Numeric]: [[radarMetricMaxValue]], }, shouldMapStateToProps() { return true; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Radar/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Radar/index.ts index 70f94f42f..5a919febb 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Radar/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Radar/index.ts @@ -48,9 +48,9 @@ export default class EchartsRadarChartPlugin extends EchartsChartPlugin< loadChart: () => import('./EchartsRadar'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Ranking'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/index.ts index 43309d5d2..94fb33c90 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/index.ts @@ -33,9 +33,9 @@ export default class EchartsSunburstChartPlugin extends EchartsChartPlugin { loadChart: () => import('./EchartsSunburst'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Part of a Whole'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/index.ts index b0fdfed0f..eb3564bb9 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/index.ts @@ -45,9 +45,9 @@ export default class EchartsAreaChartPlugin extends EchartsChartPlugin< loadChart: () => import('../EchartsTimeseries'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Evolution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx index 022338219..78a573670 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx @@ -173,7 +173,7 @@ export default function EchartsTimeseries({ ...(eventParams.name ? [eventParams.name] : []), ...(labelMap[seriesName] ?? []), ]; - if (data && xAxis.type === AxisType.time) { + if (data && xAxis.type === AxisType.Time) { drillToDetailFilters.push({ col: // if the xAxis is '__timestamp', granularity_sqla will be the column of filter @@ -187,7 +187,7 @@ export default function EchartsTimeseries({ }); } [ - ...(xAxis.type === AxisType.category && data ? [xAxis.label] : []), + ...(xAxis.type === AxisType.Category && data ? [xAxis.label] : []), ...formData.groupby, ].forEach((dimension, i) => drillToDetailFilters.push({ diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx index 50cf3549f..ba2f873a1 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx @@ -59,9 +59,9 @@ const { function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] { const isXAxis = axis === 'x'; const isVertical = (controls: ControlStateMapping) => - Boolean(controls?.orientation.value === OrientationType.vertical); + Boolean(controls?.orientation.value === OrientationType.Vertical); const isHorizontal = (controls: ControlStateMapping) => - Boolean(controls?.orientation.value === OrientationType.horizontal); + Boolean(controls?.orientation.value === OrientationType.Horizontal); return [ [ { @@ -148,9 +148,9 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] { function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] { const isXAxis = axis === 'x'; const isVertical = (controls: ControlStateMapping) => - Boolean(controls?.orientation.value === OrientationType.vertical); + Boolean(controls?.orientation.value === OrientationType.Vertical); const isHorizontal = (controls: ControlStateMapping) => - Boolean(controls?.orientation.value === OrientationType.horizontal); + Boolean(controls?.orientation.value === OrientationType.Horizontal); return [ [ { @@ -272,8 +272,8 @@ const config: ControlPanelConfig = { label: t('Bar orientation'), default: orientation, options: [ - [OrientationType.vertical, t('Vertical')], - [OrientationType.horizontal, t('Horizontal')], + [OrientationType.Vertical, t('Vertical')], + [OrientationType.Horizontal, t('Horizontal')], ], description: t('Orientation of bar chart'), }, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/index.ts index 8057c8f0d..6e1962b4c 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/index.ts @@ -51,9 +51,9 @@ export default class EchartsTimeseriesBarChartPlugin extends EchartsChartPlugin< loadChart: () => import('../../EchartsTimeseries'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Evolution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/index.ts index e83f19e59..c778e0719 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/index.ts @@ -50,9 +50,9 @@ export default class EchartsTimeseriesLineChartPlugin extends EchartsChartPlugin loadChart: () => import('../../EchartsTimeseries'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Evolution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/index.ts index 753f9150d..931a790cc 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/index.ts @@ -49,9 +49,9 @@ export default class EchartsTimeseriesScatterChartPlugin extends EchartsChartPlu loadChart: () => import('../../EchartsTimeseries'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Evolution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/index.ts index de6a1d38a..320e4752e 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/index.ts @@ -49,9 +49,9 @@ export default class EchartsTimeseriesSmoothLineChartPlugin extends EchartsChart loadChart: () => import('../../EchartsTimeseries'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Evolution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/index.ts index 91deb322b..c581da3e0 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/index.ts @@ -40,9 +40,9 @@ export default class EchartsTimeseriesStepChartPlugin extends EchartsChartPlugin loadChart: () => import('../EchartsTimeseries'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Evolution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts index 839bc607f..96efd4a06 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts @@ -69,7 +69,7 @@ export const DEFAULT_FORM_DATA: EchartsTimeseriesFormData = { showValue: false, onlyTotal: false, percentageThreshold: 0, - orientation: OrientationType.vertical, + orientation: OrientationType.Vertical, sort_series_type: 'sum', sort_series_ascending: false, }; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/index.ts index dace33a10..33623952e 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/index.ts @@ -39,9 +39,9 @@ export default class EchartsTimeseriesChartPlugin extends EchartsChartPlugin< loadChart: () => import('./EchartsTimeseries'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Evolution'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts index a5c380c5f..b9e04b2e8 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts @@ -204,7 +204,7 @@ export default function transformProps( ) { xAxisLabel = verboseMap[xAxisLabel]; } - const isHorizontal = orientation === OrientationType.horizontal; + const isHorizontal = orientation === OrientationType.Horizontal; const { totalStackedValues, thresholdValues } = extractDataTotalValues( rebasedData, { @@ -410,11 +410,11 @@ export default function transformProps( } const tooltipFormatter = - xAxisDataType === GenericDataType.TEMPORAL + xAxisDataType === GenericDataType.Temporal ? getTooltipTimeFormatter(tooltipTimeFormat) : String; const xAxisFormatter = - xAxisDataType === GenericDataType.TEMPORAL + xAxisDataType === GenericDataType.Temporal ? getXAxisFormatter(xAxisTimeFormat) : String; @@ -461,7 +461,7 @@ export default function transformProps( }, minorTick: { show: minorTicks }, minInterval: - xAxisType === AxisType.time && timeGrainSqla + xAxisType === AxisType.Time && timeGrainSqla ? TIMEGRAIN_TO_TIMESTAMP[timeGrainSqla] : 0, ...getMinAndMaxFromBounds( @@ -475,7 +475,7 @@ export default function transformProps( let yAxis: any = { ...defaultYAxis, - type: logAxis ? AxisType.log : AxisType.value, + type: logAxis ? AxisType.Log : AxisType.Value, min: yAxisMin, max: yAxisMax, minorTick: { show: minorTicks }, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts index 692abb2c7..dbecb483d 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts @@ -38,8 +38,8 @@ import { } from '../types'; export enum OrientationType { - vertical = 'vertical', - horizontal = 'horizontal', + Vertical = 'vertical', + Horizontal = 'horizontal', } export enum EchartsTimeseriesSeriesType { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/index.ts index d0359aff9..e461e6860 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/index.ts @@ -48,9 +48,9 @@ export default class EchartsTreemapChartPlugin extends EchartsChartPlugin< loadChart: () => import('./EchartsTreemap'), metadata: { behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Part of a Whole'), credits: ['https://echarts.apache.org'], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/index.ts index b8c66fabb..f0f2e9e5c 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/index.ts @@ -47,7 +47,7 @@ export default class EchartsWaterfallChartPlugin extends ChartPlugin< controlPanel, loadChart: () => import('./EchartsWaterfall'), metadata: new ChartMetadata({ - behaviors: [Behavior.INTERACTIVE_CHART], + behaviors: [Behavior.InteractiveChart], credits: ['https://echarts.apache.org'], category: t('Evolution'), description: t( diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts index 84fbbf6cb..edc29363f 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts @@ -339,7 +339,7 @@ export default function transformProps( if (value === TOTAL_MARK) { return TOTAL_MARK; } - if (coltypeMapping[xAxisColumns[index]] === GenericDataType.TEMPORAL) { + if (coltypeMapping[xAxisColumns[index]] === GenericDataType.Temporal) { if (typeof value === 'string') { return getTimeFormatter(xAxisTimeFormat)(Number.parseInt(value, 10)); } diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts b/superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts index d3d858d97..df6515d20 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts @@ -25,13 +25,13 @@ import { AnnotationLayer, AnnotationOpacity, AnnotationType, + AxisType, DataRecord, evalExpression, FormulaAnnotationLayer, isRecordAnnotationResult, isTableAnnotationLayer, isTimeseriesAnnotationResult, - AxisType, } from '@superset-ui/core'; import { EchartsTimeseriesChartProps } from '../types'; import { EchartsMixedTimeseriesProps } from '../MixedTimeseries/types'; @@ -46,7 +46,7 @@ export function evalFormula( return data.map(row => { let value = row[xAxis]; - if (xAxisType === 'time') { + if (xAxisType === AxisType.Time) { value = new Date(value as string).getTime(); } return [value, evalExpression(expression, (value || 0) as number)]; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts b/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts index 8c87bf433..cebfe374d 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts @@ -364,7 +364,7 @@ export function formatSeriesName( if (typeof name === 'boolean') { return name.toString(); } - if (name instanceof Date || coltype === GenericDataType.TEMPORAL) { + if (name instanceof Date || coltype === GenericDataType.Temporal) { const normalizedName = typeof name === 'string' ? normalizeTimestamp(name) : name; const d = @@ -535,15 +535,15 @@ export function getAxisType( dataType?: GenericDataType, ): AxisType { if (forceCategorical) { - return AxisType.category; + return AxisType.Category; } - if (dataType === GenericDataType.TEMPORAL) { - return AxisType.time; + if (dataType === GenericDataType.Temporal) { + return AxisType.Time; } - if (dataType === GenericDataType.NUMERIC && !stack) { - return AxisType.value; + if (dataType === GenericDataType.Numeric && !stack) { + return AxisType.Value; } - return AxisType.category; + return AxisType.Category; } export function getOverMaxHiddenFormatter( @@ -585,7 +585,7 @@ export function getMinAndMaxFromBounds( max?: number, seriesType?: EchartsTimeseriesSeriesType, ): BoundsType | {} { - if (axisType === AxisType.value && truncateAxis) { + if (axisType === AxisType.Value && truncateAxis) { const ret: BoundsType = {}; if (seriesType === EchartsTimeseriesSeriesType.Bar) { ret.scale = true; diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Funnel/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Funnel/transformProps.test.ts index 9c1d35cdd..4d326ab30 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/Funnel/transformProps.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/Funnel/transformProps.test.ts @@ -93,7 +93,7 @@ describe('formatFunnelLabel', () => { params, numberFormatter, labelType: EchartsFunnelLabelTypeType.Key, - percentCalculationType: PercentCalcType.TOTAL, + percentCalculationType: PercentCalcType.Total, }), ).toEqual('My Label'); expect( @@ -101,7 +101,7 @@ describe('formatFunnelLabel', () => { params, numberFormatter, labelType: EchartsFunnelLabelTypeType.Value, - percentCalculationType: PercentCalcType.TOTAL, + percentCalculationType: PercentCalcType.Total, }), ).toEqual('1.23k'); expect( @@ -109,7 +109,7 @@ describe('formatFunnelLabel', () => { params, numberFormatter, labelType: EchartsFunnelLabelTypeType.Percent, - percentCalculationType: PercentCalcType.TOTAL, + percentCalculationType: PercentCalcType.Total, }), ).toEqual('12.34%'); expect( @@ -117,7 +117,7 @@ describe('formatFunnelLabel', () => { params, numberFormatter, labelType: EchartsFunnelLabelTypeType.Percent, - percentCalculationType: PercentCalcType.FIRST_STEP, + percentCalculationType: PercentCalcType.FirstStep, }), ).toEqual('50.00%'); expect( @@ -125,7 +125,7 @@ describe('formatFunnelLabel', () => { params, numberFormatter, labelType: EchartsFunnelLabelTypeType.Percent, - percentCalculationType: PercentCalcType.PREV_STEP, + percentCalculationType: PercentCalcType.PreviousStep, }), ).toEqual('85.00%'); expect( @@ -133,7 +133,7 @@ describe('formatFunnelLabel', () => { params, numberFormatter, labelType: EchartsFunnelLabelTypeType.KeyValue, - percentCalculationType: PercentCalcType.TOTAL, + percentCalculationType: PercentCalcType.Total, }), ).toEqual('My Label: 1.23k'); expect( @@ -141,7 +141,7 @@ describe('formatFunnelLabel', () => { params, numberFormatter, labelType: EchartsFunnelLabelTypeType.KeyPercent, - percentCalculationType: PercentCalcType.TOTAL, + percentCalculationType: PercentCalcType.Total, }), ).toEqual('My Label: 12.34%'); expect( @@ -149,7 +149,7 @@ describe('formatFunnelLabel', () => { params, numberFormatter, labelType: EchartsFunnelLabelTypeType.KeyValuePercent, - percentCalculationType: PercentCalcType.TOTAL, + percentCalculationType: PercentCalcType.Total, }), ).toEqual('My Label: 1.23k (12.34%)'); expect( @@ -157,7 +157,7 @@ describe('formatFunnelLabel', () => { params: { ...params, name: '' }, numberFormatter, labelType: EchartsFunnelLabelTypeType.Key, - percentCalculationType: PercentCalcType.TOTAL, + percentCalculationType: PercentCalcType.Total, }), ).toEqual(''); expect( @@ -165,7 +165,7 @@ describe('formatFunnelLabel', () => { params: { ...params, name: '' }, numberFormatter, labelType: EchartsFunnelLabelTypeType.Key, - percentCalculationType: PercentCalcType.TOTAL, + percentCalculationType: PercentCalcType.Total, sanitizeName: true, }), ).toEqual('<NULL>'); diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/utils/annotation.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/utils/annotation.test.ts index 59afebd73..fd2f4acf2 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/utils/annotation.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/utils/annotation.test.ts @@ -161,7 +161,7 @@ describe('evalFormula', () => { { __timestamp: 10 }, ]; - expect(evalFormula(layer, data, '__timestamp', AxisType.time)).toEqual([ + expect(evalFormula(layer, data, '__timestamp', AxisType.Time)).toEqual([ [0, 1], [10, 11], ]); @@ -178,7 +178,7 @@ describe('evalFormula', () => { { ...layer, value: 'y = x* 2 -1' }, data, '__timestamp', - AxisType.time, + AxisType.Time, ), ).toEqual([ [0, -1], @@ -194,7 +194,7 @@ describe('evalFormula', () => { { ...layer, value: 'y = 1000' }, data, 'gender', - AxisType.category, + AxisType.Category, ), ).toEqual([ ['boy', 1000], diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts index 10768a47f..6e4848643 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts @@ -645,7 +645,7 @@ describe('formatSeriesName', () => { expect( formatSeriesName('1995-01-01 00:00:00.000000', { timeFormatter: annualTimeFormatter, - coltype: GenericDataType.TEMPORAL, + coltype: GenericDataType.Temporal, }), ).toEqual('1995'); }); @@ -911,33 +911,33 @@ test('calculateLowerLogTick', () => { }); test('getAxisType without forced categorical', () => { - expect(getAxisType(false, false, GenericDataType.TEMPORAL)).toEqual( - AxisType.time, + expect(getAxisType(false, false, GenericDataType.Temporal)).toEqual( + AxisType.Time, ); - expect(getAxisType(false, false, GenericDataType.NUMERIC)).toEqual( - AxisType.value, + expect(getAxisType(false, false, GenericDataType.Numeric)).toEqual( + AxisType.Value, ); - expect(getAxisType(true, false, GenericDataType.NUMERIC)).toEqual( - AxisType.category, + expect(getAxisType(true, false, GenericDataType.Numeric)).toEqual( + AxisType.Category, ); - expect(getAxisType(false, false, GenericDataType.BOOLEAN)).toEqual( - AxisType.category, + expect(getAxisType(false, false, GenericDataType.Boolean)).toEqual( + AxisType.Category, ); - expect(getAxisType(false, false, GenericDataType.STRING)).toEqual( - AxisType.category, + expect(getAxisType(false, false, GenericDataType.String)).toEqual( + AxisType.Category, ); }); test('getAxisType with forced categorical', () => { - expect(getAxisType(false, true, GenericDataType.NUMERIC)).toEqual( - AxisType.category, + expect(getAxisType(false, true, GenericDataType.Numeric)).toEqual( + AxisType.Category, ); }); test('getMinAndMaxFromBounds returns empty object when not truncating', () => { expect( getMinAndMaxFromBounds( - AxisType.value, + AxisType.Value, false, 10, 100, @@ -949,7 +949,7 @@ test('getMinAndMaxFromBounds returns empty object when not truncating', () => { test('getMinAndMaxFromBounds returns empty object for categorical axis', () => { expect( getMinAndMaxFromBounds( - AxisType.category, + AxisType.Category, false, 10, 100, @@ -961,7 +961,7 @@ test('getMinAndMaxFromBounds returns empty object for categorical axis', () => { test('getMinAndMaxFromBounds returns empty object for time axis', () => { expect( getMinAndMaxFromBounds( - AxisType.time, + AxisType.Time, false, 10, 100, @@ -973,7 +973,7 @@ test('getMinAndMaxFromBounds returns empty object for time axis', () => { test('getMinAndMaxFromBounds returns dataMin/dataMax for non-bar charts', () => { expect( getMinAndMaxFromBounds( - AxisType.value, + AxisType.Value, true, undefined, undefined, @@ -988,7 +988,7 @@ test('getMinAndMaxFromBounds returns dataMin/dataMax for non-bar charts', () => test('getMinAndMaxFromBounds returns bound without scale for non-bar charts', () => { expect( getMinAndMaxFromBounds( - AxisType.value, + AxisType.Value, true, 10, undefined, @@ -1003,7 +1003,7 @@ test('getMinAndMaxFromBounds returns bound without scale for non-bar charts', () test('getMinAndMaxFromBounds returns scale when truncating without bounds', () => { expect( getMinAndMaxFromBounds( - AxisType.value, + AxisType.Value, true, undefined, undefined, @@ -1015,7 +1015,7 @@ test('getMinAndMaxFromBounds returns scale when truncating without bounds', () = test('getMinAndMaxFromBounds returns automatic upper bound when truncating', () => { expect( getMinAndMaxFromBounds( - AxisType.value, + AxisType.Value, true, 10, undefined, @@ -1030,7 +1030,7 @@ test('getMinAndMaxFromBounds returns automatic upper bound when truncating', () test('getMinAndMaxFromBounds returns automatic lower bound when truncating', () => { expect( getMinAndMaxFromBounds( - AxisType.value, + AxisType.Value, true, undefined, 100, diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/queryMode.tsx b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/queryMode.tsx index b895b97f2..87178cc46 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/queryMode.tsx +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/queryMode.tsx @@ -29,8 +29,8 @@ const queryMode: ControlConfig<'RadioButtonControl'> = { label: t('Query mode'), default: null, options: [ - [QueryMode.aggregate, QueryModeLabel[QueryMode.aggregate]], - [QueryMode.raw, QueryModeLabel[QueryMode.raw]], + [QueryMode.Aggregate, QueryModeLabel[QueryMode.Aggregate]], + [QueryMode.Raw, QueryModeLabel[QueryMode.Raw]], ], mapStateToProps: ({ controls }) => ({ value: getQueryMode(controls) }), rerender: ['all_columns', 'groupby', 'metrics', 'percent_metrics'], diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/shared.ts b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/shared.ts index 5f364a288..2c65c4780 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/shared.ts +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/shared.ts @@ -29,14 +29,14 @@ import { export function getQueryMode(controls: ControlStateMapping): QueryMode { const mode = controls?.query_mode?.value; - if (mode === QueryMode.aggregate || mode === QueryMode.raw) { + if (mode === QueryMode.Aggregate || mode === QueryMode.Raw) { return mode as QueryMode; } const rawColumns = controls?.all_columns?.value as | QueryFormColumn[] | undefined; const hasRawColumns = rawColumns && rawColumns.length > 0; - return hasRawColumns ? QueryMode.raw : QueryMode.aggregate; + return hasRawColumns ? QueryMode.Raw : QueryMode.Aggregate; } /** @@ -47,8 +47,8 @@ export function isQueryMode(mode: QueryMode) { getQueryMode(controls) === mode; } -export const isAggMode = isQueryMode(QueryMode.aggregate); -export const isRawMode = isQueryMode(QueryMode.raw); +export const isAggMode = isQueryMode(QueryMode.Aggregate); +export const isRawMode = isQueryMode(QueryMode.Raw); export const validateAggControlValues = ( controls: ControlStateMapping, diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx index 32f10b077..c727e0cfc 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx @@ -439,8 +439,8 @@ export default function PivotTableChart(props: PivotTableProps) { rowSubTotals, highlightHeaderCellsOnHover: emitCrossFilters || - isFeatureEnabled(FeatureFlag.DRILL_BY) || - isFeatureEnabled(FeatureFlag.DRILL_TO_DETAIL), + isFeatureEnabled(FeatureFlag.DrillBy) || + isFeatureEnabled(FeatureFlag.DrillToDetail), highlightedHeaderCells: selectedFilters, omittedHighlightHeaderGroups: [METRIC_KEY], cellColorFormatters: { [METRIC_KEY]: metricColorFormatters }, diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/index.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/index.ts index 6963c67f0..c890c1a8f 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/index.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/index.ts @@ -48,9 +48,9 @@ export default class PivotTableChartPlugin extends ChartPlugin< constructor() { const metadata = new ChartMetadata({ behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Table'), description: t( diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts index 76c58b895..b7f4451ce 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts @@ -112,7 +112,7 @@ export default function transformProps(chartProps: ChartProps) { const dateFormatters = colnames .filter( (colname: string, index: number) => - coltypes[index] === GenericDataType.TEMPORAL, + coltypes[index] === GenericDataType.Temporal, ) .reduce( ( diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/hooks/useSticky.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/hooks/useSticky.tsx index 6120e1980..857af565e 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/hooks/useSticky.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/hooks/useSticky.tsx @@ -56,8 +56,8 @@ export type GetTableSize = () => Partial | undefined; export type SetStickyState = (size?: Partial) => void; export enum ReducerActions { - init = 'init', // this is from global reducer - setStickyState = 'setStickyState', + Init = 'init', // this is from global reducer + SetStickyState = 'setStickyState', } export type ReducerAction< @@ -341,7 +341,7 @@ function useInstance(instance: TableInstance) { const setStickyState = useCallback( (size?: Partial) => { dispatch({ - type: ReducerActions.setStickyState, + type: ReducerActions.SetStickyState, size, }); }, @@ -395,7 +395,7 @@ export default function useSticky(hooks: Hooks) { ReducerActions, { size: StickyState } >; - if (action.type === ReducerActions.init) { + if (action.type === ReducerActions.Init) { return { ...newState, sticky: { @@ -403,7 +403,7 @@ export default function useSticky(hooks: Hooks) { }, }; } - if (action.type === ReducerActions.setStickyState) { + if (action.type === ReducerActions.SetStickyState) { const { size } = action; if (!size) { return { ...newState }; diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx index d106e42a8..785e34f63 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx @@ -81,10 +81,10 @@ const ACTION_KEYS = { * Return sortType based on data type */ function getSortTypeByDataType(dataType: GenericDataType): DefaultSortTypes { - if (dataType === GenericDataType.TEMPORAL) { + if (dataType === GenericDataType.Temporal) { return 'datetime'; } - if (dataType === GenericDataType.STRING) { + if (dataType === GenericDataType.String) { return 'alphanumeric'; } return 'basic'; diff --git a/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts b/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts index b8102a0ce..69631a5f3 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts @@ -39,12 +39,12 @@ import { updateExternalFormData } from './DataTable/utils/externalAPIs'; */ export function getQueryMode(formData: TableChartFormData) { const { query_mode: mode } = formData; - if (mode === QueryMode.aggregate || mode === QueryMode.raw) { + if (mode === QueryMode.Aggregate || mode === QueryMode.Raw) { return mode; } const rawColumns = formData?.all_columns; const hasRawColumns = rawColumns && rawColumns.length > 0; - return hasRawColumns ? QueryMode.raw : QueryMode.aggregate; + return hasRawColumns ? QueryMode.Raw : QueryMode.Aggregate; } const buildQuery: BuildQuery = ( @@ -62,7 +62,7 @@ const buildQuery: BuildQuery = ( extra_form_data?.time_grain_sqla || formData.time_grain_sqla; let formDataCopy = formData; // never include time in raw records mode - if (queryMode === QueryMode.raw) { + if (queryMode === QueryMode.Raw) { formDataCopy = { ...formData, include_time: false, @@ -73,7 +73,7 @@ const buildQuery: BuildQuery = ( let { metrics, orderby = [], columns = [] } = baseQueryObject; let postProcessing: PostProcessingRule[] = []; - if (queryMode === QueryMode.aggregate) { + if (queryMode === QueryMode.Aggregate) { metrics = metrics || []; // override orderby with timeseries metric when in aggregation mode if (sortByMetric) { @@ -161,7 +161,7 @@ const buildQuery: BuildQuery = ( if ( metrics?.length && formData.show_totals && - queryMode === QueryMode.aggregate + queryMode === QueryMode.Aggregate ) { extraQueries.push({ ...queryObject, diff --git a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx index bb608e1c0..ad39b504c 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx @@ -50,14 +50,14 @@ import { PAGE_SIZE_OPTIONS } from './consts'; function getQueryMode(controls: ControlStateMapping): QueryMode { const mode = controls?.query_mode?.value; - if (mode === QueryMode.aggregate || mode === QueryMode.raw) { + if (mode === QueryMode.Aggregate || mode === QueryMode.Raw) { return mode as QueryMode; } const rawColumns = controls?.all_columns?.value as | QueryFormColumn[] | undefined; const hasRawColumns = rawColumns && rawColumns.length > 0; - return hasRawColumns ? QueryMode.raw : QueryMode.aggregate; + return hasRawColumns ? QueryMode.Raw : QueryMode.Aggregate; } /** @@ -68,8 +68,8 @@ function isQueryMode(mode: QueryMode) { getQueryMode(controls) === mode; } -const isAggMode = isQueryMode(QueryMode.aggregate); -const isRawMode = isQueryMode(QueryMode.raw); +const isAggMode = isQueryMode(QueryMode.Aggregate); +const isRawMode = isQueryMode(QueryMode.Raw); const validateAggControlValues = ( controls: ControlStateMapping, @@ -86,8 +86,8 @@ const queryMode: ControlConfig<'RadioButtonControl'> = { label: t('Query mode'), default: null, options: [ - [QueryMode.aggregate, QueryModeLabel[QueryMode.aggregate]], - [QueryMode.raw, QueryModeLabel[QueryMode.raw]], + [QueryMode.Aggregate, QueryModeLabel[QueryMode.Aggregate]], + [QueryMode.Raw, QueryModeLabel[QueryMode.Raw]], ], mapStateToProps: ({ controls }) => ({ value: getQueryMode(controls) }), rerender: ['all_columns', 'groupby', 'metrics', 'percent_metrics'], @@ -501,7 +501,7 @@ const config: ControlPanelConfig = { ? colnames .filter( (colname: string, index: number) => - coltypes[index] === GenericDataType.NUMERIC, + coltypes[index] === GenericDataType.Numeric, ) .map(colname => ({ value: colname, diff --git a/superset-frontend/plugins/plugin-chart-table/src/index.ts b/superset-frontend/plugins/plugin-chart-table/src/index.ts index 3d7b1dcea..ce250aa87 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/index.ts +++ b/superset-frontend/plugins/plugin-chart-table/src/index.ts @@ -32,9 +32,9 @@ export * from './types'; const metadata = new ChartMetadata({ behaviors: [ - Behavior.INTERACTIVE_CHART, - Behavior.DRILL_TO_DETAIL, - Behavior.DRILL_BY, + Behavior.InteractiveChart, + Behavior.DrillToDetail, + Behavior.DrillBy, ], category: t('Table'), canBeAnnotationTypes: ['EVENT', 'INTERVAL'], diff --git a/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts b/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts index e76201cac..c0eacfb51 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts @@ -62,7 +62,7 @@ const processDataRecords = memoizeOne(function processDataRecords( return data || []; } const timeColumns = columns.filter( - column => column.dataType === GenericDataType.TEMPORAL, + column => column.dataType === GenericDataType.Temporal, ); if (timeColumns.length > 0) { @@ -122,8 +122,8 @@ const processColumns = memoizeOne(function processColumns( isPercentMetric && verboseMap?.hasOwnProperty(key.replace('%', '')) ? `%${verboseMap[key.replace('%', '')]}` : verboseMap?.[key] || key; - const isTime = dataType === GenericDataType.TEMPORAL; - const isNumber = dataType === GenericDataType.NUMERIC; + const isTime = dataType === GenericDataType.Temporal; + const isNumber = dataType === GenericDataType.Numeric; const savedFormat = columnFormats?.[key]; const savedCurrency = currencyFormats?.[key]; const numberFormat = config.d3NumberFormat || savedFormat; @@ -172,7 +172,7 @@ const processColumns = memoizeOne(function processColumns( key, label, dataType, - isNumeric: dataType === GenericDataType.NUMERIC, + isNumeric: dataType === GenericDataType.Numeric, isMetric, isPercentMetric, formatter, @@ -257,7 +257,7 @@ const transformProps = ( } const data = processDataRecords(baseQuery?.data, columns); const totals = - showTotals && queryMode === QueryMode.aggregate + showTotals && queryMode === QueryMode.Aggregate ? totalQuery?.data[0] : undefined; const columnColorFormatters = @@ -266,7 +266,7 @@ const transformProps = ( return { height, width, - isRawRecords: queryMode === QueryMode.raw, + isRawRecords: queryMode === QueryMode.Raw, data, totals, columns, diff --git a/superset-frontend/plugins/plugin-chart-table/src/utils/formatValue.ts b/superset-frontend/plugins/plugin-chart-table/src/utils/formatValue.ts index 139f92336..43cddad0a 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/utils/formatValue.ts +++ b/superset-frontend/plugins/plugin-chart-table/src/utils/formatValue.ts @@ -60,7 +60,7 @@ export function formatColumnValue( value: DataRecordValue, ) { const { dataType, formatter, config = {} } = column; - const isNumber = dataType === GenericDataType.NUMERIC; + const isNumber = dataType === GenericDataType.Numeric; const smallNumberFormatter = config.d3SmallNumberFormat === undefined ? formatter diff --git a/superset-frontend/plugins/plugin-chart-table/test/buildQuery.test.ts b/superset-frontend/plugins/plugin-chart-table/test/buildQuery.test.ts index e196eae10..a86f7d181 100644 --- a/superset-frontend/plugins/plugin-chart-table/test/buildQuery.test.ts +++ b/superset-frontend/plugins/plugin-chart-table/test/buildQuery.test.ts @@ -30,7 +30,7 @@ describe('plugin-chart-table', () => { it('should add post-processing and ignore duplicate metrics', () => { const query = buildQuery({ ...basicFormData, - query_mode: QueryMode.aggregate, + query_mode: QueryMode.Aggregate, metrics: ['aaa', 'aaa'], percent_metrics: ['bbb', 'bbb'], }).queries[0]; @@ -49,7 +49,7 @@ describe('plugin-chart-table', () => { it('should not add metrics in raw records mode', () => { const query = buildQuery({ ...basicFormData, - query_mode: QueryMode.raw, + query_mode: QueryMode.Raw, columns: ['a'], metrics: ['aaa', 'aaa'], percent_metrics: ['bbb', 'bbb'], @@ -61,7 +61,7 @@ describe('plugin-chart-table', () => { it('should not add post-processing when there is no percent metric', () => { const query = buildQuery({ ...basicFormData, - query_mode: QueryMode.aggregate, + query_mode: QueryMode.Aggregate, metrics: ['aaa'], percent_metrics: [], }).queries[0]; @@ -72,7 +72,7 @@ describe('plugin-chart-table', () => { it('should not add post-processing in raw records mode', () => { const query = buildQuery({ ...basicFormData, - query_mode: QueryMode.raw, + query_mode: QueryMode.Raw, metrics: ['aaa'], columns: ['rawcol'], percent_metrics: ['ccc'], @@ -85,7 +85,7 @@ describe('plugin-chart-table', () => { const query = buildQuery({ ...basicFormData, groupby: ['col1'], - query_mode: QueryMode.aggregate, + query_mode: QueryMode.Aggregate, time_grain_sqla: TimeGranularity.MONTH, extra_form_data: { time_grain_sqla: TimeGranularity.QUARTER }, temporal_columns_lookup: { col1: true }, @@ -103,7 +103,7 @@ describe('plugin-chart-table', () => { ...basicFormData, time_grain_sqla: TimeGranularity.MONTH, groupby: ['col1'], - query_mode: QueryMode.aggregate, + query_mode: QueryMode.Aggregate, temporal_columns_lookup: { col1: true }, }).queries[0]; expect(query.columns?.[0]).toEqual({ diff --git a/superset-frontend/plugins/plugin-chart-table/test/testData.ts b/superset-frontend/plugins/plugin-chart-table/test/testData.ts index 1f255703f..24abc3381 100644 --- a/superset-frontend/plugins/plugin-chart-table/test/testData.ts +++ b/superset-frontend/plugins/plugin-chart-table/test/testData.ts @@ -96,10 +96,10 @@ const basic: TableChartProps = { ...basicQueryResult, colnames: ['__timestamp', 'name', 'sum__num', 'abc.com'], coltypes: [ - GenericDataType.TEMPORAL, - GenericDataType.STRING, - GenericDataType.NUMERIC, - GenericDataType.STRING, + GenericDataType.Temporal, + GenericDataType.String, + GenericDataType.Numeric, + GenericDataType.String, ], data: [ { @@ -165,9 +165,9 @@ const advanced: TableChartProps = { ...basicQueryResult, colnames: ['name', 'sum__num', '%pct_nice'], coltypes: [ - GenericDataType.STRING, - GenericDataType.NUMERIC, - GenericDataType.NUMERIC, + GenericDataType.String, + GenericDataType.Numeric, + GenericDataType.Numeric, ], data: [...(basic.queriesData[0].data || [])], }, @@ -178,14 +178,14 @@ const raw = { ...advanced, rawFormData: { ...advanced.rawFormData, - query_mode: QueryMode.raw, + query_mode: QueryMode.Raw, columns: ['num'], }, queriesData: [ { ...basicQueryResult, colnames: ['num'], - coltypes: [GenericDataType.NUMERIC], + coltypes: [GenericDataType.Numeric], data: [ { num: 1234, diff --git a/superset-frontend/spec/fixtures/mockDashboardInfo.js b/superset-frontend/spec/fixtures/mockDashboardInfo.js index b2f9f1183..4fd599ea3 100644 --- a/superset-frontend/spec/fixtures/mockDashboardInfo.js +++ b/superset-frontend/spec/fixtures/mockDashboardInfo.js @@ -38,5 +38,5 @@ export default { flash_messages: [], conf: { SUPERSET_WEBSERVER_TIMEOUT: 60 }, }, - filterBarOrientation: FilterBarOrientation.VERTICAL, + filterBarOrientation: FilterBarOrientation.Vertical, }; diff --git a/superset-frontend/spec/fixtures/mockNativeFilters.ts b/superset-frontend/spec/fixtures/mockNativeFilters.ts index 1ff78467d..070f48ab0 100644 --- a/superset-frontend/spec/fixtures/mockNativeFilters.ts +++ b/superset-frontend/spec/fixtures/mockNativeFilters.ts @@ -52,7 +52,7 @@ export const nativeFilters: NativeFiltersState = { enableEmptyFilter: false, inverseSelection: false, }, - type: NativeFilterType.NATIVE_FILTER, + type: NativeFilterType.NativeFilter, description: '', chartsInScope: [18], }, @@ -83,7 +83,7 @@ export const nativeFilters: NativeFiltersState = { enableEmptyFilter: false, inverseSelection: false, }, - type: NativeFilterType.NATIVE_FILTER, + type: NativeFilterType.NativeFilter, description: '2 letter code', chartsInScope: [18], }, diff --git a/superset-frontend/spec/fixtures/mockStore.js b/superset-frontend/spec/fixtures/mockStore.js index 1689555dd..df464f7b7 100644 --- a/superset-frontend/spec/fixtures/mockStore.js +++ b/superset-frontend/spec/fixtures/mockStore.js @@ -127,7 +127,7 @@ export const stateWithNativeFilters = { }, }, dashboardInfo: { - filterBarOrientation: FilterBarOrientation.VERTICAL, + filterBarOrientation: FilterBarOrientation.Vertical, }, }; @@ -160,7 +160,7 @@ export const stateWithoutNativeFilters = { }, dashboardInfo: { dash_edit_perm: true, - filterBarOrientation: FilterBarOrientation.VERTICAL, + filterBarOrientation: FilterBarOrientation.Vertical, metadata: { native_filter_configuration: [], }, diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index e93538959..9cfd76e2e 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -108,8 +108,8 @@ export const addDangerToast = addDangerToastAction; export const addWarningToast = addWarningToastAction; export const CtasEnum = { - TABLE: 'TABLE', - VIEW: 'VIEW', + Table: 'TABLE', + View: 'VIEW', }; const ERR_MSG_CANT_LOAD_QUERY = t("The query couldn't be loaded"); @@ -513,7 +513,7 @@ export function migrateQueryEditorFromLocalStorage( export function addQueryEditor(queryEditor) { return function (dispatch) { - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? SupersetClient.post({ endpoint: '/tabstateview/', postPayload: { queryEditor }, @@ -562,7 +562,7 @@ export function addNewQueryEditor() { ...(unsavedQueryEditor.id === activeQueryEditor?.id && unsavedQueryEditor), }; - const warning = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const warning = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? '' : t( '-- Note: Unless you save your query, these tabs will NOT persist if you clear your cookies or change browsers.\n\n', @@ -613,7 +613,7 @@ export function cloneQueryToNewTab(query, autorun) { export function setActiveQueryEditor(queryEditor) { return function (dispatch) { - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? SupersetClient.post({ endpoint: encodeURI(`/tabstateview/${queryEditor.id}/activate`), }) @@ -676,7 +676,7 @@ export function setTables(tableSchemas) { export function switchQueryEditor(queryEditor, displayLimit) { return function (dispatch) { if ( - isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) && + isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) && queryEditor && !queryEditor.loaded ) { @@ -735,7 +735,7 @@ export function toggleLeftBar(queryEditor) { export function removeQueryEditor(queryEditor) { return function (dispatch) { - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? SupersetClient.delete({ endpoint: encodeURI(`/tabstateview/${queryEditor.id}`), }) @@ -768,7 +768,7 @@ export function removeAllOtherQueryEditors(queryEditor) { export function removeQuery(query) { return function (dispatch) { - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? SupersetClient.delete({ endpoint: encodeURI( `/tabstateview/${query.sqlEditorId}/query/${query.id}`, @@ -843,7 +843,7 @@ export function saveQuery(query, clientId) { export const addSavedQueryToTabState = (queryEditor, savedQuery) => dispatch => { - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? SupersetClient.put({ endpoint: `/tabstateview/${queryEditor.id}`, postPayload: { saved_query_id: savedQuery.remoteId }, @@ -893,7 +893,7 @@ export function queryEditorSetAndSaveSql(targetQueryEditor, sql, queryId) { const queryEditor = getUpToDateQuery(getState(), targetQueryEditor); // saved query and set tab state use this action dispatch(queryEditorSetSql(queryEditor, sql, queryId)); - if (isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)) { + if (isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)) { return SupersetClient.put({ endpoint: encodeURI(`/tabstateview/${queryEditor.id}`), postPayload: { sql, latest_query_id: queryId }, @@ -1016,7 +1016,7 @@ export function runTablePreviewQuery(newTable) { export function syncTable(table, tableMetadata) { return function (dispatch) { - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? SupersetClient.post({ endpoint: encodeURI('/tableschemaview/'), postPayload: { table: { ...tableMetadata, ...table } }, @@ -1075,7 +1075,7 @@ export function reFetchQueryResults(query) { export function expandTable(table) { return function (dispatch) { - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? SupersetClient.post({ endpoint: encodeURI(`/tableschemaview/${table.id}/expanded`), postPayload: { expanded: true }, @@ -1099,7 +1099,7 @@ export function expandTable(table) { export function collapseTable(table) { return function (dispatch) { - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? SupersetClient.post({ endpoint: encodeURI(`/tableschemaview/${table.id}/expanded`), postPayload: { expanded: false }, @@ -1124,7 +1124,7 @@ export function collapseTable(table) { export function removeTables(tables) { return function (dispatch) { const tablesToRemove = tables?.filter(Boolean) ?? []; - const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) + const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) ? Promise.all( tablesToRemove.map(table => SupersetClient.delete({ diff --git a/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx b/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx index 0599793d8..764884614 100644 --- a/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx @@ -24,38 +24,38 @@ import { detectOS } from 'src/utils/common'; const userOS = detectOS(); export enum KeyboardShortcut { - CTRL_R = 'ctrl+r', - CTRL_ENTER = 'ctrl+enter', - CTRL_SHIFT_ENTER = 'ctrl+shift+enter', - CTRL_P = 'ctrl+p', - CTRL_Q = 'ctrl+q', - CTRL_E = 'ctrl+e', - CTRL_T = 'ctrl+t', - CTRL_X = 'ctrl+x', - ALT_ENTER = 'alt+enter', - CMD_F = 'cmd+f', - CMD_OPT_F = 'cmd+opt+f', - CTRL_F = 'ctrl+f', - CTRL_H = 'ctrl+h', - CTRL_SHIFT_F = 'ctrl+shift+f', + CtrlR = 'ctrl+r', + CtrlEnter = 'ctrl+enter', + CtrlShiftEnter = 'ctrl+shift+enter', + CtrlP = 'ctrl+p', + CtrlQ = 'ctrl+q', + CtrlE = 'ctrl+e', + CtrlT = 'ctrl+t', + CtrlX = 'ctrl+x', + AltEnter = 'alt+enter', + CmdF = 'cmd+f', + CmdOptF = 'cmd+opt+f', + CtrlF = 'ctrl+f', + CtrlH = 'ctrl+h', + CtrlShiftF = 'ctrl+shift+f', } export const KEY_MAP = { - [KeyboardShortcut.CTRL_R]: t('Run query'), - [KeyboardShortcut.CTRL_ENTER]: t('Run query'), - [KeyboardShortcut.ALT_ENTER]: t('Run query'), - [KeyboardShortcut.CTRL_SHIFT_ENTER]: t('Run current query'), - [KeyboardShortcut.CTRL_X]: userOS === 'MacOS' ? t('Stop query') : undefined, - [KeyboardShortcut.CTRL_E]: userOS !== 'MacOS' ? t('Stop query') : undefined, - [KeyboardShortcut.CTRL_Q]: userOS === 'Windows' ? t('New tab') : undefined, - [KeyboardShortcut.CTRL_T]: userOS !== 'Windows' ? t('New tab') : undefined, - [KeyboardShortcut.CTRL_P]: t('Previous Line'), - [KeyboardShortcut.CTRL_SHIFT_F]: t('Format SQL'), + [KeyboardShortcut.CtrlR]: t('Run query'), + [KeyboardShortcut.CtrlEnter]: t('Run query'), + [KeyboardShortcut.AltEnter]: t('Run query'), + [KeyboardShortcut.CtrlShiftEnter]: t('Run current query'), + [KeyboardShortcut.CtrlX]: userOS === 'MacOS' ? t('Stop query') : undefined, + [KeyboardShortcut.CtrlE]: userOS !== 'MacOS' ? t('Stop query') : undefined, + [KeyboardShortcut.CtrlQ]: userOS === 'Windows' ? t('New tab') : undefined, + [KeyboardShortcut.CtrlT]: userOS !== 'Windows' ? t('New tab') : undefined, + [KeyboardShortcut.CtrlP]: t('Previous Line'), + [KeyboardShortcut.CtrlShiftF]: t('Format SQL'), // default ace editor shortcuts - [KeyboardShortcut.CMD_F]: userOS === 'MacOS' ? t('Find') : undefined, - [KeyboardShortcut.CTRL_F]: userOS !== 'MacOS' ? t('Find') : undefined, - [KeyboardShortcut.CMD_OPT_F]: userOS === 'MacOS' ? t('Replace') : undefined, - [KeyboardShortcut.CTRL_H]: userOS !== 'MacOS' ? t('Replace') : undefined, + [KeyboardShortcut.CmdF]: userOS === 'MacOS' ? t('Find') : undefined, + [KeyboardShortcut.CtrlF]: userOS !== 'MacOS' ? t('Find') : undefined, + [KeyboardShortcut.CmdOptF]: userOS === 'MacOS' ? t('Replace') : undefined, + [KeyboardShortcut.CtrlH]: userOS !== 'MacOS' ? t('Replace') : undefined, }; const KeyMapByCommand = Object.entries(KEY_MAP).reduce( diff --git a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx index 58e55a1df..358802d54 100644 --- a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx +++ b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx @@ -69,11 +69,11 @@ import ExploreResultsButton from '../ExploreResultsButton'; import HighlightedSql from '../HighlightedSql'; import QueryStateLabel from '../QueryStateLabel'; -enum LIMITING_FACTOR { - QUERY = 'QUERY', - QUERY_AND_DROPDOWN = 'QUERY_AND_DROPDOWN', - DROPDOWN = 'DROPDOWN', - NOT_LIMITED = 'NOT_LIMITED', +enum LimitingFactor { + Query = 'QUERY', + QueryAndDropdown = 'QUERY_AND_DROPDOWN', + Dropdown = 'DROPDOWN', + NotLimited = 'NOT_LIMITED', } export interface ResultSetProps { @@ -338,23 +338,22 @@ const ResultSet = ({ ), }; const shouldUseDefaultDropdownAlert = - limit === defaultQueryLimit && - limitingFactor === LIMITING_FACTOR.DROPDOWN; + limit === defaultQueryLimit && limitingFactor === LimitingFactor.Dropdown; - if (limitingFactor === LIMITING_FACTOR.QUERY && csv) { + if (limitingFactor === LimitingFactor.Query && csv) { limitMessage = t( 'The number of rows displayed is limited to %(rows)d by the query', { rows }, ); } else if ( - limitingFactor === LIMITING_FACTOR.DROPDOWN && + limitingFactor === LimitingFactor.Dropdown && !shouldUseDefaultDropdownAlert ) { limitMessage = t( 'The number of rows displayed is limited to %(rows)d by the limit dropdown.', { rows }, ); - } else if (limitingFactor === LIMITING_FACTOR.QUERY_AND_DROPDOWN) { + } else if (limitingFactor === LimitingFactor.QueryAndDropdown) { limitMessage = t( 'The number of rows displayed is limited to %(rows)d by the query and limit dropdown.', { rows }, @@ -444,8 +443,8 @@ const ResultSet = ({ let trackingUrl; if ( query.trackingUrl && - query.state !== QueryState.SUCCESS && - query.state !== QueryState.FETCHING + query.state !== QueryState.Success && + query.state !== QueryState.Fetching ) { trackingUrl = ( @@ -470,11 +469,11 @@ const ResultSet = ({ ); } - if (query.state === QueryState.STOPPED) { + if (query.state === QueryState.Stopped) { return ; } - if (query.state === QueryState.FAILED) { + if (query.state === QueryState.Failed) { return ( - {newOrOverwrite === DatasetRadioState.SAVE_NEW && ( + {newOrOverwrite === DatasetRadioState.SaveNew && ( diff --git a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx index a123576c3..8f4cde1a6 100644 --- a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx +++ b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx @@ -92,7 +92,7 @@ const ShareSqlLabQuery = ({ } }; const getCopyUrl = (callback: Function) => { - if (isFeatureEnabled(FeatureFlag.SHARE_QUERIES_VIA_KV_STORE)) { + if (isFeatureEnabled(FeatureFlag.ShareQueriesViaKvStore)) { return getCopyUrlForKvStore(callback); } return getCopyUrlForSavedQuery(callback); @@ -116,7 +116,7 @@ const ShareSqlLabQuery = ({ }; const canShare = - !!remoteId || isFeatureEnabled(FeatureFlag.SHARE_QUERIES_VIA_KV_STORE); + !!remoteId || isFeatureEnabled(FeatureFlag.ShareQueriesViaKvStore); return ( <> diff --git a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx index 38a20f9f6..9aa0b7575 100644 --- a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx +++ b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx @@ -164,7 +164,7 @@ const SouthPane = ({ latestQuery.errors = latestQuery.extra.errors; } if ( - isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) && + isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) && latestQuery.state === 'success' && !latestQuery.resultsKey && !latestQuery.results diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx index 0e6a4845d..821325368 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx @@ -279,7 +279,7 @@ const SqlEditor: React.FC = ({ queryEditor.southPercent || INITIAL_SOUTH_PERCENT, ); const [autocompleteEnabled, setAutocompleteEnabled] = useState( - getItem(LocalStorageKeys.sqllab__is_autocomplete_enabled, true), + getItem(LocalStorageKeys.SqllabIsAutocompleteEnabled, true), ); const [showCreateAsModal, setShowCreateAsModal] = useState(false); const [createAs, setCreateAs] = useState(''); @@ -291,7 +291,7 @@ const SqlEditor: React.FC = ({ const SqlFormExtension = extensionsRegistry.get('sqleditor.extension.form'); const startQuery = useCallback( - (ctasArg = false, ctas_method = CtasEnum.TABLE) => { + (ctasArg = false, ctas_method = CtasEnum.Table) => { if (!database) { return; } @@ -348,8 +348,8 @@ const SqlEditor: React.FC = ({ return [ { name: 'runQuery1', - key: KeyboardShortcut.CTRL_R, - descr: KEY_MAP[KeyboardShortcut.CTRL_R], + key: KeyboardShortcut.CtrlR, + descr: KEY_MAP[KeyboardShortcut.CtrlR], func: () => { if (queryEditor.sql.trim() !== '') { startQuery(); @@ -358,8 +358,8 @@ const SqlEditor: React.FC = ({ }, { name: 'runQuery2', - key: KeyboardShortcut.CTRL_ENTER, - descr: KEY_MAP[KeyboardShortcut.CTRL_ENTER], + key: KeyboardShortcut.CtrlEnter, + descr: KEY_MAP[KeyboardShortcut.CtrlEnter], func: () => { if (queryEditor.sql.trim() !== '') { startQuery(); @@ -370,12 +370,12 @@ const SqlEditor: React.FC = ({ name: 'newTab', ...(userOS === 'Windows' ? { - key: KeyboardShortcut.CTRL_Q, - descr: KEY_MAP[KeyboardShortcut.CTRL_Q], + key: KeyboardShortcut.CtrlQ, + descr: KEY_MAP[KeyboardShortcut.CtrlQ], } : { - key: KeyboardShortcut.CTRL_T, - descr: KEY_MAP[KeyboardShortcut.CTRL_T], + key: KeyboardShortcut.CtrlT, + descr: KEY_MAP[KeyboardShortcut.CtrlT], }), func: () => { dispatch(addNewQueryEditor()); @@ -385,19 +385,19 @@ const SqlEditor: React.FC = ({ name: 'stopQuery', ...(userOS === 'MacOS' ? { - key: KeyboardShortcut.CTRL_X, - descr: KEY_MAP[KeyboardShortcut.CTRL_X], + key: KeyboardShortcut.CtrlX, + descr: KEY_MAP[KeyboardShortcut.CtrlX], } : { - key: KeyboardShortcut.CTRL_E, - descr: KEY_MAP[KeyboardShortcut.CTRL_E], + key: KeyboardShortcut.CtrlE, + descr: KEY_MAP[KeyboardShortcut.CtrlE], }), func: stopQuery, }, { name: 'formatQuery', - key: KeyboardShortcut.CTRL_SHIFT_F, - descr: KEY_MAP[KeyboardShortcut.CTRL_SHIFT_F], + key: KeyboardShortcut.CtrlShiftF, + descr: KEY_MAP[KeyboardShortcut.CtrlShiftF], func: () => { formatCurrentQuery(); }, @@ -413,8 +413,8 @@ const SqlEditor: React.FC = ({ ...getHotkeyConfig(), { name: 'runQuery3', - key: KeyboardShortcut.CTRL_SHIFT_ENTER, - descr: KEY_MAP[KeyboardShortcut.CTRL_SHIFT_ENTER], + key: KeyboardShortcut.CtrlShiftEnter, + descr: KEY_MAP[KeyboardShortcut.CtrlShiftEnter], func: (editor: AceEditor['editor']) => { if (!editor.getValue().trim()) { return; @@ -471,8 +471,8 @@ const SqlEditor: React.FC = ({ if (userOS === 'MacOS') { base.push({ name: 'previousLine', - key: KeyboardShortcut.CTRL_P, - descr: KEY_MAP[KeyboardShortcut.CTRL_P], + key: KeyboardShortcut.CtrlP, + descr: KEY_MAP[KeyboardShortcut.CtrlP], func: editor => { editor.navigateUp(); }, @@ -589,21 +589,18 @@ const SqlEditor: React.FC = ({ }; const handleToggleAutocompleteEnabled = () => { - setItem( - LocalStorageKeys.sqllab__is_autocomplete_enabled, - !autocompleteEnabled, - ); + setItem(LocalStorageKeys.SqllabIsAutocompleteEnabled, !autocompleteEnabled); setAutocompleteEnabled(!autocompleteEnabled); }; const createTableAs = () => { - startQuery(true, CtasEnum.TABLE); + startQuery(true, CtasEnum.Table); setShowCreateAsModal(false); setCtas(''); }; const createViewAs = () => { - startQuery(true, CtasEnum.VIEW); + startQuery(true, CtasEnum.View); setShowCreateAsModal(false); setCtas(''); }; @@ -628,7 +625,7 @@ const SqlEditor: React.FC = ({ onChange={handleToggleAutocompleteEnabled} />{' '} - {isFeatureEnabled(FeatureFlag.ENABLE_TEMPLATE_PROCESSING) && ( + {isFeatureEnabled(FeatureFlag.EnableTemplateProcessing) && ( = ({ { setShowCreateAsModal(true); - setCreateAs(CtasEnum.TABLE); + setCreateAs(CtasEnum.Table); }} key="1" > @@ -689,7 +686,7 @@ const SqlEditor: React.FC = ({ { setShowCreateAsModal(true); - setCreateAs(CtasEnum.VIEW); + setCreateAs(CtasEnum.View); }} key="2" > @@ -712,7 +709,7 @@ const SqlEditor: React.FC = ({ overlayCreateAsMenu={showMenu ? runMenuBtn : null} /> - {isFeatureEnabled(FeatureFlag.ESTIMATE_QUERY_COST) && + {isFeatureEnabled(FeatureFlag.EstimateQueryCost) && database?.allows_cost_estimate && ( = ({ }; const createViewModalTitle = - createAs === CtasEnum.VIEW ? 'CREATE VIEW AS' : 'CREATE TABLE AS'; + createAs === CtasEnum.View ? 'CREATE VIEW AS' : 'CREATE TABLE AS'; const createModalPlaceHolder = - createAs === CtasEnum.VIEW + createAs === CtasEnum.View ? t('Specify name to CREATE VIEW AS schema in: public') : t('Specify name to CREATE TABLE AS schema in: public'); @@ -869,7 +866,7 @@ const SqlEditor: React.FC = ({ - {createAs === CtasEnum.TABLE && ( + {createAs === CtasEnum.Table && ( )} - {createAs === CtasEnum.VIEW && ( + {createAs === CtasEnum.View && (