2019-11-25 09:15:11 +00:00
/ * *
* Handles the Api pane ui state . It looks into the routing based on actions too
* * /
2021-05-17 07:21:48 +00:00
import get from "lodash/get" ;
import omit from "lodash/omit" ;
import cloneDeep from "lodash/cloneDeep" ;
2020-08-19 09:21:32 +00:00
import { all , select , put , takeEvery , call , take } from "redux-saga/effects" ;
2020-12-14 16:22:45 +00:00
import * as Sentry from "@sentry/react" ;
2019-11-25 09:15:11 +00:00
import {
ReduxAction ,
2020-06-18 14:16:49 +00:00
ReduxActionErrorTypes ,
2019-11-25 09:15:11 +00:00
ReduxActionTypes ,
ReduxActionWithMeta ,
ReduxFormActionTypes ,
2022-04-12 10:50:01 +00:00
} from "@appsmith/constants/ReduxActionConstants" ;
2022-06-21 13:57:34 +00:00
import { GetFormData , getFormData } from "selectors/formSelectors" ;
2022-09-02 17:15:08 +00:00
import {
API_EDITOR_FORM_NAME ,
QUERY_EDITOR_FORM_NAME ,
} from "@appsmith/constants/forms" ;
2020-04-20 08:26:19 +00:00
import {
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
POST_BODY_FORMAT_OPTIONS_ARRAY ,
2020-04-20 08:26:19 +00:00
POST_BODY_FORMAT_OPTIONS ,
2021-03-01 14:57:15 +00:00
CONTENT_TYPE_HEADER_KEY ,
EMPTY_KEY_VALUE_PAIRS ,
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
HTTP_METHOD ,
2022-04-12 11:13:11 +00:00
HTTP_METHODS_DEFAULT_FORMAT_TYPES ,
2022-09-09 15:59:47 +00:00
} from "constants/ApiEditorConstants/CommonApiConstants" ;
import {
REST_PLUGIN_PACKAGE_NAME ,
DEFAULT_CREATE_API_CONFIG ,
} from "constants/ApiEditorConstants/ApiEditorConstants" ;
import {
GRAPHQL_PLUGIN_PACKAGE_NAME ,
DEFAULT_CREATE_GRAPHQL_CONFIG ,
} from "constants/ApiEditorConstants/GraphQLEditorConstants" ;
2019-11-25 09:15:11 +00:00
import history from "utils/history" ;
2022-03-25 10:43:26 +00:00
import { INTEGRATION_EDITOR_MODES , INTEGRATION_TABS } from "constants/routes" ;
2020-05-07 07:56:37 +00:00
import { initialize , autofill , change } from "redux-form" ;
2020-06-04 13:49:22 +00:00
import { Property } from "api/ActionAPI" ;
2022-08-04 05:40:44 +00:00
import { createNewApiName } from "utils/AppsmithUtils" ;
import { getQueryParams } from "utils/URLUtils" ;
2020-04-20 08:26:19 +00:00
import { getPluginIdOfPackageName } from "sagas/selectors" ;
2022-01-29 07:26:19 +00:00
import { getAction , getActions , getPlugin } from "selectors/entitiesSelector" ;
2022-06-21 13:57:34 +00:00
import {
ActionData ,
ActionDataState ,
} from "reducers/entityReducers/actionsReducer" ;
2021-08-27 09:25:28 +00:00
import {
createActionRequest ,
setActionProperty ,
} from "actions/pluginActionActions" ;
2021-01-12 04:17:28 +00:00
import { Datasource } from "entities/Datasource" ;
2021-04-07 10:36:17 +00:00
import { Action , ApiAction , PluginType } from "entities/Action" ;
2022-06-15 15:37:41 +00:00
import { getCurrentWorkspaceId } from "@appsmith/selectors/workspaceSelectors" ;
2020-08-18 08:48:06 +00:00
import log from "loglevel" ;
2020-09-24 04:47:37 +00:00
import PerformanceTracker , {
PerformanceTransactionName ,
} from "utils/PerformanceTracker" ;
2020-10-06 15:10:21 +00:00
import { EventLocation } from "utils/AnalyticsUtil" ;
2020-12-14 16:22:45 +00:00
import { Variant } from "components/ads/common" ;
import { Toaster } from "components/ads/Toast" ;
2022-02-11 18:08:46 +00:00
import {
createMessage ,
ERROR_ACTION_RENAME_FAIL ,
} from "@appsmith/constants/messages" ;
2021-06-03 04:58:18 +00:00
import {
getIndextoUpdate ,
parseUrlForQueryParams ,
queryParamsRegEx ,
} from "utils/ApiPaneUtils" ;
2021-12-07 09:45:18 +00:00
import { updateReplayEntity } from "actions/pageActions" ;
import { ENTITY_TYPE } from "entities/AppsmithConsole" ;
2022-03-25 10:43:26 +00:00
import { Plugin } from "api/PluginApi" ;
2022-02-22 11:02:43 +00:00
import { getDisplayFormat } from "selectors/apiPaneSelectors" ;
2022-03-25 10:43:26 +00:00
import {
apiEditorIdURL ,
datasourcesEditorIdURL ,
integrationEditorURL ,
} from "RouteBuilder" ;
2022-07-11 04:06:29 +00:00
import { getCurrentPageId } from "selectors/editorSelectors" ;
2019-11-25 09:15:11 +00:00
2019-12-23 12:12:58 +00:00
function * syncApiParamsSaga (
actionPayload : ReduxActionWithMeta < string , { field : string } > ,
2020-07-14 06:53:33 +00:00
actionId : string ,
2019-12-23 12:12:58 +00:00
) {
const field = actionPayload . meta . field ;
2021-05-06 13:15:05 +00:00
//Payload here contains the path and query params of a typical url like https://{domain}/{path}?{query_params}
2021-06-03 04:58:18 +00:00
const value = actionPayload . payload ;
2021-05-06 13:15:05 +00:00
// Regular expression to find the query params group
2020-09-24 04:47:37 +00:00
PerformanceTracker . startTracking ( PerformanceTransactionName . SYNC_PARAMS_SAGA ) ;
2019-12-23 12:12:58 +00:00
if ( field === "actionConfiguration.path" ) {
2021-06-03 04:58:18 +00:00
const params = parseUrlForQueryParams ( value ) ;
yield put (
autofill (
API_EDITOR_FORM_NAME ,
"actionConfiguration.queryParameters" ,
params ,
) ,
) ;
yield put (
setActionProperty ( {
actionId : actionId ,
propertyName : "actionConfiguration.queryParameters" ,
value : params ,
} ) ,
) ;
2019-12-23 12:12:58 +00:00
} else if ( field . includes ( "actionConfiguration.queryParameters" ) ) {
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
2019-12-30 13:05:37 +00:00
const path = values . actionConfiguration . path || "" ;
2021-05-06 13:15:05 +00:00
const matchGroups = path . match ( queryParamsRegEx ) || [ ] ;
const currentPath = matchGroups [ 1 ] || "" ;
2019-12-23 12:12:58 +00:00
const paramsString = values . actionConfiguration . queryParameters
. filter ( ( p : Property ) = > p . key )
. map (
( p : Property , i : number ) = > ` ${ i === 0 ? "?" : "&" } ${ p . key } = ${ p . value } ` ,
)
. join ( "" ) ;
yield put (
autofill (
API_EDITOR_FORM_NAME ,
"actionConfiguration.path" ,
` ${ currentPath } ${ paramsString } ` ,
) ,
) ;
}
2020-09-24 04:47:37 +00:00
PerformanceTracker . stopTracking ( ) ;
2019-12-23 12:12:58 +00:00
}
2021-07-07 03:46:16 +00:00
function * redirectToNewIntegrations (
2021-07-29 08:13:10 +00:00
action : ReduxAction < {
pageId : string ;
params? : Record < string , string > ;
} > ,
2021-07-07 03:46:16 +00:00
) {
history . push (
2022-03-25 10:43:26 +00:00
integrationEditorURL ( {
pageId : action.payload.pageId ,
selectedTab : INTEGRATION_TABS.ACTIVE ,
params : {
. . . action . payload . params ,
mode : INTEGRATION_EDITOR_MODES.AUTO ,
} ,
} ) ,
2021-07-07 03:46:16 +00:00
) ;
}
2021-03-01 14:57:15 +00:00
function * handleUpdateBodyContentType (
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
action : ReduxAction < { title : string ; apiId : string } > ,
2021-03-01 14:57:15 +00:00
) {
2021-05-13 08:35:39 +00:00
const { apiId , title } = action . payload ;
2021-03-01 14:57:15 +00:00
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
2022-02-22 11:02:43 +00:00
// this is the previous value gotten before the new content type has been set
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const previousContentType =
2022-02-16 03:17:13 +00:00
values . actionConfiguration ? . formData ? . apiContentType ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const displayFormatValue = POST_BODY_FORMAT_OPTIONS_ARRAY . find (
( el ) = > el === title ,
2021-03-01 14:57:15 +00:00
) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if ( ! displayFormatValue ) {
2021-03-01 14:57:15 +00:00
log . error ( "Display format not supported" , title ) ;
return ;
}
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
2022-02-22 11:02:43 +00:00
// this is the update for the new apicontentType
// Quick Context: APiContentype is the field that represents the content type the user wants while in RAW mode.
// users should be able to set the content type to whatever they want.
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
let formData = { . . . values . actionConfiguration . formData } ;
if ( formData === undefined ) formData = { } ;
2022-02-22 11:02:43 +00:00
formData [ "apiContentType" ] =
2022-04-12 11:13:11 +00:00
title === POST_BODY_FORMAT_OPTIONS . NONE ? previousContentType : title ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
yield put (
change ( API_EDITOR_FORM_NAME , "actionConfiguration.formData" , formData ) ,
) ;
2022-02-22 11:02:43 +00:00
// Quick Context: The extra formadata action is responsible for updating the current multi switch mode you see on api editor body tab
// whenever a user selects a new content type through the tab e.g application/json, this action is dispatched to update that value, which is then read in the PostDataBody file
// to show the appropriate content type section.
yield put ( {
type : ReduxActionTypes . SET_EXTRA_FORMDATA ,
payload : {
id : apiId ,
values : {
displayFormat : {
label : title ,
value : title ,
2021-03-01 14:57:15 +00:00
} ,
} ,
2022-02-22 11:02:43 +00:00
} ,
} ) ;
2021-03-01 14:57:15 +00:00
const headers = cloneDeep ( values . actionConfiguration . headers ) ;
const contentTypeHeaderIndex = headers . findIndex (
( element : { key : string ; value : string } ) = >
element &&
element . key &&
element . key . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2021-03-23 09:44:44 +00:00
const indexToUpdate = getIndextoUpdate ( headers , contentTypeHeaderIndex ) ;
2021-03-01 14:57:15 +00:00
2022-06-18 06:26:45 +00:00
// If the user has selected "None" as the body type & there was a content-type
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
// header present in the API configuration, keep the previous content type header
2022-06-18 06:26:45 +00:00
// this is done to ensure user input isn't cleared off if they switch to none mode.
2022-02-22 11:02:43 +00:00
// however if the user types in a new value, we use the updated value (formValueChangeSaga - line 426).
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if (
2022-04-12 11:13:11 +00:00
displayFormatValue === POST_BODY_FORMAT_OPTIONS . NONE &&
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
indexToUpdate !== - 1
) {
2022-06-18 06:26:45 +00:00
//Checking if any type was seleccted before
if ( contentTypeHeaderIndex !== - 1 ) {
headers [ indexToUpdate ] = {
key : previousContentType ? CONTENT_TYPE_HEADER_KEY : "" ,
value : previousContentType ? previousContentType : "" ,
} ;
}
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
} else {
headers [ indexToUpdate ] = {
key : CONTENT_TYPE_HEADER_KEY ,
value : displayFormatValue ,
} ;
}
2021-03-01 14:57:15 +00:00
2022-02-22 11:02:43 +00:00
// update the new header values.
2021-03-01 14:57:15 +00:00
yield put (
change ( API_EDITOR_FORM_NAME , "actionConfiguration.headers" , headers ) ,
) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const bodyFormData = cloneDeep ( values . actionConfiguration . bodyFormData ) ;
2021-08-25 10:48:17 +00:00
if (
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
displayFormatValue === POST_BODY_FORMAT_OPTIONS . FORM_URLENCODED ||
displayFormatValue === POST_BODY_FORMAT_OPTIONS . MULTIPART_FORM_DATA
2021-08-25 10:48:17 +00:00
) {
2021-03-01 14:57:15 +00:00
if ( ! bodyFormData || bodyFormData . length === 0 ) {
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.bodyFormData" ,
EMPTY_KEY_VALUE_PAIRS . slice ( ) ,
) ,
) ;
}
}
}
2022-04-12 11:13:11 +00:00
function * updateExtraFormDataSaga() {
2022-06-21 13:57:34 +00:00
const formData : GetFormData = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
2020-05-07 07:56:37 +00:00
const { values } = formData ;
2022-02-22 11:02:43 +00:00
// when initializing, check if theres a display format present, if not use Json display format as default.
2022-06-21 13:57:34 +00:00
const extraFormData : GetFormData = yield select ( getDisplayFormat , values . id ) ;
2022-02-22 11:02:43 +00:00
2022-04-12 11:13:11 +00:00
const headers : Array < { key : string ; value : string } > =
get ( values , "actionConfiguration.headers" ) || [ ] ;
const contentTypeValue : string =
headers . find (
( h : { key : string ; value : string } ) = > h . key === CONTENT_TYPE_HEADER_KEY ,
) ? . value || "" ;
let rawApiContentType ;
2022-02-22 11:02:43 +00:00
if ( ! extraFormData ) {
2022-04-12 11:13:11 +00:00
/ *
* Checking if the content - type header exists , if yes then set the body format type one of the three json , multipart or url encoded whichever matches else set raw as default
* /
if (
[
POST_BODY_FORMAT_OPTIONS . JSON ,
POST_BODY_FORMAT_OPTIONS . FORM_URLENCODED ,
POST_BODY_FORMAT_OPTIONS . MULTIPART_FORM_DATA ,
] . includes ( contentTypeValue )
) {
rawApiContentType = contentTypeValue ;
2022-06-01 10:29:58 +00:00
} else if (
contentTypeValue === "" ||
contentTypeValue === POST_BODY_FORMAT_OPTIONS . NONE
) {
rawApiContentType = POST_BODY_FORMAT_OPTIONS . NONE ;
2022-04-12 11:13:11 +00:00
} else {
rawApiContentType = POST_BODY_FORMAT_OPTIONS . RAW ;
}
} else {
if (
[
POST_BODY_FORMAT_OPTIONS . JSON ,
POST_BODY_FORMAT_OPTIONS . FORM_URLENCODED ,
POST_BODY_FORMAT_OPTIONS . MULTIPART_FORM_DATA ,
] . includes ( contentTypeValue )
) {
rawApiContentType = contentTypeValue ;
2022-06-01 10:29:58 +00:00
} else if (
contentTypeValue === "" ||
contentTypeValue === POST_BODY_FORMAT_OPTIONS . NONE
) {
rawApiContentType = POST_BODY_FORMAT_OPTIONS . NONE ;
2022-04-12 11:13:11 +00:00
} else {
rawApiContentType = POST_BODY_FORMAT_OPTIONS . RAW ;
}
2020-05-07 07:56:37 +00:00
}
2022-04-12 11:13:11 +00:00
yield call ( setHeaderFormat , values . id , rawApiContentType ) ;
2020-05-07 07:56:37 +00:00
}
2021-05-04 13:08:20 +00:00
function * changeApiSaga (
2021-12-07 09:45:18 +00:00
actionPayload : ReduxAction < { id : string ; isSaas : boolean ; action? : Action } > ,
2021-05-04 13:08:20 +00:00
) {
2020-09-24 04:47:37 +00:00
PerformanceTracker . startTracking ( PerformanceTransactionName . CHANGE_API_SAGA ) ;
2021-05-04 13:08:20 +00:00
const { id , isSaas } = actionPayload . payload ;
2021-12-07 09:45:18 +00:00
let { action } = actionPayload . payload ;
if ( ! action ) action = yield select ( getAction , id ) ;
2020-05-07 07:09:07 +00:00
if ( ! action ) return ;
2021-05-04 13:08:20 +00:00
if ( isSaas ) {
2022-04-07 16:18:49 +00:00
yield put ( initialize ( QUERY_EDITOR_FORM_NAME , action ) ) ;
2021-05-04 13:08:20 +00:00
} else {
yield put ( initialize ( API_EDITOR_FORM_NAME , action ) ) ;
2020-05-07 07:56:37 +00:00
2022-04-12 11:13:11 +00:00
yield call ( updateExtraFormDataSaga ) ;
2020-05-07 07:56:37 +00:00
2021-05-04 13:08:20 +00:00
if (
action . actionConfiguration &&
action . actionConfiguration . queryParameters ? . length
) {
// Sync the api params my mocking a change action
yield call (
syncApiParamsSaga ,
{
type : ReduxFormActionTypes . ARRAY_REMOVE ,
payload : action.actionConfiguration.queryParameters ,
meta : {
field : "actionConfiguration.queryParameters" ,
} ,
2020-07-14 06:53:33 +00:00
} ,
2021-05-04 13:08:20 +00:00
id ,
) ;
}
2019-12-30 13:05:37 +00:00
}
2021-05-04 13:08:20 +00:00
2021-12-07 09:45:18 +00:00
//Retrieve form data with synced query params to start tracking change history.
const { values : actionPostProcess } = yield select (
getFormData ,
API_EDITOR_FORM_NAME ,
) ;
2020-09-24 04:47:37 +00:00
PerformanceTracker . stopTracking ( ) ;
2021-12-07 09:45:18 +00:00
yield put ( updateReplayEntity ( id , actionPostProcess , ENTITY_TYPE . ACTION ) ) ;
2019-11-25 09:15:11 +00:00
}
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
function * setHeaderFormat ( apiId : string , apiContentType? : string ) {
// use the current apiContentType to set appropriate Headers for action
2021-04-26 05:41:32 +00:00
let displayFormat ;
2022-02-22 11:02:43 +00:00
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if ( apiContentType ) {
if ( apiContentType === POST_BODY_FORMAT_OPTIONS . NONE ) {
displayFormat = {
label : POST_BODY_FORMAT_OPTIONS.NONE ,
value : POST_BODY_FORMAT_OPTIONS.NONE ,
} ;
} else if (
apiContentType !== POST_BODY_FORMAT_OPTIONS . NONE &&
Object . values ( POST_BODY_FORMAT_OPTIONS ) . includes ( apiContentType )
2021-04-26 05:41:32 +00:00
) {
displayFormat = {
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
label : apiContentType ,
value : apiContentType ,
2021-04-26 05:41:32 +00:00
} ;
} else {
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
displayFormat = {
label : POST_BODY_FORMAT_OPTIONS.RAW ,
value : POST_BODY_FORMAT_OPTIONS.RAW ,
} ;
2021-04-26 05:41:32 +00:00
}
}
yield put ( {
type : ReduxActionTypes . SET_EXTRA_FORMDATA ,
payload : {
id : apiId ,
values : {
displayFormat ,
} ,
} ,
} ) ;
}
2021-12-07 09:45:18 +00:00
export function * updateFormFields (
2020-04-14 12:34:14 +00:00
actionPayload : ReduxActionWithMeta < string , { field : string } > ,
) {
const field = actionPayload . meta . field ;
const value = actionPayload . payload ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
log . debug ( "updateFormFields: " + JSON . stringify ( value ) ) ;
2020-07-03 08:58:58 +00:00
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
2020-04-14 12:34:14 +00:00
2022-02-22 11:02:43 +00:00
// get current content type of the action
2022-03-03 15:32:59 +00:00
let apiContentType =
values ? . actionConfiguration ? . formData ? . apiContentType ||
POST_BODY_FORMAT_OPTIONS . JSON ;
2022-04-12 11:13:11 +00:00
let extraFormDataToBeChanged = false ;
2020-04-14 12:34:14 +00:00
if ( field === "actionConfiguration.httpMethod" ) {
2021-03-16 14:27:21 +00:00
const { actionConfiguration } = values ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if ( ! actionConfiguration . headers ) return ;
2021-03-16 14:27:21 +00:00
const actionConfigurationHeaders = cloneDeep ( actionConfiguration . headers ) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const contentTypeHeaderIndex = actionConfigurationHeaders . findIndex (
( header : { key : string ; value : string } ) = >
header ? . key ? . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2022-06-01 10:29:58 +00:00
const indexToUpdate = getIndextoUpdate (
actionConfigurationHeaders ,
contentTypeHeaderIndex ,
) ;
2022-06-18 06:26:45 +00:00
//When user switches to GET method, content type remains same (empty or any type)
//This condition handles other HTTP methods
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if ( value !== HTTP_METHOD . GET ) {
// if user switches to other methods that is not GET and apiContentType is undefined set default apiContentType to JSON.
2022-04-12 11:13:11 +00:00
if ( apiContentType === POST_BODY_FORMAT_OPTIONS . NONE ) {
apiContentType =
HTTP_METHODS_DEFAULT_FORMAT_TYPES [ value as HTTP_METHOD ] ;
extraFormDataToBeChanged = true ;
}
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
actionConfigurationHeaders [ indexToUpdate ] = {
key : CONTENT_TYPE_HEADER_KEY ,
value : apiContentType ,
} ;
2020-04-14 12:34:14 +00:00
}
2022-02-22 11:02:43 +00:00
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.headers" ,
actionConfigurationHeaders ,
) ,
) ;
2022-04-12 11:13:11 +00:00
if ( extraFormDataToBeChanged ) yield call ( updateExtraFormDataSaga ) ;
2020-04-14 12:34:14 +00:00
}
}
2020-07-03 08:58:58 +00:00
function * formValueChangeSaga (
actionPayload : ReduxActionWithMeta < string , { field : string ; form : string } > ,
2020-06-04 13:49:22 +00:00
) {
2021-05-13 08:35:39 +00:00
const { field , form } = actionPayload . meta ;
2020-07-03 08:58:58 +00:00
if ( form !== API_EDITOR_FORM_NAME ) return ;
2020-07-06 13:35:31 +00:00
if ( field === "dynamicBindingPathList" || field === "name" ) return ;
2020-06-04 13:49:22 +00:00
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
if ( ! values . id ) return ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const contentTypeHeaderIndex = values . actionConfiguration . headers . findIndex (
( header : { key : string ; value : string } ) = >
header ? . key ? . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2020-07-03 08:58:58 +00:00
if (
actionPayload . type === ReduxFormActionTypes . ARRAY_REMOVE ||
actionPayload . type === ReduxFormActionTypes . ARRAY_PUSH
) {
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
const value = get ( values , field ) ;
2020-07-14 06:53:33 +00:00
yield put (
setActionProperty ( {
actionId : values.id ,
propertyName : field ,
value ,
} ) ,
) ;
2020-07-03 08:58:58 +00:00
} else {
2020-06-12 08:35:52 +00:00
yield put (
2020-07-03 08:58:58 +00:00
setActionProperty ( {
actionId : values.id ,
propertyName : field ,
value : actionPayload.payload ,
} ) ,
2020-06-12 08:35:52 +00:00
) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
// when user types a content type value, update actionConfiguration.formData.apiContent type as well.
2022-02-22 11:02:43 +00:00
// we don't do this initally because we want to specifically catch user editing the content-type value
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if (
field === ` actionConfiguration.headers[ ${ contentTypeHeaderIndex } ].value `
) {
2022-02-22 11:02:43 +00:00
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.formData.apiContentType" ,
actionPayload . payload ,
) ,
) ;
const apiId = get ( values , "id" ) ;
// when the user specifically sets a new content type value, we check if the input value is a supported post body type and switch to it
// if it does not we set the default to Raw mode.
yield call ( setHeaderFormat , apiId , actionPayload . payload ) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
}
2020-06-12 08:35:52 +00:00
}
2019-12-23 12:12:58 +00:00
yield all ( [
2020-07-14 06:53:33 +00:00
call ( syncApiParamsSaga , actionPayload , values . id ) ,
2020-04-14 12:34:14 +00:00
call ( updateFormFields , actionPayload ) ,
2019-12-23 12:12:58 +00:00
] ) ;
2021-12-07 09:45:18 +00:00
// We need to refetch form values here since syncApuParams saga and updateFormFields directly update reform form values.
const { values : formValuesPostProcess } = yield select (
getFormData ,
API_EDITOR_FORM_NAME ,
) ;
yield put (
updateReplayEntity (
formValuesPostProcess . id ,
formValuesPostProcess ,
ENTITY_TYPE . ACTION ,
) ,
) ;
2019-11-25 09:15:11 +00:00
}
2019-12-23 12:12:58 +00:00
2021-01-12 04:17:28 +00:00
function * handleActionCreatedSaga ( actionPayload : ReduxAction < Action > ) {
2020-05-05 07:50:30 +00:00
const { id , pluginType } = actionPayload . payload ;
2022-06-21 13:57:34 +00:00
const action : Action | undefined = yield select ( getAction , id ) ;
const data = action ? { . . . action } : { } ;
2022-07-11 04:06:29 +00:00
const pageId : string = yield select ( getCurrentPageId ) ;
2020-05-05 07:50:30 +00:00
2021-04-22 03:30:09 +00:00
if ( pluginType === PluginType . API ) {
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
yield put ( initialize ( API_EDITOR_FORM_NAME , omit ( data , "name" ) ) ) ;
2020-07-06 05:38:39 +00:00
history . push (
2022-03-25 10:43:26 +00:00
apiEditorIdURL ( {
2022-07-11 04:06:29 +00:00
pageId ,
2022-03-25 10:43:26 +00:00
apiId : id ,
params : {
editName : "true" ,
from : "datasources" ,
} ,
2020-07-06 05:38:39 +00:00
} ) ,
) ;
2020-05-05 07:50:30 +00:00
}
2019-11-25 09:15:11 +00:00
}
2021-04-22 03:30:09 +00:00
function * handleDatasourceCreatedSaga ( actionPayload : ReduxAction < Datasource > ) {
2022-06-21 13:57:34 +00:00
const plugin : Plugin | undefined = yield select (
2022-03-25 10:43:26 +00:00
getPlugin ,
actionPayload . payload . pluginId ,
) ;
2022-07-11 04:06:29 +00:00
const pageId : string = yield select ( getCurrentPageId ) ;
2021-04-22 03:30:09 +00:00
// Only look at API plugins
2022-06-21 13:57:34 +00:00
if ( plugin && plugin . type !== PluginType . API ) return ;
2021-04-22 03:30:09 +00:00
history . push (
2022-03-25 10:43:26 +00:00
datasourcesEditorIdURL ( {
2022-07-11 04:06:29 +00:00
pageId ,
2022-03-25 10:43:26 +00:00
datasourceId : actionPayload.payload.id ,
params : {
2021-07-07 03:46:16 +00:00
from : "datasources" ,
2021-07-29 08:13:10 +00:00
. . . getQueryParams ( ) ,
2021-07-07 03:46:16 +00:00
} ,
2022-03-25 10:43:26 +00:00
} ) ,
2021-04-22 03:30:09 +00:00
) ;
}
2022-09-09 15:59:47 +00:00
/ * *
* Creates an API with datasource as DEFAULT_REST_DATASOURCE ( No user created datasource )
* @param action
* /
2020-04-20 08:26:19 +00:00
function * handleCreateNewApiActionSaga (
2022-09-09 15:59:47 +00:00
action : ReduxAction < {
pageId : string ;
from : EventLocation ;
apiType? : string ;
} > ,
2020-04-20 08:26:19 +00:00
) {
2022-06-15 15:37:41 +00:00
const workspaceId : string = yield select ( getCurrentWorkspaceId ) ;
2022-09-09 15:59:47 +00:00
const { pageId , apiType = REST_PLUGIN_PACKAGE_NAME } = action . payload ;
const pluginId : string = yield select ( getPluginIdOfPackageName , apiType ) ;
// Default Config is Rest Api Plugin Config
let defaultConfig = DEFAULT_CREATE_API_CONFIG ;
if ( apiType === GRAPHQL_PLUGIN_PACKAGE_NAME ) {
defaultConfig = DEFAULT_CREATE_GRAPHQL_CONFIG ;
}
2020-04-20 08:26:19 +00:00
if ( pageId && pluginId ) {
2022-06-21 13:57:34 +00:00
const actions : ActionDataState = yield select ( getActions ) ;
2020-04-20 08:26:19 +00:00
const pageActions = actions . filter (
( a : ActionData ) = > a . config . pageId === pageId ,
) ;
const newActionName = createNewApiName ( pageActions , pageId ) ;
2021-02-16 15:01:35 +00:00
// Note: Do NOT send pluginId on top level here.
// It breaks embedded rest datasource flow.
2020-04-20 08:26:19 +00:00
yield put (
createActionRequest ( {
2022-09-09 15:59:47 +00:00
actionConfiguration : defaultConfig.config ,
2020-04-20 08:26:19 +00:00
name : newActionName ,
datasource : {
2022-09-09 15:59:47 +00:00
name : defaultConfig.datasource.name ,
2020-04-20 08:26:19 +00:00
pluginId ,
2022-06-15 15:37:41 +00:00
workspaceId ,
2020-04-20 08:26:19 +00:00
} ,
2020-10-06 15:10:21 +00:00
eventData : {
2022-09-09 15:59:47 +00:00
actionType : defaultConfig.eventData.actionType ,
2020-10-06 15:10:21 +00:00
from : action . payload . from ,
} ,
2020-04-20 08:26:19 +00:00
pageId ,
2021-01-12 04:17:28 +00:00
} as ApiAction ) , // We don't have recursive partial in typescript for now.
2020-04-20 08:26:19 +00:00
) ;
}
}
2020-08-19 09:21:32 +00:00
function * handleApiNameChangeSaga (
action : ReduxAction < { id : string ; name : string } > ,
) {
2020-06-18 14:16:49 +00:00
yield put ( change ( API_EDITOR_FORM_NAME , "name" , action . payload . name ) ) ;
}
2020-08-19 09:21:32 +00:00
function * handleApiNameChangeSuccessSaga (
action : ReduxAction < { actionId : string } > ,
) {
const { actionId } = action . payload ;
2022-06-21 13:57:34 +00:00
const actionObj : Action | undefined = yield select ( getAction , actionId ) ;
2020-08-19 09:21:32 +00:00
yield take ( ReduxActionTypes . FETCH_ACTIONS_FOR_PAGE_SUCCESS ) ;
2020-12-14 16:22:45 +00:00
if ( ! actionObj ) {
// Error case, log to sentry
Toaster . show ( {
2021-04-20 06:56:30 +00:00
text : createMessage ( ERROR_ACTION_RENAME_FAIL , "" ) ,
2020-12-14 16:22:45 +00:00
variant : Variant.danger ,
} ) ;
2021-03-13 14:24:45 +00:00
Sentry . captureException (
2021-04-20 06:56:30 +00:00
new Error ( createMessage ( ERROR_ACTION_RENAME_FAIL , "" ) ) ,
2021-03-13 14:24:45 +00:00
{
extra : {
actionId : actionId ,
} ,
2020-12-14 16:22:45 +00:00
} ,
2021-03-13 14:24:45 +00:00
) ;
2020-12-14 16:22:45 +00:00
return ;
}
2021-04-22 03:30:09 +00:00
if ( actionObj . pluginType === PluginType . API ) {
const params = getQueryParams ( ) ;
if ( params . editName ) {
params . editName = "false" ;
}
2022-03-25 10:43:26 +00:00
history . push (
apiEditorIdURL ( {
2022-07-11 04:06:29 +00:00
pageId : actionObj.pageId ,
2022-03-25 10:43:26 +00:00
apiId : actionId ,
params ,
} ) ,
) ;
2021-04-22 03:30:09 +00:00
}
2020-08-19 09:21:32 +00:00
}
2020-06-18 14:16:49 +00:00
function * handleApiNameChangeFailureSaga (
action : ReduxAction < { oldName : string } > ,
) {
yield put ( change ( API_EDITOR_FORM_NAME , "name" , action . payload . oldName ) ) ;
}
2019-11-25 09:15:11 +00:00
export default function * root() {
yield all ( [
takeEvery ( ReduxActionTypes . API_PANE_CHANGE_API , changeApiSaga ) ,
takeEvery ( ReduxActionTypes . CREATE_ACTION_SUCCESS , handleActionCreatedSaga ) ,
2021-04-22 03:30:09 +00:00
takeEvery (
ReduxActionTypes . CREATE_DATASOURCE_SUCCESS ,
handleDatasourceCreatedSaga ,
) ,
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
takeEvery ( ReduxActionTypes . SAVE_ACTION_NAME_INIT , handleApiNameChangeSaga ) ,
2020-08-19 09:21:32 +00:00
takeEvery (
ReduxActionTypes . SAVE_ACTION_NAME_SUCCESS ,
handleApiNameChangeSuccessSaga ,
) ,
2020-06-18 14:16:49 +00:00
takeEvery (
2020-08-18 08:48:06 +00:00
ReduxActionErrorTypes . SAVE_ACTION_NAME_ERROR ,
2020-06-18 14:16:49 +00:00
handleApiNameChangeFailureSaga ,
) ,
2020-04-20 08:26:19 +00:00
takeEvery (
ReduxActionTypes . CREATE_NEW_API_ACTION ,
handleCreateNewApiActionSaga ,
) ,
2021-03-01 14:57:15 +00:00
takeEvery (
ReduxActionTypes . UPDATE_API_ACTION_BODY_CONTENT_TYPE ,
handleUpdateBodyContentType ,
) ,
2021-07-07 03:46:16 +00:00
takeEvery (
ReduxActionTypes . REDIRECT_TO_NEW_INTEGRATIONS ,
redirectToNewIntegrations ,
) ,
2019-12-23 12:12:58 +00:00
// Intercepting the redux-form change actionType
takeEvery ( ReduxFormActionTypes . VALUE_CHANGE , formValueChangeSaga ) ,
takeEvery ( ReduxFormActionTypes . ARRAY_REMOVE , formValueChangeSaga ) ,
2020-04-14 12:34:14 +00:00
takeEvery ( ReduxFormActionTypes . ARRAY_PUSH , formValueChangeSaga ) ,
2019-11-25 09:15:11 +00:00
] ) ;
}