feat(HTTP Request Node): Redesign and add the ability to import cURL commands (#3860)

*  Initial commit

* 👕 Fix linting issue

*  Add import button

*  Remove ligh versioning

*  Improvements

*  Improvements

* 🔥 Remove HttpRequest2 file used for testing

* 🐛 Fix building issue

*  Small improvement

* 👕 Fix linting issue

* 🔥 Remove HttpRequest2 from loader

*  Update package-lock.json

*  Improvements

*  Small change

* 🐛 Fix issue retrieving splitIntoItems

* 🐛 Fix issue retrieving neverError parameter

* 🐛 Fix issue with displayOptions

*  Improvements

*  Improvements

*  Improvements

*  Improvements

*  Move cURL section to its own component

*  Improvements

*  Improvements

*  Add fix for  batching in all versions

*  Add notice to cURL modal

* 🔥 Remove comments

*  Improvements

*  Type curl-to-json endpoint

*  Fix typo

* 🔥 Remove console.logs

*  Fix typo in curl-to-json endpoint

*  Improvements

*  Improvements

*  Update package-lock.json

*  Rename import modal constant

*  Add return types to methods

*  Add CSS modules to ImportParameter component

*  Rename ImportParameter component to use kebab-case

*  Improvements

*  update package-lock.json

*  Fix linting issues

* Fix issue with css reference in ImportParameter component

*  Small improvements

*  Rename redirects to redirect

*  Allow to set multiple parameters on valueChanged

* 👕 Fix linting issue

* 🐛 Add mistakenly removed openExistingCredentials

*  Improve curl regex

*  Keep  headers as defined in the cURL command

*  Account for all protocols supported by cURL

*  Add tests

* 🔥 Remove unnecessary lines

*  Add more testing

*  Add noDataExpression to dependent fields

* 🐛 Fix bug not handling multipart-form data correctly

*  Change error messages

* 🐛 Fix response format string for empty values

* Fix typo
This commit is contained in:
Ricardo Espinoza
2022-09-29 17:28:02 -04:00
committed by GitHub
parent 5526057efc
commit f37d6ba03b
25 changed files with 5816 additions and 1805 deletions

View File

@@ -1,3 +1,4 @@
import { getCurlToJson } from '@/api/curlHelper';
import { applyForOnboardingCall, fetchNextOnboardingPrompt, submitEmailOnSignup } from '@/api/workflow-webhooks';
import {
ABOUT_MODAL_KEY,
@@ -22,6 +23,7 @@ import {
ONBOARDING_CALL_SIGNUP_MODAL_KEY,
FAKE_DOOR_FEATURES,
COMMUNITY_PACKAGE_MANAGE_ACTIONS,
IMPORT_CURL_MODAL_KEY,
} from '@/constants';
import Vue from 'vue';
import { ActionContext, Module } from 'vuex';
@@ -100,6 +102,11 @@ const module: Module<IUiState, IRootState> = {
mode: '',
activeId: null,
},
[IMPORT_CURL_MODAL_KEY]: {
open: false,
curlCommand: '',
httpNodeParameters: '',
},
},
modalStack: [],
sidebarMenuCollapsed: true,
@@ -167,6 +174,12 @@ const module: Module<IUiState, IRootState> = {
isVersionsOpen: (state: IUiState) => {
return state.modals[VERSIONS_MODAL_KEY].open;
},
getCurlCommand: (state: IUiState) => {
return state.modals[IMPORT_CURL_MODAL_KEY].curlCommand;
},
getHttpNodeParameters: (state: IUiState) => {
return state.modals[IMPORT_CURL_MODAL_KEY].httpNodeParameters;
},
isModalOpen: (state: IUiState) => {
return (name: string) => state.modals[name].open;
},
@@ -231,6 +244,14 @@ const module: Module<IUiState, IRootState> = {
const { name, id } = params;
Vue.set(state.modals[name], 'activeId', id);
},
setCurlCommand: (state: IUiState, params: {name: string, command: string}) => {
const { name, command } = params;
Vue.set(state.modals[name], 'curlCommand', command);
},
setHttpNodeParameters: (state: IUiState, params: {name: string, parameters: string}) => {
const { name, parameters } = params;
Vue.set(state.modals[name], 'httpNodeParameters', parameters);
},
openModal: (state: IUiState, name: string) => {
Vue.set(state.modals[name], 'open', true);
state.modalStack = [name].concat(state.modalStack);
@@ -323,6 +344,17 @@ const module: Module<IUiState, IRootState> = {
context.commit('setMode', { name: CREDENTIAL_EDIT_MODAL_KEY, mode: 'edit' });
context.commit('openModal', CREDENTIAL_EDIT_MODAL_KEY);
},
setCurlCommand: async (context: ActionContext<IUiState, IRootState>, { command }: {command: string}) => {
context.commit('setCurlCommand', { name: IMPORT_CURL_MODAL_KEY, command });
},
setHttpNodeParameters: async (context: ActionContext<IUiState, IRootState>, { parameters }) => {
context.commit('setHttpNodeParameters', { name: IMPORT_CURL_MODAL_KEY, parameters });
},
openExisitngCredential: async (context: ActionContext<IUiState, IRootState>, { id }: {id: string}) => {
context.commit('setActiveId', { name: CREDENTIAL_EDIT_MODAL_KEY, id });
context.commit('setMode', { name: CREDENTIAL_EDIT_MODAL_KEY, mode: 'edit' });
context.commit('openModal', CREDENTIAL_EDIT_MODAL_KEY);
},
openNewCredential: async (context: ActionContext<IUiState, IRootState>, { type }: {type: string}) => {
context.commit('setActiveId', { name: CREDENTIAL_EDIT_MODAL_KEY, id: type });
context.commit('setMode', { name: CREDENTIAL_EDIT_MODAL_KEY, mode: 'new' });
@@ -354,6 +386,9 @@ const module: Module<IUiState, IRootState> = {
context.commit('setMode', { name: COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY, mode: COMMUNITY_PACKAGE_MANAGE_ACTIONS.UPDATE });
context.commit('openModal', COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY);
},
async getCurlToJson(context: ActionContext<IUiState, IRootState>, curlCommand) {
return await getCurlToJson(context.rootGetters['getRestApiContext'], curlCommand);
},
},
};