From d19f86ffee4e388100c01958f9a60b53994b45bf Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Tue, 12 May 2020 15:14:29 +0000 Subject: [PATCH] Untitled datasources are named by the server --- .../DataSourceEditor/DatasourceHome.tsx | 39 +++---------------- app/client/src/selectors/entitiesSelector.ts | 3 -- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/app/client/src/pages/Editor/DataSourceEditor/DatasourceHome.tsx b/app/client/src/pages/Editor/DataSourceEditor/DatasourceHome.tsx index 8acfa217b7..7780488519 100644 --- a/app/client/src/pages/Editor/DataSourceEditor/DatasourceHome.tsx +++ b/app/client/src/pages/Editor/DataSourceEditor/DatasourceHome.tsx @@ -3,11 +3,7 @@ import styled from "styled-components"; import { connect } from "react-redux"; import { initialize } from "redux-form"; import { Card, Spinner } from "@blueprintjs/core"; -import { - getDatasourceNames, - getDatasourcePlugins, -} from "selectors/entitiesSelector"; -import { getNextEntityName } from "utils/AppsmithUtils"; +import { getDatasourcePlugins } from "selectors/entitiesSelector"; import { Plugin } from "api/PluginApi"; import { DATASOURCE_DB_FORM } from "constants/forms"; import ImageAlt from "assets/images/placeholder-image.svg"; @@ -123,43 +119,21 @@ interface ReduxDispatchProps { interface ReduxStateProps { plugins: Plugin[]; - datasourceNames: string[]; currentApplication: UserApplication; } type Props = ReduxStateProps & DatasourceHomeScreenProps & ReduxDispatchProps; class DatasourceHomeScreen extends React.Component { - goToCreateDatasource = (pluginId: string, packageName: string) => { - const { datasourceNames, currentApplication } = this.props; - let type = ""; + goToCreateDatasource = (pluginId: string) => { + const { currentApplication } = this.props; AnalyticsUtil.logEvent("CREATE_DATA_SOURCE_CLICK", { appName: currentApplication.name, }); - switch (packageName) { - case PLUGIN_PACKAGE_POSTGRES: - type = "POSTGRES"; - break; - case PLUGIN_PACKAGE_MONGO: - type = "MONGODB"; - break; - case REST_PLUGIN_PACKAGE_NAME: - type = "REST API"; - break; - default: - break; - } - - const name = getNextEntityName( - `Untitled Datasource ${type}`, - datasourceNames, - ); - this.props.selectPlugin(pluginId); this.props.createDatasource({ - name, pluginId, }); }; @@ -198,15 +172,13 @@ class DatasourceHomeScreen extends React.Component { interactive={false} className="eachDatasourceCard" key={plugin.id} - onClick={() => - this.goToCreateDatasource(plugin.id, plugin.packageName) - } + onClick={() => this.goToCreateDatasource(plugin.id)} > Datasource + />

{plugin.name}

); @@ -222,7 +194,6 @@ class DatasourceHomeScreen extends React.Component { const mapStateToProps = (state: AppState): ReduxStateProps => { return { plugins: getDatasourcePlugins(state), - datasourceNames: getDatasourceNames(state), currentApplication: getCurrentApplication(state), }; }; diff --git a/app/client/src/selectors/entitiesSelector.ts b/app/client/src/selectors/entitiesSelector.ts index c30e6f3689..38c4423025 100644 --- a/app/client/src/selectors/entitiesSelector.ts +++ b/app/client/src/selectors/entitiesSelector.ts @@ -107,9 +107,6 @@ export const getActions = (state: AppState): ActionDataState => export const getDatasourceRefs = (state: AppState): any => state.ui.datasourcePane.datasourceRefs; -export const getDatasourceNames = (state: AppState): any => - state.entities.datasources.list.map(datasource => datasource.name); - export const getPlugins = (state: AppState) => state.entities.plugins.list; export const getApiActions = (state: AppState): ActionDataState => {