From c3b784c6805c89143fe5be6c8a94c2dea26cd9dc Mon Sep 17 00:00:00 2001 From: Nivedin <53208152+nivedin@users.noreply.github.com> Date: Thu, 5 May 2022 20:46:28 +0530 Subject: [PATCH] fix : save request popup bug (#2324) --- .../components/collections/SaveRequest.vue | 6 ++++++ .../hoppscotch-app/components/http/Request.vue | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-app/components/collections/SaveRequest.vue b/packages/hoppscotch-app/components/collections/SaveRequest.vue index 06f775fc6..8f635dce5 100644 --- a/packages/hoppscotch-app/components/collections/SaveRequest.vue +++ b/packages/hoppscotch-app/components/collections/SaveRequest.vue @@ -233,6 +233,7 @@ const saveRequestAs = async () => { originLocation: "user-collection", folderPath: picked.value.folderPath, requestIndex: picked.value.requestIndex, + req: cloneDeep(requestUpdated), }) requestSaved() @@ -249,6 +250,7 @@ const saveRequestAs = async () => { originLocation: "user-collection", folderPath: picked.value.folderPath, requestIndex: insertionIndex, + req: cloneDeep(requestUpdated), }) requestSaved() @@ -265,6 +267,7 @@ const saveRequestAs = async () => { originLocation: "user-collection", folderPath: `${picked.value.collectionIndex}`, requestIndex: insertionIndex, + req: cloneDeep(requestUpdated), }) requestSaved() @@ -293,6 +296,7 @@ const saveRequestAs = async () => { setRESTSaveContext({ originLocation: "team-collection", requestID: picked.value.requestID, + req: cloneDeep(requestUpdated), }) } else if (picked.value.pickedType === "teams-folder") { if (!isHoppRESTRequest(requestUpdated)) @@ -319,6 +323,7 @@ const saveRequestAs = async () => { requestID: result.right.createRequestInCollection.id, teamID: collectionsType.value.selectedTeam.id, collectionID: picked.value.folderID, + req: cloneDeep(requestUpdated), }) requestSaved() @@ -348,6 +353,7 @@ const saveRequestAs = async () => { requestID: result.right.createRequestInCollection.id, teamID: collectionsType.value.selectedTeam.id, collectionID: picked.value.collectionID, + req: cloneDeep(requestUpdated), }) requestSaved() diff --git a/packages/hoppscotch-app/components/http/Request.vue b/packages/hoppscotch-app/components/http/Request.vue index 7939be844..4aa0594fb 100644 --- a/packages/hoppscotch-app/components/http/Request.vue +++ b/packages/hoppscotch-app/components/http/Request.vue @@ -208,6 +208,7 @@ import { computed, ref, watch } from "@nuxtjs/composition-api" import { isLeft, isRight } from "fp-ts/lib/Either" import * as E from "fp-ts/Either" +import cloneDeep from "lodash/cloneDeep" import { updateRESTResponse, restEndpoint$, @@ -477,14 +478,21 @@ const saveRequest = () => { showSaveRequestModal.value = true return } - if (saveCtx.originLocation === "user-collection") { + const req = getRESTRequest() + try { editRESTRequest( saveCtx.folderPath, saveCtx.requestIndex, getRESTRequest() ) + setRESTSaveContext({ + originLocation: "user-collection", + folderPath: saveCtx.folderPath, + requestIndex: saveCtx.requestIndex, + req: cloneDeep(req), + }) toast.success(`${t("request.saved")}`) } catch (e) { setRESTSaveContext(null) @@ -505,6 +513,11 @@ const saveRequest = () => { if (E.isLeft(result)) { toast.error(`${t("profile.no_permission")}`) } else { + setRESTSaveContext({ + originLocation: "team-collection", + requestID: saveCtx.requestID, + req: cloneDeep(req), + }) toast.success(`${t("request.saved")}`) } })