You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2022/02/11 00:14:14 UTC
[superset] branch master updated: feat: add prop to `setDBEngine` in DatabaseModal (#18653)
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 78e20e2 feat: add prop to `setDBEngine` in DatabaseModal (#18653)
78e20e2 is described below
commit 78e20e21abe3f264701e796d36b900246b39c22b
Author: Hugh A. Miles II <hu...@gmail.com>
AuthorDate: Thu Feb 10 19:12:52 2022 -0500
feat: add prop to `setDBEngine` in DatabaseModal (#18653)
* saving this now
* remove for testing
* added test
* remove this
* remove set
* remove log
* Update index.test.jsx
---
.../CRUD/data/database/DatabaseModal/index.test.jsx | 20 ++++++++++++++++++++
.../views/CRUD/data/database/DatabaseModal/index.tsx | 7 +++++++
2 files changed, 27 insertions(+)
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx
index 088fd79..6fcbfda 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx
@@ -1016,4 +1016,24 @@ describe('DatabaseModal', () => {
});
});
});
+ describe('DatabaseModal w/ Deeplinking Engine', () => {
+ const renderAndWait = async () => {
+ const mounted = act(async () => {
+ render(<DatabaseModal {...dbProps} dbEngine="PostgreSQL" />, {
+ useRedux: true,
+ });
+ });
+
+ return mounted;
+ };
+
+ beforeEach(async () => {
+ await renderAndWait();
+ });
+
+ it('enters step 2 of 3 when proper database is selected', () => {
+ const step2of3text = screen.getByText(/step 2 of 3/i);
+ expect(step2of3text).toBeVisible();
+ });
+ });
});
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
index 8283aeb..990ab4b 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -135,6 +135,7 @@ interface DatabaseModalProps {
onHide: () => void;
show: boolean;
databaseId: number | undefined; // If included, will go into edit mode
+ dbEngine: string | undefined; // if included goto step 2 with engine already set
}
enum ActionType {
@@ -428,6 +429,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
onHide,
show,
databaseId,
+ dbEngine,
}) => {
const [db, setDB] = useReducer<
Reducer<Partial<DatabaseObject> | null, DBReducerActionType>
@@ -850,6 +852,11 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
if (isLoading) {
setLoading(false);
}
+
+ if (availableDbs && dbEngine) {
+ // set model if passed into props
+ setDatabaseModel(dbEngine);
+ }
}, [availableDbs]);
const tabChange = (key: string) => {