From 914d20ad37a13049d3b074d35da56655e7be7e57 Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Tue, 4 Jan 2022 21:42:55 +0530 Subject: [PATCH] feat: duplicate team requests --- .../components/collections/index.vue | 25 +++++++++++++++---- .../collections/teams/Collection.vue | 3 +++ .../components/collections/teams/Folder.vue | 3 +++ .../components/collections/teams/Request.vue | 19 ++++++++++++++ 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/packages/hoppscotch-app/components/collections/index.vue b/packages/hoppscotch-app/components/collections/index.vue index 4318ffe4f..2c9fefd0b 100644 --- a/packages/hoppscotch-app/components/collections/index.vue +++ b/packages/hoppscotch-app/components/collections/index.vue @@ -647,11 +647,26 @@ export default defineComponent({ }) } }, - duplicateRequest({ folderPath, request }) { - saveRESTRequestAs(folderPath, { - ...cloneDeep(request), - name: `${request.name} - ${this.$t("action.duplicate")}`, - }) + duplicateRequest({ folderPath, request, collectionID }) { + if (this.collectionsType.type === "team-collections") { + const newReq = { + ...cloneDeep(request), + name: `${request.name} - ${this.$t("action.duplicate")}`, + } + + teamUtils.saveRequestAsTeams( + this.$apollo, + JSON.stringify(newReq), + `${request.name} - ${this.$t("action.duplicate")}`, + this.collectionsType.selectedTeam.id, + collectionID + ) + } else if (this.collectionsType.type === "my-collections") { + saveRESTRequestAs(folderPath, { + ...cloneDeep(request), + name: `${request.name} - ${this.$t("action.duplicate")}`, + }) + } }, }, }) diff --git a/packages/hoppscotch-app/components/collections/teams/Collection.vue b/packages/hoppscotch-app/components/collections/teams/Collection.vue index 20e9febc5..65f6152dc 100644 --- a/packages/hoppscotch-app/components/collections/teams/Collection.vue +++ b/packages/hoppscotch-app/components/collections/teams/Collection.vue @@ -152,6 +152,7 @@ @select="$emit('select', $event)" @expand-collection="expandCollection" @remove-request="removeRequest" + @duplicate-request="$emit('duplicate-request', $event)" />
@@ -102,6 +103,22 @@ } " /> + {} }, picked: { type: Object, default: () => {} }, + collectionID: { type: String, default: null }, }, setup() { const active = useReadonlyStream(restSaveContext$, null) @@ -159,6 +177,7 @@ export default defineComponent({ options: ref(null), edit: ref(null), deleteAction: ref(null), + duplicate: ref(null), } }, data() {