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
@@ -31,6 +31,7 @@ import React, {
|
||||
useReducer,
|
||||
Reducer,
|
||||
} from 'react';
|
||||
import { setItem, LocalStorageKeys } from 'src/utils/localStorageHelpers';
|
||||
import { UploadChangeParam, UploadFile } from 'antd/lib/upload/interface';
|
||||
import Tabs from 'src/components/Tabs';
|
||||
import { AntdSelect, Upload } from 'src/components';
|
||||
@@ -191,6 +192,11 @@ type DBReducerActionType =
|
||||
};
|
||||
};
|
||||
|
||||
const StyledBtns = styled.div`
|
||||
margin-bottom: ${({ theme }) => theme.gridUnit * 3}px;
|
||||
margin-left: ${({ theme }) => theme.gridUnit * 3}px;
|
||||
`;
|
||||
|
||||
function dbReducer(
|
||||
state: Partial<DatabaseObject> | null,
|
||||
action: DBReducerActionType,
|
||||
@@ -1109,6 +1115,39 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||
return <></>;
|
||||
};
|
||||
|
||||
const fetchAndSetDB = () => {
|
||||
setLoading(true);
|
||||
fetchResource(dbFetched?.id as number).then(r => {
|
||||
setItem(LocalStorageKeys.db, r);
|
||||
});
|
||||
};
|
||||
|
||||
const renderCTABtns = () => (
|
||||
<StyledBtns>
|
||||
<Button
|
||||
// eslint-disable-next-line no-return-assign
|
||||
buttonStyle="default"
|
||||
onClick={() => {
|
||||
fetchAndSetDB();
|
||||
window.location.href = '/tablemodelview/list';
|
||||
}}
|
||||
>
|
||||
{' '}
|
||||
{t('CREATE A DATASET')}{' '}
|
||||
</Button>
|
||||
<Button
|
||||
buttonStyle="default"
|
||||
// eslint-disable-next-line no-return-assign
|
||||
onClick={() => {
|
||||
fetchAndSetDB();
|
||||
window.location.href = `/superset/sqllab/?db=true`;
|
||||
}}
|
||||
>
|
||||
{t('QUERY DATA IN SQL LAB')}{' '}
|
||||
</Button>
|
||||
</StyledBtns>
|
||||
);
|
||||
|
||||
const renderFinishState = () => {
|
||||
if (!editNewDb) {
|
||||
return (
|
||||
@@ -1440,6 +1479,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||
dbModel={dbModel}
|
||||
editNewDb={editNewDb}
|
||||
/>
|
||||
{renderCTABtns()}
|
||||
{renderFinishState()}
|
||||
</>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user