Merge branch 'fix/plugin-id-for-new-actions' into 'release'

Fix issue where new REST actions where not getting the plugin id

See merge request theappsmith/internal-tools-client!490
This commit is contained in:
Hetu Nandu 2020-04-17 09:25:31 +00:00
commit 4e90ebff99

View File

@ -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<RestAction>) => void;
@ -279,13 +283,15 @@ class ApiHomeScreen extends React.Component<Props, ApiHomeScreenState> {
}
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,
};
};