From a0ca632e72d3e8aead1b67efe244f24c35f51faa Mon Sep 17 00:00:00 2001 From: Akash N Date: Sat, 20 Jun 2020 05:28:10 +0000 Subject: [PATCH] Duplicate datasource fixes - Do not show datasoure field menu when url is blank - Embedded datasource name shouldn't be blank - Omit datasource name while creating a datasource --- .../editorComponents/form/fields/DatasourcesField.tsx | 6 +++--- app/client/src/sagas/DatasourcesSagas.ts | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/client/src/components/editorComponents/form/fields/DatasourcesField.tsx b/app/client/src/components/editorComponents/form/fields/DatasourcesField.tsx index a641f58f0c..2ea21e44c7 100644 --- a/app/client/src/components/editorComponents/form/fields/DatasourcesField.tsx +++ b/app/client/src/components/editorComponents/form/fields/DatasourcesField.tsx @@ -106,7 +106,7 @@ const DatasourcesField = ( } const DropdownIndicator = (props: any) => { - if (props.hasValue) return null; + if (props.hasValue || !props.selectProps.inputValue) return null; const MenuContainer = ( @@ -198,7 +198,7 @@ const DatasourcesField = ( const baseUrl = url.origin; datasourcePayload = { - name: baseUrl, + name: baseUrl || "DEFAULT_REST_DATASOURCE", datasourceConfiguration: { url: baseUrl, }, @@ -206,7 +206,7 @@ const DatasourcesField = ( pathPayload = path + params; } catch (e) { datasourcePayload = { - name: value, + name: value || "DEFAULT_REST_DATASOURCE", datasourceConfiguration: { url: value, }, diff --git a/app/client/src/sagas/DatasourcesSagas.ts b/app/client/src/sagas/DatasourcesSagas.ts index 966da486df..9fc2a23183 100644 --- a/app/client/src/sagas/DatasourcesSagas.ts +++ b/app/client/src/sagas/DatasourcesSagas.ts @@ -368,7 +368,8 @@ function* storeAsDatasourceSaga() { const { values } = yield select(getFormData, API_EDITOR_FORM_NAME); const applicationId = yield select(getCurrentApplicationId); const pageId = yield select(getCurrentPageId); - const datasource = _.get(values, "datasource"); + let datasource = _.get(values, "datasource"); + datasource = _.omit(datasource, ["name"]); history.push(DATA_SOURCES_EDITOR_URL(applicationId, pageId));