From 8d4c56dbd9007ec180b5eb164de32702b2765af4 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Sun, 2 Oct 2022 03:27:55 +0530 Subject: [PATCH] feat: save query params in request, resolves #5 --- .../providers/ReduxStore/slices/collections.js | 4 ++-- renderer/utils/collections/index.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/renderer/providers/ReduxStore/slices/collections.js b/renderer/providers/ReduxStore/slices/collections.js index 9c63b952..37823097 100644 --- a/renderer/providers/ReduxStore/slices/collections.js +++ b/renderer/providers/ReduxStore/slices/collections.js @@ -170,7 +170,7 @@ export const collectionsSlice = createSlice({ if(collection) { const item = findItemInCollection(collection, action.payload.itemUid); - + if(item && isItemARequest(item)) { if(!item.draft) { item.draft = cloneDeep(item); @@ -194,7 +194,7 @@ export const collectionsSlice = createSlice({ } }); - // ultimately params get replaced with params in url + the disabled onces that existed prior + // ultimately params get replaced with params in url + the disabled ones that existed prior // the query params are the source of truth, the url in the queryurl input gets constructed using these params // we however are also storing the full url (with params) in the url itself item.draft.request.params = concat(urlParams, disabledParams); diff --git a/renderer/utils/collections/index.js b/renderer/utils/collections/index.js index ac1e403d..c1f8b449 100644 --- a/renderer/utils/collections/index.js +++ b/renderer/utils/collections/index.js @@ -100,6 +100,18 @@ export const transformCollectionToSaveToIdb = (collection, options = {}) => { }); }; + const copyQueryParams = (params) => { + return map(params, (param) => { + return { + uid: param.uid, + name: param.name, + value: param.value, + description: param.description, + enabled: param.enabled + } + }); + }; + const copyItems = (sourceItems, destItems) => { each(sourceItems, (si) => { const di = { @@ -116,6 +128,7 @@ export const transformCollectionToSaveToIdb = (collection, options = {}) => { url: si.draft.request.url, method: si.draft.request.method, headers: copyHeaders(si.draft.request.headers), + params: copyQueryParams(si.draft.request.params), body: { mode: si.draft.request.body.mode, content: replaceTabsWithSpaces(si.draft.request.body.content) @@ -128,6 +141,7 @@ export const transformCollectionToSaveToIdb = (collection, options = {}) => { url: si.request.url, method: si.request.method, headers: copyHeaders(si.request.headers), + params: copyQueryParams(si.request.params), body: { mode: si.request.body.mode, content: replaceTabsWithSpaces(si.request.body.content)