fix: Loading of native filter column (#29647)

This commit is contained in:
Michael S. Molina 2024-07-22 09:01:49 -03:00 committed by GitHub
parent ae0edbfdce
commit 92537f1fd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 20 deletions

View File

@ -56,6 +56,7 @@ export function ColumnSelect({
mode,
}: ColumnSelectProps) {
const [columns, setColumns] = useState<Column[]>();
const [loading, setLoading] = useState(false);
const { addDangerToast } = useToasts();
const resetColumnField = useCallback(() => {
form.setFields([
@ -87,9 +88,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: [
@ -98,7 +101,8 @@ export function ColumnSelect({
'columns.type_generic',
],
})}`,
}).then(
})
.then(
({ json: { result } }) => {
const lookupValue = Array.isArray(value) ? value : [value];
const valueExists = result.columns.some(
@ -113,11 +117,14 @@ export function ColumnSelect({
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');
errorText = t(
'You do not have permission to edit this dashboard',
);
}
addDangerToast(errorText);
},
);
)
.finally(() => setLoading(false));
}
});
@ -126,6 +133,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')}