From 141a4688083f0de9618bd31f1bf24ce88e433d0d Mon Sep 17 00:00:00 2001 From: Nivedin <53208152+nivedin@users.noreply.github.com> Date: Wed, 5 Apr 2023 15:30:47 +0530 Subject: [PATCH 1/2] chore: update header UI (#2965) --- .../src/components/app/Header.vue | 36 ++++++++----------- .../src/components/app/Navigation.vue | 33 ----------------- 2 files changed, 15 insertions(+), 54 deletions(-) delete mode 100644 packages/hoppscotch-common/src/components/app/Navigation.vue 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") }} - - / -
+
-
-
+
-
- - -
- - - From 1d397af6743a9d03f1c010dda6a50a8cccbb5193 Mon Sep 17 00:00:00 2001 From: Nivedin <53208152+nivedin@users.noreply.github.com> Date: Wed, 5 Apr 2023 15:38:57 +0530 Subject: [PATCH 2/2] fix: move collection and request to bottom of list (#2964) --- .../src/components/collections/Collection.vue | 58 +++++++- .../components/collections/MyCollections.vue | 65 +++++++-- .../src/components/collections/Request.vue | 70 +++++++++- .../collections/TeamCollections.vue | 59 ++++++-- .../src/components/collections/index.vue | 112 ++++++++++----- .../mutations/UpdateCollectionOrder.graphql | 2 +- .../backend/mutations/TeamCollection.ts | 2 +- .../helpers/backend/mutations/TeamRequest.ts | 2 +- .../helpers/teams/TeamCollectionAdapter.ts | 132 ++++++++++++------ .../src/newstore/collections.ts | 66 ++++++++- 10 files changed, 455 insertions(+), 113 deletions(-) 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, + }) + " />