mirror of https://github.com/apache/superset.git
feat(explore): new datasets have autocomplete filters enabled if UX_BETA is set (#15864)
* feat(explore): new datasets have autocomplete filters enabled if UX_BETA is set * Lint fix * Set autocomplete to True in example datasets * Use "IN" as a default operator in dnd filters * Default operator only if UX_BETA enabled
This commit is contained in:
parent
019e74652d
commit
3f5237a3c1
|
@ -17,12 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { logging, SupersetClient, t, Metric } from '@superset-ui/core';
|
||||
import {
|
||||
FeatureFlag,
|
||||
isFeatureEnabled,
|
||||
logging,
|
||||
Metric,
|
||||
SupersetClient,
|
||||
t,
|
||||
} from '@superset-ui/core';
|
||||
import { ColumnMeta } from '@superset-ui/chart-controls';
|
||||
import { Tooltip } from 'src/components/Tooltip';
|
||||
import {
|
||||
Operators,
|
||||
OPERATOR_ENUM_TO_OPERATOR_TYPE,
|
||||
Operators,
|
||||
} from 'src/explore/constants';
|
||||
import { OptionSortType } from 'src/explore/types';
|
||||
import {
|
||||
|
@ -304,9 +311,14 @@ export const DndFilterSelect = (props: DndFilterSelectProps) => {
|
|||
sqlExpression: (droppedItem as AdhocMetric)?.translateToSql(),
|
||||
});
|
||||
}
|
||||
return new AdhocFilter({
|
||||
const config: Partial<AdhocFilter> = {
|
||||
subject: (droppedItem as ColumnMeta)?.column_name,
|
||||
});
|
||||
};
|
||||
if (isFeatureEnabled(FeatureFlag.UX_BETA)) {
|
||||
config.operator = OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.IN].operation;
|
||||
config.operatorId = Operators.IN;
|
||||
}
|
||||
return new AdhocFilter(config);
|
||||
}, [droppedItem]);
|
||||
|
||||
return (
|
||||
|
|
|
@ -427,7 +427,7 @@ const AdhocFilterEditPopoverSimpleTabContent: React.FC<Props> = props => {
|
|||
>
|
||||
{suggestions.map((suggestion: string) => (
|
||||
<Select.Option value={suggestion} key={suggestion}>
|
||||
{suggestion}
|
||||
{String(suggestion)}
|
||||
</Select.Option>
|
||||
))}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ from sqlalchemy import and_, Boolean, Column, Integer, String, Text
|
|||
from sqlalchemy.ext.declarative import declared_attr
|
||||
from sqlalchemy.orm import foreign, Query, relationship, RelationshipProperty, Session
|
||||
|
||||
from superset import security_manager
|
||||
from superset import is_feature_enabled, security_manager
|
||||
from superset.constants import NULL_STRING
|
||||
from superset.models.helpers import AuditMixinNullable, ImportExportMixin, QueryResult
|
||||
from superset.models.slice import Slice
|
||||
|
@ -103,7 +103,7 @@ class BaseDatasource(
|
|||
description = Column(Text)
|
||||
default_endpoint = Column(Text)
|
||||
is_featured = Column(Boolean, default=False) # TODO deprecating
|
||||
filter_select_enabled = Column(Boolean, default=False)
|
||||
filter_select_enabled = Column(Boolean, default=is_feature_enabled("UX_BETA"))
|
||||
offset = Column(Integer, default=0)
|
||||
cache_timeout = Column(Integer)
|
||||
params = Column(String(1000))
|
||||
|
|
|
@ -59,6 +59,7 @@ def load_bart_lines(only_metadata: bool = False, force: bool = False) -> None:
|
|||
tbl = table(table_name=tbl_name)
|
||||
tbl.description = "BART lines"
|
||||
tbl.database = database
|
||||
tbl.filter_select_enabled = True
|
||||
db.session.merge(tbl)
|
||||
db.session.commit()
|
||||
tbl.fetch_metadata()
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: ''
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: d95a2865-53ce-1f82-a53d-8e3c89331469
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: null
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 3e8130eb-0831-d568-b531-c3ce6d68d3d8
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: null
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: f7db6d45-7056-f395-d24a-6c805fb4c97d
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: null
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: e8623bb9-5e00-f531-506a-19607f5f8005
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: ''
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 974b7a1c-22ea-49cb-9214-97b7dbd511e0
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: ''
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 0bd5d01c-b7d8-471b-b3a5-366ce6c920d4
|
||||
|
|
|
@ -25,7 +25,7 @@ sql: SELECT c.name AS channel_name, u.name AS member_name FROM channel_members c
|
|||
JOIN channels c ON cm.channel_id = c.id JOIN users u ON cm.user_id = u.id
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 3d9c0054-b31b-4102-92de-b1ef9f9e5e77
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: null
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: e032c69e-716e-d700-eff7-07800d0f9989
|
||||
|
|
|
@ -25,7 +25,7 @@ sql: SELECT m.ts, c.name, m.text FROM messages m JOIN channels c ON m.channel_id
|
|||
c.id
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 6e533506-fce6-4f6a-b116-d139df6dbdea
|
||||
|
|
|
@ -25,7 +25,7 @@ sql: SELECT date, total_membership - lag(total_membership) OVER (ORDER BY date)
|
|||
new_members FROM exported_stats
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 9dd99cda-ff6b-4575-9a74-684d06e871ab
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: null
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: d7438be6-6078-17dd-cf9a-56f0ef546c80
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: null
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: a6771c73-96fc-44c6-8b6e-9d303955ea48
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: null
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 7195db6b-2d17-7619-b7c7-26b15378df8c
|
||||
|
|
|
@ -28,7 +28,7 @@ sql: 'SELECT uc1.name as channel_1, uc2.name as channel_2, count(*) AS cnt
|
|||
HAVING uc1.name <> uc2.name'
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 473d6113-b44a-48d8-a6ae-e0ef7e2aebb0
|
||||
|
|
|
@ -24,7 +24,7 @@ schema: null
|
|||
sql: null
|
||||
params: null
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 29b18573-c9d6-40bc-b8cb-f70c9a1b6244
|
||||
|
|
|
@ -27,7 +27,7 @@ params:
|
|||
database_name: examples
|
||||
import_time: 1606677834
|
||||
template_params: null
|
||||
filter_select_enabled: false
|
||||
filter_select_enabled: true
|
||||
fetch_values_predicate: null
|
||||
extra: null
|
||||
uuid: 53d47c0c-c03d-47f0-b9ac-81225f808283
|
||||
|
|
|
@ -79,6 +79,7 @@ def load_country_map_data(only_metadata: bool = False, force: bool = False) -> N
|
|||
obj = table(table_name=tbl_name)
|
||||
obj.main_dttm_col = "dttm"
|
||||
obj.database = database
|
||||
obj.filter_select_enabled = True
|
||||
if not any(col.metric_name == "avg__2004" for col in obj.metrics):
|
||||
col = str(column("2004").compile(db.engine))
|
||||
obj.metrics.append(SqlMetric(metric_name="avg__2004", expression=f"AVG({col})"))
|
||||
|
|
|
@ -63,6 +63,7 @@ def load_energy(
|
|||
tbl = table(table_name=tbl_name)
|
||||
tbl.description = "Energy consumption"
|
||||
tbl.database = database
|
||||
tbl.filter_select_enabled = True
|
||||
|
||||
if not any(col.metric_name == "sum__value" for col in tbl.metrics):
|
||||
col = str(column("value").compile(db.engine))
|
||||
|
|
|
@ -63,6 +63,7 @@ def load_flights(only_metadata: bool = False, force: bool = False) -> None:
|
|||
tbl = table(table_name=tbl_name)
|
||||
tbl.description = "Random set of flights in the US"
|
||||
tbl.database = database
|
||||
tbl.filter_select_enabled = True
|
||||
db.session.merge(tbl)
|
||||
db.session.commit()
|
||||
tbl.fetch_metadata()
|
||||
|
|
|
@ -88,6 +88,7 @@ def load_long_lat_data(only_metadata: bool = False, force: bool = False) -> None
|
|||
obj = table(table_name=tbl_name)
|
||||
obj.main_dttm_col = "datetime"
|
||||
obj.database = database
|
||||
obj.filter_select_enabled = True
|
||||
db.session.merge(obj)
|
||||
db.session.commit()
|
||||
obj.fetch_metadata()
|
||||
|
|
|
@ -80,6 +80,7 @@ def load_multiformat_time_series(
|
|||
obj = table(table_name=tbl_name)
|
||||
obj.main_dttm_col = "ds"
|
||||
obj.database = database
|
||||
obj.filter_select_enabled = True
|
||||
dttm_and_expr_dict: Dict[str, Tuple[Optional[str], None]] = {
|
||||
"ds": (None, None),
|
||||
"ds2": (None, None),
|
||||
|
|
|
@ -56,6 +56,7 @@ def load_paris_iris_geojson(only_metadata: bool = False, force: bool = False) ->
|
|||
tbl = table(table_name=tbl_name)
|
||||
tbl.description = "Map of Paris"
|
||||
tbl.database = database
|
||||
tbl.filter_select_enabled = True
|
||||
db.session.merge(tbl)
|
||||
db.session.commit()
|
||||
tbl.fetch_metadata()
|
||||
|
|
|
@ -65,6 +65,7 @@ def load_random_time_series_data(
|
|||
obj = table(table_name=tbl_name)
|
||||
obj.main_dttm_col = "ds"
|
||||
obj.database = database
|
||||
obj.filter_select_enabled = True
|
||||
db.session.merge(obj)
|
||||
db.session.commit()
|
||||
obj.fetch_metadata()
|
||||
|
|
|
@ -58,6 +58,7 @@ def load_sf_population_polygons(
|
|||
tbl = table(table_name=tbl_name)
|
||||
tbl.description = "Population density of San Francisco"
|
||||
tbl.database = database
|
||||
tbl.filter_select_enabled = True
|
||||
db.session.merge(tbl)
|
||||
db.session.commit()
|
||||
tbl.fetch_metadata()
|
||||
|
|
Loading…
Reference in New Issue