mirror of
https://github.com/apache/superset.git
synced 2026-04-21 17:14:57 +00:00
feat: hack db connection modal ctabtns (#20017)
* add flow for dbconnmodal to datasetmodal * fix bug * second part * fix dataset to sql lab * fix lint * more lint * add key value * fix type * add new styling * remove undefined from types
This commit is contained in:
committed by
GitHub
parent
4137fe03a0
commit
9da7c1f7b8
@@ -25,6 +25,7 @@ import React, {
|
||||
Dispatch,
|
||||
SetStateAction,
|
||||
} from 'react';
|
||||
import querystring from 'query-string';
|
||||
import Button from 'src/components/Button';
|
||||
import { t, styled, css, SupersetTheme } from '@superset-ui/core';
|
||||
import Collapse from 'src/components/Collapse';
|
||||
@@ -34,6 +35,11 @@ import { IconTooltip } from 'src/components/IconTooltip';
|
||||
import { QueryEditor } from 'src/SqlLab/types';
|
||||
import { DatabaseObject } from 'src/components/DatabaseSelector';
|
||||
import { EmptyStateSmall } from 'src/components/EmptyState';
|
||||
import {
|
||||
getItem,
|
||||
LocalStorageKeys,
|
||||
setItem,
|
||||
} from 'src/utils/localStorageHelpers';
|
||||
import TableElement, { Table, TableElementProps } from '../TableElement';
|
||||
|
||||
interface ExtendedTable extends Table {
|
||||
@@ -105,10 +111,26 @@ export default function SqlEditorLeftBar({
|
||||
// that require and modify the queryEditor
|
||||
const queryEditorRef = useRef<QueryEditor>(queryEditor);
|
||||
const [emptyResultsWithSearch, setEmptyResultsWithSearch] = useState(false);
|
||||
const [userSelectedDb, setUserSelected] = useState<DatabaseObject | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const bool = querystring.parse(window.location.search).db;
|
||||
const userSelected = getItem(
|
||||
LocalStorageKeys.db,
|
||||
null,
|
||||
) as DatabaseObject | null;
|
||||
|
||||
if (bool && userSelected) {
|
||||
setUserSelected(userSelected);
|
||||
setItem(LocalStorageKeys.db, null);
|
||||
} else setUserSelected(database);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
queryEditorRef.current = queryEditor;
|
||||
}, [queryEditor]);
|
||||
}, [queryEditor, database]);
|
||||
|
||||
const onEmptyResults = (searchText?: string) => {
|
||||
setEmptyResultsWithSearch(!!searchText);
|
||||
@@ -222,7 +244,7 @@ export default function SqlEditorLeftBar({
|
||||
<TableSelectorMultiple
|
||||
onEmptyResults={onEmptyResults}
|
||||
emptyState={emptyStateComponent}
|
||||
database={database}
|
||||
database={userSelectedDb}
|
||||
getDbList={actions.setDatabases}
|
||||
handleError={actions.addDangerToast}
|
||||
onDbChange={onDbChange}
|
||||
|
||||
Reference in New Issue
Block a user