Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: drag and drop on collections

Andrew Bastin66bb9dc42bc7
diff --git a/components/collections/ImportExport.vue b/components/collections/ImportExport.vue
index 57cab3c3e..2fbad2ef0 100644
--- a/components/collections/ImportExport.vue
+++ b/components/collections/ImportExport.vue
@@ -67,24 +67,6 @@
</div>
<div slot="body" class="flex flex-col">
<div v-if="mode == 'import_export'" class="flex flex-col items-start p-2">
- <span
- v-tooltip="{
- content: !fb.currentUser
- ? $t('login_first')
- : $t('replace_current'),
- }"
- >
- <!-- TODO: wtf -->
- <button
- v-if="collectionsType.type == 'my-collections'"
- :disabled="!fb.currentUser"
- class="icon"
- @click="syncCollections"
- >
- <i class="material-icons">folder_shared</i>
- <span>{{ $t("import_from_sync") }}</span>
- </button>
- </span>
<button
v-tooltip="$t('replace_current')"
class="icon"
@@ -214,6 +196,7 @@ export default {
mode: "import_export",
mySelectedCollectionID: undefined,
collectionJson: "",
+ fb
}
},
subscriptions() {
@@ -267,7 +250,6 @@ export default {
const collections = JSON.parse(Object.values(files)[0].content)
setRESTCollections(collections)
this.fileImported()
- this.syncToFBCollections()
})
.catch((error) => {
this.failedImport()
@@ -328,7 +310,6 @@ export default {
} else {
setRESTCollections(collections)
this.fileImported()
- this.syncToFBCollections()
}
}
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
@@ -382,7 +363,6 @@ export default {
})
} else {
appendRESTCollections(collections)
- this.syncToFBCollections()
this.fileImported()
}
}
@@ -411,7 +391,7 @@ export default {
},
async getJSONCollection() {
if (this.collectionsType.type === "my-collections") {
- this.collectionJson = JSON.stringify(myCollections, null, 2)
+ this.collectionJson = JSON.stringify(this.myCollections, null, 2)
} else {
this.collectionJson = await teamUtils.exportAsJSON(
this.$apollo,
diff --git a/components/collections/my/Collection.vue b/components/collections/my/Collection.vue
index e94713619..518fd5855 100644
--- a/components/collections/my/Collection.vue
+++ b/components/collections/my/Collection.vue
@@ -163,8 +163,7 @@
</template>
<script>
-import { fb } from "~/helpers/fb"
-import { getSettingSubject } from "~/newstore/settings"
+import { moveRESTRequest } from "~/newstore/collections"
export default {
props: {
@@ -188,11 +187,6 @@ export default {
pageNo: 0,
}
},
- subscriptions() {
- return {
- SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
- }
- },
computed: {
isSelected() {
return (
@@ -206,14 +200,6 @@ export default {
editRequest(event) {
this.$emit("edit-request", event)
},
- syncCollections() {
- if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
- fb.writeCollections(
- JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
- "collections"
- )
- }
- },
toggleShowChildren() {
if (this.$props.saveRequest)
this.$emit("select", {
@@ -236,22 +222,9 @@ export default {
},
dropEvent({ dataTransfer }) {
this.dragging = !this.dragging
- const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
- const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
- const oldFolderName = dataTransfer.getData("oldFolderName")
+ const folderPath = dataTransfer.getData("folderPath")
const requestIndex = dataTransfer.getData("requestIndex")
- const flag = "rest"
- this.$store.commit("postwoman/moveRequest", {
- oldCollectionIndex,
- newCollectionIndex: this.$props.collectionIndex,
- newFolderIndex: -1,
- newFolderName: this.$props.collection.name,
- oldFolderIndex,
- oldFolderName,
- requestIndex,
- flag,
- })
- this.syncCollections()
+ moveRESTRequest(folderPath, requestIndex, this.collectionIndex.toString())
},
},
}
diff --git a/components/collections/my/Folder.vue b/components/collections/my/Folder.vue
index fb3c1edc5..8b13bd3b2 100644
--- a/components/collections/my/Folder.vue
+++ b/components/collections/my/Folder.vue
@@ -104,8 +104,8 @@
:collection-index="collectionIndex"
:folder-index="folderIndex"
:folder-name="folder.name"
- :request-index="index"
:folder-path="folderPath"
+ :request-index="index"
:doc="doc"
:picked="picked"
:save-request="saveRequest"
@@ -142,8 +142,11 @@
</template>
<script>
-import { getSettingSubject } from "~/newstore/settings"
-import { removeRESTFolder, removeRESTRequest } from "~/newstore/collections"
+import {
+ removeRESTFolder,
+ removeRESTRequest,
+ moveRESTRequest,
+} from "~/newstore/collections"
export default {
name: "Folder",
@@ -167,11 +170,6 @@ export default {
cursor: "",
}
},
- subscriptions() {
- return {
- SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
- }
- },
computed: {
isSelected() {
return (
@@ -203,25 +201,9 @@ export default {
},
dropEvent({ dataTransfer }) {
this.dragging = !this.dragging
- const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
- const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
- const oldFolderName = dataTransfer.getData("oldFolderName")
+ const folderPath = dataTransfer.getData("folderPath")
const requestIndex = dataTransfer.getData("requestIndex")
- const flag = "rest"
-
- // TODO: Implement for the new collection state system
-
- this.$store.commit("postwoman/moveRequest", {
- oldCollectionIndex,
- newCollectionIndex: this.$props.collectionIndex,
- newFolderIndex: this.$props.folderIndex,
- newFolderName: this.$props.folder.name,
- oldFolderIndex,
- oldFolderName,
- requestIndex,
- flag,
- })
- this.syncCollections()
+ moveRESTRequest(folderPath, requestIndex, this.folderPath)
},
removeRequest({ requestIndex }) {
removeRESTRequest(this.folderPath, requestIndex)
diff --git a/components/collections/my/Request.vue b/components/collections/my/Request.vue
index 7fbc08b25..3c62bbff2 100644
--- a/components/collections/my/Request.vue
+++ b/components/collections/my/Request.vue
@@ -124,10 +124,8 @@ export default {
},
dragStart({ dataTransfer }) {
this.dragging = !this.dragging
- dataTransfer.setData("oldCollectionIndex", this.$props.collectionIndex)
- dataTransfer.setData("oldFolderIndex", this.$props.folderIndex)
- dataTransfer.setData("oldFolderName", this.$props.folderName)
- dataTransfer.setData("requestIndex", this.$props.requestIndex)
+ dataTransfer.setData("folderPath", this.folderPath)
+ dataTransfer.setData("requestIndex", this.requestIndex)
},
removeRequest() {
this.$emit("remove-request", {