mirror of
https://github.com/apache/superset.git
synced 2026-05-07 08:54:23 +00:00
refactor(sqllab): Remove tableOptions from redux state (#23488)
This commit is contained in:
@@ -39,7 +39,7 @@ import {
|
||||
FullSQLEditor as AceEditor,
|
||||
} from 'src/components/AsyncAceEditor';
|
||||
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
|
||||
import { useSchemas } from 'src/hooks/apiResources';
|
||||
import { useSchemas, useTables } from 'src/hooks/apiResources';
|
||||
|
||||
type HotKey = {
|
||||
key: string;
|
||||
@@ -96,11 +96,19 @@ const AceEditorWrapper = ({
|
||||
'dbId',
|
||||
'sql',
|
||||
'functionNames',
|
||||
'tableOptions',
|
||||
'validationResult',
|
||||
'schema',
|
||||
]);
|
||||
const { data: schemaOptions } = useSchemas({ dbId: queryEditor.dbId });
|
||||
const { data: schemaOptions } = useSchemas({
|
||||
...(autocomplete && { dbId: queryEditor.dbId }),
|
||||
});
|
||||
const { data: tableData } = useTables({
|
||||
...(autocomplete && {
|
||||
dbId: queryEditor.dbId,
|
||||
schema: queryEditor.schema,
|
||||
}),
|
||||
});
|
||||
|
||||
const currentSql = queryEditor.sql ?? '';
|
||||
const functionNames = queryEditor.functionNames ?? [];
|
||||
|
||||
@@ -117,7 +125,7 @@ const AceEditorWrapper = ({
|
||||
}),
|
||||
[schemaOptions],
|
||||
);
|
||||
const tables = queryEditor.tableOptions ?? [];
|
||||
const tables = tableData?.options ?? [];
|
||||
|
||||
const [sql, setSql] = useState(currentSql);
|
||||
const [words, setWords] = useState<AceCompleterKeyword[]>([]);
|
||||
|
||||
@@ -80,7 +80,6 @@ const SaveQuery = ({
|
||||
'schema',
|
||||
'selectedText',
|
||||
'sql',
|
||||
'tableOptions',
|
||||
'templateParams',
|
||||
]);
|
||||
const query = useMemo(
|
||||
|
||||
@@ -35,7 +35,6 @@ import {
|
||||
collapseTable,
|
||||
expandTable,
|
||||
queryEditorSetSchema,
|
||||
queryEditorSetTableOptions,
|
||||
setDatabases,
|
||||
addDangerToast,
|
||||
resetState,
|
||||
@@ -218,15 +217,6 @@ const SqlEditorLeftBar = ({
|
||||
[dispatch, queryEditor],
|
||||
);
|
||||
|
||||
const handleTablesLoad = useCallback(
|
||||
(options: Array<any>) => {
|
||||
if (queryEditor) {
|
||||
dispatch(queryEditorSetTableOptions(queryEditor, options));
|
||||
}
|
||||
},
|
||||
[dispatch, queryEditor],
|
||||
);
|
||||
|
||||
const handleDbList = useCallback(
|
||||
(result: DatabaseObject) => {
|
||||
dispatch(setDatabases(result));
|
||||
@@ -256,7 +246,6 @@ const SqlEditorLeftBar = ({
|
||||
onDbChange={onDbChange}
|
||||
onSchemaChange={handleSchemaChange}
|
||||
onTableSelectChange={onTablesChange}
|
||||
onTablesLoad={handleTablesLoad}
|
||||
schema={schema}
|
||||
tableValue={selectedTableNames}
|
||||
sqlLabMode
|
||||
|
||||
Reference in New Issue
Block a user