From 965a51e1e862d16adeaea73ddfe6f6d6b5649fdb Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Fri, 19 Jan 2024 13:22:19 +0100 Subject: [PATCH] Refactor branch lane layout - whole lane scrollable rather than individual sections - new upstream commit section - fixed header at the top - fixes scroll lock issue with nested scroll containers - known issue with grey padding on drag --- .../src/lib/components/IconButton.svelte | 5 + .../src/lib/components/ImgThemed.svelte | 2 +- .../lib/components/ScrollableContainer.svelte | 5 +- .../src/lib/vbranches/branchController.ts | 11 + gitbutler-ui/src/lib/vbranches/types.ts | 4 +- .../src/routes/[projectId]/board/+page.svelte | 3 +- .../src/routes/[projectId]/board/Board.svelte | 5 +- .../board/NewBranchDropZone.svelte | 28 +- .../[projectId]/components/BranchCard.svelte | 302 +++++++++--------- .../components/BranchCommits.svelte | 74 +++-- .../[projectId]/components/BranchFiles.svelte | 135 +++----- .../components/BranchHeader.svelte | 246 ++++++++------ .../[projectId]/components/BranchLane.svelte | 11 +- .../components/CommitDialog.svelte | 1 + .../[projectId]/components/CommitList.svelte | 59 +++- .../components/CommitListFooter.svelte | 19 ++ .../components/CommitListHeader.svelte | 4 + .../components/CommitListItem.svelte | 19 +- .../[projectId]/components/FileCard.svelte | 23 +- .../stashed/[branchId]/+page.svelte | 1 - gitbutler-ui/src/styles/card.postcss | 1 - gitbutler-ui/src/styles/tokens.css | 2 +- 22 files changed, 523 insertions(+), 437 deletions(-) diff --git a/gitbutler-ui/src/lib/components/IconButton.svelte b/gitbutler-ui/src/lib/components/IconButton.svelte index b0136f907..db73039e8 100644 --- a/gitbutler-ui/src/lib/components/IconButton.svelte +++ b/gitbutler-ui/src/lib/components/IconButton.svelte @@ -5,6 +5,7 @@ export let icon: keyof typeof iconsJson; export let size: 's' | 'm' | 'l' = 'l'; export let loading = false; + export let border = false; let className = ''; let selected = false; @@ -15,6 +16,7 @@ + {:else if type == 'upstream'} + {/if} {/if} diff --git a/gitbutler-ui/src/routes/[projectId]/components/CommitListHeader.svelte b/gitbutler-ui/src/routes/[projectId]/components/CommitListHeader.svelte index f9f922812..3ce779c85 100644 --- a/gitbutler-ui/src/routes/[projectId]/components/CommitListHeader.svelte +++ b/gitbutler-ui/src/routes/[projectId]/components/CommitListHeader.svelte @@ -6,6 +6,7 @@ export let expanded: boolean; export let type: CommitStatus; export let height: number | undefined; + export let upstreamCommitCount = 0; let element: HTMLButtonElement | undefined = undefined; @@ -31,6 +32,9 @@ Remote branch {:else if type == 'integrated'} Integrated + {:else if type == 'upstream'} + {upstreamCommitCount} upstream {upstreamCommitCount == 1 ? 'commit' : 'commits'} + {/if}
diff --git a/gitbutler-ui/src/routes/[projectId]/components/CommitListItem.svelte b/gitbutler-ui/src/routes/[projectId]/components/CommitListItem.svelte index 8658ec674..7d0b20566 100644 --- a/gitbutler-ui/src/routes/[projectId]/components/CommitListItem.svelte +++ b/gitbutler-ui/src/routes/[projectId]/components/CommitListItem.svelte @@ -10,7 +10,7 @@ } from '$lib/draggables'; import { dropzone } from '$lib/utils/draggable'; import type { BranchController } from '$lib/vbranches/branchController'; - import type { BaseBranch, Branch, Commit } from '$lib/vbranches/types'; + import { RemoteCommit, type BaseBranch, type Branch, type Commit } from '$lib/vbranches/types'; import { get } from 'svelte/store'; import CommitCard from './CommitCard.svelte'; import DropzoneOverlay from './DropzoneOverlay.svelte'; @@ -18,14 +18,17 @@ export let branch: Branch; export let project: Project; - export let commit: Commit; + export let commit: Commit | RemoteCommit; export let base: BaseBranch | undefined | null; export let isHeadCommit: boolean; export let isChained: boolean; export let readonly = false; export let branchController: BranchController; - function acceptAmend(commit: Commit) { + function acceptAmend(commit: Commit | RemoteCommit) { + if (commit instanceof RemoteCommit) { + return () => false; + } return (data: any) => { if (!project.ok_with_force_push && commit.isRemote) { return false; @@ -60,7 +63,10 @@ } } - function acceptSquash(commit: Commit) { + function acceptSquash(commit: Commit | RemoteCommit) { + if (commit instanceof RemoteCommit) { + return () => false; + } return (data: any) => { if (!isDraggableCommit(data)) return false; if (data.branchId != branch.id) return false; @@ -79,7 +85,10 @@ }; } - function onSquash(commit: Commit) { + function onSquash(commit: Commit | RemoteCommit) { + if (commit instanceof RemoteCommit) { + return () => false; + } return (data: DraggableCommit) => { if (data.commit.isParentOf(commit)) { branchController.squashBranchCommit(data.branchId, commit.id); diff --git a/gitbutler-ui/src/routes/[projectId]/components/FileCard.svelte b/gitbutler-ui/src/routes/[projectId]/components/FileCard.svelte index bb8fb9642..51390f7be 100644 --- a/gitbutler-ui/src/routes/[projectId]/components/FileCard.svelte +++ b/gitbutler-ui/src/routes/[projectId]/components/FileCard.svelte @@ -116,13 +116,9 @@ ...draggableFile(branchId, file, writable([file])), disabled: readonly }} + style:width={`${fileWidth || $defaultFileWidthRem}rem`} > -
+
{#if conflicted}
@@ -251,12 +247,20 @@