diff --git a/app/client/src/pages/Editor/APIEditor/ApiHomeScreen.tsx b/app/client/src/pages/Editor/APIEditor/ApiHomeScreen.tsx index cbde09e011..84e10ae8f3 100644 --- a/app/client/src/pages/Editor/APIEditor/ApiHomeScreen.tsx +++ b/app/client/src/pages/Editor/APIEditor/ApiHomeScreen.tsx @@ -8,6 +8,7 @@ import InfiniteScroll from "react-infinite-scroller"; import { DEFAULT_API_ACTION, DEFAULT_PROVIDER_OPTION, + REST_PLUGIN_PACKAGE_NAME, } from "constants/ApiEditorConstants"; import { getCurlImportPageURL, @@ -44,6 +45,8 @@ import Spinner from "components/editorComponents/Spinner"; // import PostmanLogo from "assets/images/Postman-logo.svg"; import CurlLogo from "assets/images/Curl-logo.svg"; import { FetchProviderWithCategoryRequest } from "api/ProvidersApi"; +import { Plugin } from "api/PluginApi"; +import _ from "lodash"; // const SearchContainer = styled.div` // display: flex; @@ -221,6 +224,7 @@ type ApiHomeScreenProps = { fetchProviderCategories: () => void; providerCategories: string[]; pageId: string; + plugins: Plugin[]; applicationId: string; actions: ActionDataState; createAction: (data: Partial) => void; @@ -279,13 +283,15 @@ class ApiHomeScreen extends React.Component { } handleCreateNew = (params: string) => { - const { actions } = this.props; + const { actions, plugins } = this.props; const pageId = new URLSearchParams(params).get("importTo"); - if (pageId) { + const plugin = _.find(plugins, { packageName: REST_PLUGIN_PACKAGE_NAME }); + if (pageId && plugin) { const newActionName = createNewApiName(actions, pageId); this.props.createAction({ ...DEFAULT_API_ACTION, name: newActionName, + pluginId: plugin.id, pageId, }); } @@ -537,6 +543,7 @@ const mapStateToProps = (state: AppState) => { actions: state.entities.actions, providersTotal, providerCategories: getProviderCategories(state), + plugins: state.entities.plugins.list, isSwitchingCategory, }; };