From 1573ddad1b6ea13c5d7a6b97f58328e01755d79f Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 19 Jul 2021 05:59:22 -0400 Subject: [PATCH] feat: initial attempt at restoring codegen --- components/http/CodegenModal.vue | 59 ++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/components/http/CodegenModal.vue b/components/http/CodegenModal.vue index 008441ed7..9310dbc34 100644 --- a/components/http/CodegenModal.vue +++ b/components/http/CodegenModal.vue @@ -35,7 +35,7 @@ focus:outline-none " > - {{ codegens.find((x) => x.id === requestType).name }} + {{ codegens.find((x) => x.id === codegenType).name }} @@ -66,10 +66,10 @@ /> x.id === this.codegenType)! + .generator({ + auth: "None", + httpUser: null, + httpPassword: null, + method: effectiveRequest.method, + url: baseURL, + pathName: path, + queryString: urlObj.searchParams.toString(), + bearerToken: null, + headers: effectiveRequest.effectiveFinalHeaders, + rawInput: null, + rawParams: null, + rawRequestBody: "", + contentType: effectiveRequest.effectiveFinalHeaders.find( + (x) => x.key === "content-type" + ), + }) }, }, watch: { @@ -123,9 +146,6 @@ export default defineComponent({ }, }, methods: { - requestCode() { - return getEffectiveRESTRequest(this.request, getCurrentEnvironment()) - }, hideModal() { this.$emit("hide-modal") }, @@ -133,15 +153,16 @@ export default defineComponent({ this.$emit("handle-import") }, copyRequestCode() { - ;(this.$refs.generatedCode as any).editor - .selectAll()(this.$refs.generatedCode as any) - .editor.focus() + const editor: any = this.$refs.generatedCode + + editor.editor.selectAll() + editor.editor.focus() + document.execCommand("copy") this.copyIcon = "done" this.$toast.success(this.$t("copied_to_clipboard").toString(), { icon: "done", }) - setTimeout(() => (this.copyIcon = "content_copy"), 1000) }, }, })