Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLDN-1609] Fixing all QA bugs #201

Merged
merged 5 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions superset-frontend/logs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,20 @@ const config: ControlPanelConfig = {
],
[
{
name: 'order_desc',
name: 'order_by_cols',
config: {
type: 'CheckboxControl',
label: t('Sort descending'),
default: true,
description: t('Whether to sort descending or ascending'),
visibility: isAggMode,
type: 'SelectControl',
label: t('Ordering'),
description: t('Order results by selected columns'),
multi: true,
default: [],
mapStateToProps: ({ datasource }) => ({
choices: datasource?.hasOwnProperty('order_by_choices')
? (datasource as Dataset)?.order_by_choices
: datasource?.columns || [],
}),
visibility: isRawMode,
resetOnHide: false,
},
},
],
Expand Down
15 changes: 12 additions & 3 deletions superset-frontend/src/components/Datasource/DatasourceEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import SpatialControl from 'src/explore/components/controls/SpatialControl';
import withToasts from 'src/components/MessageToasts/withToasts';
import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
import Icons from 'src/components/Icons';
import { bootstrapData } from 'src/preamble';
import CollectionTable from './CollectionTable';
import Fieldset from './Fieldset';
import Field from './Field';
Expand Down Expand Up @@ -279,9 +280,17 @@ function ColumnCollectionTable({
fieldKey="advanced_data_type"
label={t('Advanced data type')}
control={
<TextControl
controlId="advanced_data_type"
placeholder={t('Advanced Data type')}
<Select
ariaLabel={t('Select advanced data type')}
name="advanced_data_type"
allowClear
allowNewOptions
options={bootstrapData?.common?.advanced_data_types.map(
v => ({
value: v.id,
label: v.verbose_name,
}),
)}
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export interface AdvancedDataTypesState {
parsedAdvancedDataType: string;
advancedDataTypeOperatorList: string[];
errorMessage: string;
useDefaultOperators: boolean;
}

export const useSimpleTabFilterProps = (props: Props) => {
Expand Down Expand Up @@ -268,7 +269,7 @@ const AdhocFilterEditPopoverSimpleTabContent: React.FC<Props> = props => {
} = useAdvancedDataTypes(props.validHandler);
// TODO: This does not need to exist, just use the advancedTypeOperatorList list
const isOperatorRelevantWrapper = (operator: Operators, subject: string) =>
subjectAdvancedDataType
subjectAdvancedDataType && !advancedDataTypesState.useDefaultOperators
? isOperatorRelevant(operator, subject) &&
advancedDataTypesState.advancedDataTypeOperatorList.includes(operator)
: isOperatorRelevant(operator, subject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const INITIAL_ADVANCED_DATA_TYPES_STATE: AdvancedDataTypesState = {
parsedAdvancedDataType: '',
advancedDataTypeOperatorList: [],
errorMessage: '',
useDefaultOperators: false,
};

const useAdvancedDataTypes = (validHandler: (isValid: boolean) => void) => {
Expand Down Expand Up @@ -58,6 +59,7 @@ const useAdvancedDataTypes = (validHandler: (isValid: boolean) => void) => {
parsedAdvancedDataType: json.result.display_value,
advancedDataTypeOperatorList: json.result.valid_filter_operators,
errorMessage: json.result.error_message,
useDefaultOperators: false,
});
// Changed due to removal of status field
validHandler(!json.result.error_message);
Expand All @@ -68,8 +70,9 @@ const useAdvancedDataTypes = (validHandler: (isValid: boolean) => void) => {
advancedDataTypeOperatorList:
advancedDataTypesState.advancedDataTypeOperatorList,
errorMessage: t('Failed to retrieve advanced type'),
useDefaultOperators: true,
});
validHandler(false);
validHandler(true);
});
}, 600)();
},
Expand Down
4 changes: 2 additions & 2 deletions superset/advanced_data_type/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def get(self, **kwargs: Any) -> Response:
$ref: '#/components/responses/500'
"""
item = kwargs["rison"]
advanced_data_type = item["type"]
advanced_data_type: str = item["type"]
values = item["values"]
addon = ADVANCED_DATA_TYPES.get(advanced_data_type)
addon = ADVANCED_DATA_TYPES.get(advanced_data_type.lower())
if not addon:
return self.response(
400,
Expand Down
2 changes: 1 addition & 1 deletion superset/advanced_data_type/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"values": {
"type": "array",
"items": {"default": "http"},
"minItems": 1,
"minItems": 0,
},
},
"required": ["type", "values"],
Expand Down
7 changes: 4 additions & 3 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
utils.FilterOperator.NOT_IN.value,
)

col_advanced_data_type = col_obj.advanced_data_type if col_obj else ""
col_advanced_data_type: str = col_obj.advanced_data_type if col_obj else ""

if col_spec and not col_advanced_data_type:
target_generic_type = col_spec.generic_type
Expand All @@ -1535,14 +1535,15 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
)
if (
col_advanced_data_type != ""
and col_advanced_data_type
and feature_flag_manager.is_feature_enabled(
"ENABLE_ADVANCED_DATA_TYPES"
)
and col_advanced_data_type in ADVANCED_DATA_TYPES
and col_advanced_data_type.lower() in ADVANCED_DATA_TYPES
):
values = eq if is_list_target else [eq] # type: ignore
bus_resp: AdvancedDataTypeResponse = ADVANCED_DATA_TYPES[
col_advanced_data_type
col_advanced_data_type.lower()
].translate_type(
{
"type": col_advanced_data_type,
Expand Down
11 changes: 11 additions & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@ def common_bootstrap_payload() -> Dict[str, Any]:
"theme_overrides": conf["THEME_OVERRIDES"],
"menu_data": menu_data(),
"datahub_url": conf.get("DATAHUB_URL", ""),
"advanced_data_types": list(
map(
lambda v: {
"id": v[0],
"verbose_name": v[1].verbose_name,
"description": v[1].description,
"valid_data_types": v[1].valid_data_types,
},
config["ADVANCED_DATA_TYPES"].items(),
)
),
}
bootstrap_data.update(conf["COMMON_BOOTSTRAP_OVERRIDES_FUNC"](bootstrap_data))
return bootstrap_data
Expand Down