You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2024/08/13 15:03:18 UTC
(superset) 05/06: fix: Loading of native filter column (#29647)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 244048d98692b6180ccf1a8ef1f17c63e94372a0
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Mon Jul 22 09:01:49 2024 -0300
fix: Loading of native filter column (#29647)
(cherry picked from commit 92537f1fd5e8039163950a0cfbd3eb6c8859a4ce)
---
.../FiltersConfigForm/ColumnSelect.tsx | 48 +++++++++++++---------
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
index d167a9be8c..64a1f3c96e 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
@@ -51,6 +51,7 @@ export function ColumnSelect({
mode,
}: ColumnSelectProps) {
const [columns, setColumns] = useState<Column[]>();
+ const [loading, setLoading] = useState(false);
const { addDangerToast } = useToasts();
const resetColumnField = useCallback(() => {
form.setFields([
@@ -82,9 +83,11 @@ export function ColumnSelect({
useChangeEffect(datasetId, previous => {
if (previous != null) {
+ setColumns([]);
resetColumnField();
}
if (datasetId != null) {
+ setLoading(true);
cachedSupersetGet({
endpoint: `/api/v1/dataset/${datasetId}?q=${rison.encode({
columns: [
@@ -93,26 +96,30 @@ export function ColumnSelect({
'columns.type_generic',
],
})}`,
- }).then(
- ({ json: { result } }) => {
- const lookupValue = Array.isArray(value) ? value : [value];
- const valueExists = result.columns.some(
- (column: Column) => lookupValue?.includes(column.column_name),
- );
- if (!valueExists) {
- resetColumnField();
- }
- setColumns(result.columns);
- },
- async badResponse => {
- const { error, message } = await getClientErrorObject(badResponse);
- let errorText = message || error || t('An error has occurred');
- if (message === 'Forbidden') {
- errorText = t('You do not have permission to edit this dashboard');
- }
- addDangerToast(errorText);
- },
- );
+ })
+ .then(
+ ({ json: { result } }) => {
+ const lookupValue = Array.isArray(value) ? value : [value];
+ const valueExists = result.columns.some(
+ (column: Column) => lookupValue?.includes(column.column_name),
+ );
+ if (!valueExists) {
+ resetColumnField();
+ }
+ setColumns(result.columns);
+ },
+ async badResponse => {
+ const { error, message } = await getClientErrorObject(badResponse);
+ let errorText = message || error || t('An error has occurred');
+ if (message === 'Forbidden') {
+ errorText = t(
+ 'You do not have permission to edit this dashboard',
+ );
+ }
+ addDangerToast(errorText);
+ },
+ )
+ .finally(() => setLoading(false));
}
});
@@ -121,6 +128,7 @@ export function ColumnSelect({
mode={mode}
value={mode === 'multiple' ? value || [] : value}
ariaLabel={t('Column select')}
+ loading={loading}
onChange={onChange}
options={options}
placeholder={t('Select a column')}