From e5ee060eaf78fd474fc994be0d6d974cf53138f4 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 6 Nov 2023 14:15:17 +0100 Subject: [PATCH] re-enable branch reorder --- .../src/routes/[projectId]/board/Board.svelte | 85 ++++++++++++++++--- 1 file changed, 72 insertions(+), 13 deletions(-) diff --git a/packages/ui/src/routes/[projectId]/board/Board.svelte b/packages/ui/src/routes/[projectId]/board/Board.svelte index f94cd63c1..a85ba4d28 100644 --- a/packages/ui/src/routes/[projectId]/board/Board.svelte +++ b/packages/ui/src/routes/[projectId]/board/Board.svelte @@ -24,6 +24,11 @@ export let githubContext: GitHubIntegrationContext | undefined; + let dragged: any; + let dropZone: HTMLDivElement; + let priorPosition = 0; + let dropPosition = 0; + function handleEmpty() { const emptyIndex = branches?.findIndex((item) => !item.files || item.files.length == 0); if (emptyIndex && emptyIndex != -1) { @@ -40,20 +45,74 @@ {:else if branchesState.isError || baseBranchState.isError}
Something went wrong...
{:else if branches} -
+
{ + if (!dragged) return; + + e.preventDefault(); + const children = [...e.currentTarget.children]; + dropPosition = 0; + // We account for the NewBranchDropZone by subtracting 2 + for (let i = 0; i < children.length - 2; i++) { + const pos = children[i].getBoundingClientRect(); + if (e.clientX > pos.left + pos.width) { + dropPosition = i + 1; // Note that this is declared in the