mirror of
https://github.com/apache/superset.git
synced 2026-05-10 02:15:50 +00:00
* 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
137 lines
4.1 KiB
TypeScript
137 lines
4.1 KiB
TypeScript
/**
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
* or more contributor license agreements. See the NOTICE file
|
|
* distributed with this work for additional information
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
* to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance
|
|
* with the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
import React from 'react';
|
|
import { t, validateNonEmpty } from '@superset-ui/core';
|
|
import {
|
|
columnChoices,
|
|
ColumnOption,
|
|
ColumnMeta,
|
|
ControlPanelConfig,
|
|
ControlState,
|
|
formatSelectOptionsForRange,
|
|
sections,
|
|
SelectControlConfig,
|
|
} from '@superset-ui/chart-controls';
|
|
|
|
const config: ControlPanelConfig = {
|
|
controlPanelSections: [
|
|
sections.legacyRegularTime,
|
|
{
|
|
label: t('Event definition'),
|
|
controlSetRows: [
|
|
['entity'],
|
|
[
|
|
{
|
|
name: 'all_columns_x',
|
|
config: {
|
|
type: 'SelectControl',
|
|
label: t('Event Names'),
|
|
description: t('Columns to display'),
|
|
mapStateToProps: state => ({
|
|
choices: columnChoices(state?.datasource),
|
|
}),
|
|
// choices is from `mapStateToProps`
|
|
default: (control: ControlState) =>
|
|
control.choices?.[0]?.[0] || null,
|
|
validators: [validateNonEmpty],
|
|
},
|
|
},
|
|
],
|
|
['row_limit'],
|
|
[
|
|
{
|
|
name: 'order_by_entity',
|
|
config: {
|
|
type: 'CheckboxControl',
|
|
label: t('Order by entity id'),
|
|
description: t(
|
|
'Important! Select this if the table is not already sorted by entity id, ' +
|
|
'else there is no guarantee that all events for each entity are returned.',
|
|
),
|
|
default: true,
|
|
},
|
|
},
|
|
],
|
|
[
|
|
{
|
|
name: 'min_leaf_node_event_count',
|
|
config: {
|
|
type: 'SelectControl',
|
|
freeForm: false,
|
|
label: t('Minimum leaf node event count'),
|
|
default: 1,
|
|
choices: formatSelectOptionsForRange(1, 10),
|
|
description: t(
|
|
'Leaf nodes that represent fewer than this number of events will be initially ' +
|
|
'hidden in the visualization',
|
|
),
|
|
},
|
|
},
|
|
],
|
|
],
|
|
},
|
|
{
|
|
label: t('Query'),
|
|
expanded: true,
|
|
controlSetRows: [['adhoc_filters']],
|
|
},
|
|
{
|
|
label: t('Additional metadata'),
|
|
controlSetRows: [
|
|
[
|
|
{
|
|
name: 'all_columns',
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
config: {
|
|
type: 'SelectControl',
|
|
multi: true,
|
|
label: t('Metadata'),
|
|
default: [],
|
|
description: t('Select any columns for metadata inspection'),
|
|
optionRenderer: c => <ColumnOption showType column={c} />,
|
|
valueRenderer: c => <ColumnOption column={c} />,
|
|
valueKey: 'column_name',
|
|
allowAll: true,
|
|
mapStateToProps: state => ({
|
|
options: state.datasource?.columns || [],
|
|
}),
|
|
commaChoosesOption: false,
|
|
freeForm: true,
|
|
} as SelectControlConfig<ColumnMeta>,
|
|
},
|
|
],
|
|
],
|
|
},
|
|
],
|
|
controlOverrides: {
|
|
entity: {
|
|
label: t('Entity ID'),
|
|
description: t('e.g., a "user id" column'),
|
|
},
|
|
row_limit: {
|
|
label: t('Max Events'),
|
|
description: t(
|
|
'The maximum number of events to return, equivalent to the number of rows',
|
|
),
|
|
},
|
|
},
|
|
};
|
|
|
|
export default config;
|