forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: native filter components (apache#840)
* feat: add AntD filter components * add missing files * add filter hook * fix hook name * required thumbnail * add native filters to where clause * add isNativeFilter flag to ChartMetadata * rename native_filters to extra_form_data * lint * move hook to SuperChart props * add NOOP default to setSelectedValues * replace extra_form_data with override_ and append_ * add support for appending freeform where * address review comments * Add default values * Update packages/superset-ui-core/test/query/processExtraFormData.test.ts Co-authored-by: Evan Rusackas <[email protected]> * Update packages/superset-ui-core/test/query/processExtraFormData.test.ts Co-authored-by: Evan Rusackas <[email protected]> * add storybook entry and change width to 100% * add placeholder * add default thumbnails Co-authored-by: Evan Rusackas <[email protected]>
- Loading branch information
1 parent
4c5871f
commit 342a16d
Showing
47 changed files
with
2,173 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...ntend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/chart/types/Base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...orary_superset_ui/superset-ui/packages/superset-ui-core/src/query/processExtraFormData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* 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 { QueryObject } from './types/Query'; | ||
|
||
const ALLOWED_OVERRIDES = ['time_grain_sqla', 'time_range', 'since', 'until']; | ||
const ALLOWED_APPENDS = ['adhoc_filters', 'filters', 'groupby']; | ||
|
||
export function overrideExtraFormData( | ||
queryObject: QueryObject, | ||
overrideFormData: Partial<QueryObject>, | ||
): QueryObject { | ||
const overriddenFormData = { ...queryObject }; | ||
ALLOWED_OVERRIDES.forEach(key => { | ||
if (key in overrideFormData) { | ||
overriddenFormData[key] = overrideFormData[key]; | ||
} | ||
}); | ||
return overriddenFormData; | ||
} | ||
|
||
export function appendExtraFormData( | ||
queryObject: QueryObject, | ||
appendFormData: Partial<QueryObject>, | ||
): QueryObject { | ||
const appendedFormData = { ...queryObject }; | ||
ALLOWED_APPENDS.forEach(key => { | ||
if (key in appendFormData) { | ||
const append = appendFormData[key]; | ||
const currentValue = appendedFormData[key] || []; | ||
// @ts-ignore | ||
currentValue.push(...append); | ||
appendedFormData[key] = currentValue; | ||
} | ||
}); | ||
|
||
// Add freeform where | ||
const { extras = {} } = appendedFormData; | ||
const { where = '' } = extras; | ||
extras.where = where; | ||
|
||
const { extras: appendExtras = {} } = appendFormData; | ||
let { where: appendWhere } = appendExtras; | ||
|
||
if (appendWhere) { | ||
appendedFormData.extras = extras; | ||
appendWhere = `(${appendWhere})`; | ||
} | ||
if (where) { | ||
appendWhere = `(${where}) AND ${appendWhere}`; | ||
} | ||
extras.where = appendWhere; | ||
|
||
return appendedFormData; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...porary_superset_ui/superset-ui/packages/superset-ui-core/test/query/DatasourceKey.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ry_superset_ui/superset-ui/packages/superset-ui-core/test/query/buildQueryContext.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ary_superset_ui/superset-ui/packages/superset-ui-core/test/query/buildQueryObject.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.