Untitled datasources are named by the server
This commit is contained in:
parent
1c094be437
commit
d19f86ffee
|
|
@ -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<Props> {
|
||||
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<Props> {
|
|||
interactive={false}
|
||||
className="eachDatasourceCard"
|
||||
key={plugin.id}
|
||||
onClick={() =>
|
||||
this.goToCreateDatasource(plugin.id, plugin.packageName)
|
||||
}
|
||||
onClick={() => this.goToCreateDatasource(plugin.id)}
|
||||
>
|
||||
<img
|
||||
src={this.getImageSrc(plugin.packageName)}
|
||||
className="dataSourceImage"
|
||||
alt="Datasource"
|
||||
></img>
|
||||
/>
|
||||
<p className="t--plugin-name textBtn">{plugin.name}</p>
|
||||
</Card>
|
||||
);
|
||||
|
|
@ -222,7 +194,6 @@ class DatasourceHomeScreen extends React.Component<Props> {
|
|||
const mapStateToProps = (state: AppState): ReduxStateProps => {
|
||||
return {
|
||||
plugins: getDatasourcePlugins(state),
|
||||
datasourceNames: getDatasourceNames(state),
|
||||
currentApplication: getCurrentApplication(state),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user