mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
feat: add separate endpoint to fetch function names for autocomplete (#12840)
* WIP * Add unit test for API * Add spec * Fix unit test * Fix unit test * Fix test * Fix test * Add period to error message
This commit is contained in:
@@ -57,6 +57,8 @@ export const QUERY_EDITOR_SET_QUERY_LIMIT = 'QUERY_EDITOR_SET_QUERY_LIMIT';
|
||||
export const QUERY_EDITOR_SET_TEMPLATE_PARAMS =
|
||||
'QUERY_EDITOR_SET_TEMPLATE_PARAMS';
|
||||
export const QUERY_EDITOR_SET_SELECTED_TEXT = 'QUERY_EDITOR_SET_SELECTED_TEXT';
|
||||
export const QUERY_EDITOR_SET_FUNCTION_NAMES =
|
||||
'QUERY_EDITOR_SET_FUNCTION_NAMES';
|
||||
export const QUERY_EDITOR_PERSIST_HEIGHT = 'QUERY_EDITOR_PERSIST_HEIGHT';
|
||||
export const MIGRATE_QUERY_EDITOR = 'MIGRATE_QUERY_EDITOR';
|
||||
export const MIGRATE_TAB_HISTORY = 'MIGRATE_TAB_HISTORY';
|
||||
@@ -1300,3 +1302,23 @@ export function createCtasDatasource(vizOptions) {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function queryEditorSetFunctionNames(queryEditor, dbId) {
|
||||
return function (dispatch) {
|
||||
return SupersetClient.get({
|
||||
endpoint: encodeURI(`/api/v1/database/${dbId}/function_names/`),
|
||||
})
|
||||
.then(({ json }) =>
|
||||
dispatch({
|
||||
type: QUERY_EDITOR_SET_FUNCTION_NAMES,
|
||||
queryEditor,
|
||||
functionNames: json.function_names,
|
||||
}),
|
||||
)
|
||||
.catch(() =>
|
||||
dispatch(
|
||||
addDangerToast(t('An error occurred while fetching function names.')),
|
||||
),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user