diff --git a/packages/hoppscotch-common/src/components/app/Header.vue b/packages/hoppscotch-common/src/components/app/Header.vue index 53ab0a975..3df45f7aa 100644 --- a/packages/hoppscotch-common/src/components/app/Header.vue +++ b/packages/hoppscotch-common/src/components/app/Header.vue @@ -17,27 +17,13 @@ /> -
- -
- - - {{ t("app.search") }} - - / -
+
-
-
+
-
- - -
- - - diff --git a/packages/hoppscotch-common/src/components/collections/Collection.vue b/packages/hoppscotch-common/src/components/collections/Collection.vue index 9a8695a3e..7babb29f1 100644 --- a/packages/hoppscotch-common/src/components/collections/Collection.vue +++ b/packages/hoppscotch-common/src/components/collections/Collection.vue @@ -165,6 +165,20 @@
+
@@ -249,6 +263,11 @@ const props = defineProps({ default: () => [], required: false, }, + isLastItem: { + type: Boolean, + default: false, + required: false, + }, }) const emit = defineEmits<{ @@ -262,6 +281,7 @@ const emit = defineEmits<{ (event: "drag-event", payload: DataTransfer): void (event: "dragging", payload: boolean): void (event: "update-collection-order", payload: DataTransfer): void + (event: "update-last-collection-order", payload: DataTransfer): void }>() const tippyActions = ref(null) @@ -274,6 +294,7 @@ const options = ref(null) const dragging = ref(false) const ordering = ref(false) +const orderingLastItem = ref(false) const dropItemID = ref("") const currentReorderingStatus = useReadonlyStream(currentReorderingStatus$, { @@ -333,6 +354,14 @@ const isReorderable = computed(() => { isSameParent.value ) }) +const isLastItemReorderable = computed(() => { + return ( + orderingLastItem.value && + notSameDestination.value && + !isRequestDragging.value && + isSameParent.value + ) +}) const dragStart = ({ dataTransfer }: DragEvent) => { if (dataTransfer) { @@ -350,17 +379,35 @@ const dragStart = ({ dataTransfer }: DragEvent) => { // Trigger the re-ordering event when a collection is dragged over another collection's top section const handleDragOver = (e: DragEvent) => { dragging.value = true - if (e.offsetY < 10 && notSameDestination.value) { + if ( + e.offsetY < 10 && + notSameDestination.value && + !isRequestDragging.value && + isSameParent.value + ) { ordering.value = true dragging.value = false + orderingLastItem.value = false + } else if ( + e.offsetY > 18 && + notSameDestination.value && + !isRequestDragging.value && + isSameParent.value + ) { + orderingLastItem.value = true + dragging.value = false + ordering.value = false } else { ordering.value = false + orderingLastItem.value = false } } const handelDrop = (e: DragEvent) => { if (ordering.value) { orderUpdateCollectionEvent(e) + } else if (orderingLastItem.value) { + updateLastItemOrder(e) } else { dropEvent(e) } @@ -382,6 +429,14 @@ const orderUpdateCollectionEvent = (e: DragEvent) => { } } +const updateLastItemOrder = (e: DragEvent) => { + if (e.dataTransfer) { + e.stopPropagation() + emit("update-last-collection-order", e.dataTransfer) + resetDragState() + } +} + const notSameDestination = computed(() => { return dropItemID.value !== props.id }) @@ -397,5 +452,6 @@ const isCollLoading = computed(() => { const resetDragState = () => { dragging.value = false ordering.value = false + orderingLastItem.value = false } diff --git a/packages/hoppscotch-common/src/components/collections/MyCollections.vue b/packages/hoppscotch-common/src/components/collections/MyCollections.vue index d09b93a45..ca13025a4 100644 --- a/packages/hoppscotch-common/src/components/collections/MyCollections.vue +++ b/packages/hoppscotch-common/src/components/collections/MyCollections.vue @@ -43,6 +43,7 @@ :data="node.data.data.data" :collections-type="collectionsType.type" :is-open="isOpen" + :is-last-item="node.data.isLastItem" :is-selected=" isSelected({ collectionIndex: parseInt(node.id), @@ -77,7 +78,18 @@ @remove-collection="emit('remove-collection', node.id)" @drop-event="dropEvent($event, node.id)" @drag-event="dragEvent($event, node.id)" - @update-collection-order="updateCollectionOrder($event, node.id)" + @update-collection-order=" + updateCollectionOrder($event, { + destinationCollectionIndex: node.id, + destinationCollectionParentIndex: node.data.data.parentIndex, + }) + " + @update-last-collection-order=" + updateCollectionOrder($event, { + destinationCollectionIndex: null, + destinationCollectionParentIndex: node.data.data.parentIndex, + }) + " @dragging=" (isDraging) => highlightChildren(isDraging ? node.id : null) " @@ -99,6 +111,7 @@ :data="node.data.data.data" :collections-type="collectionsType.type" :is-open="isOpen" + :is-last-item="node.data.isLastItem" :is-selected=" isSelected({ folderPath: node.id, @@ -133,7 +146,18 @@ @remove-collection="emit('remove-folder', node.id)" @drop-event="dropEvent($event, node.id)" @drag-event="dragEvent($event, node.id)" - @update-collection-order="updateCollectionOrder($event, node.id)" + @update-collection-order=" + updateCollectionOrder($event, { + destinationCollectionIndex: node.id, + destinationCollectionParentIndex: node.data.data.parentIndex, + }) + " + @update-last-collection-order=" + updateCollectionOrder($event, { + destinationCollectionIndex: null, + destinationCollectionParentIndex: node.data.data.parentIndex, + }) + " @dragging=" (isDraging) => highlightChildren(isDraging ? node.id : null) " @@ -155,6 +179,7 @@ :parent-i-d="node.data.data.parentIndex" :collections-type="collectionsType.type" :save-request="saveRequest" + :is-last-item="node.data.isLastItem" :is-active=" isActiveRequest( node.data.data.parentIndex, @@ -209,6 +234,12 @@ requestIndex: node.id, }) " + @update-last-request-order=" + updateRequestOrder($event, { + folderPath: node.data.data.parentIndex, + requestIndex: null, + }) + " />