mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat(explore): Frontend implementation of dataset creation from infobox (#19855)
* Frontend implementation of create dataset from infobox * Fixed sl_dataset type * Fix test * Fixed sl_dataset type (forgot to save) * RTL testing * Adjusted styling/text on infobox and save dataset modal * Appease lint * Make infobox invisible and fix tests * Remove unnecessary placeholder * Move types to sql lab * Moved logic into save dataset modal * Change DatasourceMeta type to Dataset * Add ExploreDatasource union type to save dataset modal * Get user info from redux inside save dataset modal * Addressed comments * Adjusting to new query type * Fixed save dataset in explore and union type * Added testing * Defined d for queries * Remove dataset from SaveDatasetModal * Clarify useSelector parameter * Fix dndControls union type * Fix shared-controls union type * Fix controlPanel union type * Move ExploreRootState to explore type file * Remove unnecessary testing playground * Move datasource type check in DatasourcePanel to a function * Make all sqllab Query imports reference @superset-ui/core Query type * Deconstruct query props in ResultSet * Fix union type in /legacy-plugin-chart-heatmap/src/controlPanel * Change SaveDatasetModal tests to RTL * Cleaned datasourceTypeCheck * Fix infobox styling * Fix SaveDatasetModal test * Fix query fixture in sqllab and Query type in SaveDatasetModal test * Fix Query type and make test query fixture * Added columns to Query type, separated results property, created QueryResponse union type, and fixed all types affected * Fixed a couple missed broken types * Added ExploreDatasource to SqlLab type file * Removed unneeded Query import from DatasourcePanel * Address PR comments * Fix columnChoices * Fix all incorrect column property checks * Fix logic on dndGroupByControl * Dry up savedMetrics type check * Fixed TIME_COLUMN_OPTION * Dried savedMetrics type check even further * Change savedMetricsTypeCheck to defineSavedMetrics * Change datasourceTypeCheck to isValidDatasourceType * Fix Query path in groupByControl * dnd_granularity_sqla now sorts Query types with is_dttm at the top * Fixed/cleaned query sort * Add sortedQueryColumns and proper optional chaining to granularity_sqla * Move testQuery to core-ui, add test coverage for Queries in columnChoices * Moved DEFAULT_METRICS to core-ui and wrote a test for defineSavedMetrics * Add license and clean dataset test object * Change DatasourceType.Dataset to dataset
This commit is contained in:
committed by
GitHub
parent
d1c24f81f2
commit
ba0c37d3df
@@ -44,6 +44,9 @@ import {
|
||||
ExtraControlProps,
|
||||
ControlState,
|
||||
emitFilterControl,
|
||||
Dataset,
|
||||
ColumnMeta,
|
||||
defineSavedMetrics,
|
||||
} from '@superset-ui/chart-controls';
|
||||
|
||||
import i18n from './i18n';
|
||||
@@ -127,12 +130,12 @@ const dnd_all_columns: typeof sharedControls.groupby = {
|
||||
default: [],
|
||||
mapStateToProps({ datasource, controls }, controlState) {
|
||||
const newState: ExtraControlProps = {};
|
||||
if (datasource) {
|
||||
const options = datasource.columns;
|
||||
if (datasource?.columns[0]?.hasOwnProperty('column_name')) {
|
||||
const options = (datasource as Dataset).columns;
|
||||
newState.options = Object.fromEntries(
|
||||
options.map(option => [option.column_name, option]),
|
||||
options.map((option: ColumnMeta) => [option.column_name, option]),
|
||||
);
|
||||
}
|
||||
} else newState.options = datasource?.columns;
|
||||
newState.queryMode = getQueryMode(controls);
|
||||
newState.externalValidationErrors =
|
||||
isRawMode({ controls }) && ensureIsArray(controlState.value).length === 0
|
||||
@@ -155,7 +158,7 @@ const percent_metrics: typeof sharedControls.metrics = {
|
||||
resetOnHide: false,
|
||||
mapStateToProps: ({ datasource, controls }, controlState) => ({
|
||||
columns: datasource?.columns || [],
|
||||
savedMetrics: datasource?.metrics || [],
|
||||
savedMetrics: defineSavedMetrics(datasource),
|
||||
datasource,
|
||||
datasourceType: datasource?.type,
|
||||
queryMode: getQueryMode(controls),
|
||||
@@ -229,8 +232,12 @@ const config: ControlPanelConfig = {
|
||||
{ controls, datasource, form_data }: ControlPanelState,
|
||||
controlState: ControlState,
|
||||
) => ({
|
||||
columns: datasource?.columns.filter(c => c.filterable) || [],
|
||||
savedMetrics: datasource?.metrics || [],
|
||||
columns: datasource?.columns[0]?.hasOwnProperty('filterable')
|
||||
? (datasource as Dataset)?.columns?.filter(
|
||||
(c: ColumnMeta) => c.filterable,
|
||||
)
|
||||
: datasource?.columns,
|
||||
savedMetrics: defineSavedMetrics(datasource),
|
||||
// current active adhoc metrics
|
||||
selectedMetrics:
|
||||
form_data.metrics ||
|
||||
@@ -280,7 +287,9 @@ const config: ControlPanelConfig = {
|
||||
multi: true,
|
||||
default: [],
|
||||
mapStateToProps: ({ datasource }) => ({
|
||||
choices: datasource?.order_by_choices || [],
|
||||
choices: datasource?.hasOwnProperty('order_by_choices')
|
||||
? (datasource as Dataset)?.order_by_choices
|
||||
: datasource?.columns || [],
|
||||
}),
|
||||
visibility: isRawMode,
|
||||
resetOnHide: false,
|
||||
@@ -505,7 +514,11 @@ const config: ControlPanelConfig = {
|
||||
return true;
|
||||
},
|
||||
mapStateToProps(explore, _, chart) {
|
||||
const verboseMap = explore?.datasource?.verbose_map ?? {};
|
||||
const verboseMap = explore?.datasource?.hasOwnProperty(
|
||||
'verbose_map',
|
||||
)
|
||||
? (explore?.datasource as Dataset)?.verbose_map
|
||||
: explore?.datasource?.columns ?? {};
|
||||
const { colnames, coltypes } =
|
||||
chart?.queriesResponse?.[0] ?? {};
|
||||
const numericColumns =
|
||||
|
||||
Reference in New Issue
Block a user