From e5fe606ab0f58af41849ecf44174d1d25946a86a Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Thu, 1 Feb 2024 16:00:43 +0100 Subject: [PATCH] Lock hunks when viewing remote files - readonly prop for hunks to disable cursor and dragging - removes a console.log - undo a previous change related to AnyFile - fix gap between text selection blocks line numbers --- gitbutler-ui/src/lib/components/BranchFilesList.svelte | 8 ++++---- gitbutler-ui/src/lib/components/BranchLane.svelte | 1 + gitbutler-ui/src/lib/components/CommitCard.svelte | 2 ++ gitbutler-ui/src/lib/components/FileCard.svelte | 2 ++ gitbutler-ui/src/lib/components/FileDiff.svelte | 2 ++ gitbutler-ui/src/lib/components/FileListItem.svelte | 3 ++- gitbutler-ui/src/lib/components/HunkLine.svelte | 8 ++++++-- gitbutler-ui/src/lib/components/HunkViewer.svelte | 6 ++++-- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/gitbutler-ui/src/lib/components/BranchFilesList.svelte b/gitbutler-ui/src/lib/components/BranchFilesList.svelte index 5de6ad92d..ca75c0ae1 100644 --- a/gitbutler-ui/src/lib/components/BranchFilesList.svelte +++ b/gitbutler-ui/src/lib/components/BranchFilesList.svelte @@ -12,18 +12,18 @@ export let showCheckboxes = false; export let selectedFiles: Writable; export let allowMultiple = false; - - $: console.log(selectedFiles); + export let readonly = false; {#each sortLikeFileTree(files) as file (file.id)} { const isAlreadySelected = $selectedFiles.includes(file); if (isAlreadySelected && e.shiftKey) { diff --git a/gitbutler-ui/src/lib/components/BranchLane.svelte b/gitbutler-ui/src/lib/components/BranchLane.svelte index a6c9850ba..ddb1c8cb7 100644 --- a/gitbutler-ui/src/lib/components/BranchLane.svelte +++ b/gitbutler-ui/src/lib/components/BranchLane.svelte @@ -78,6 +78,7 @@ {branchController} {selectedOwnership} {isUnapplied} + readonly={selected instanceof RemoteFile} selectable={$commitBoxOpen && !isUnapplied} on:close={() => { const selectedId = selected?.id; diff --git a/gitbutler-ui/src/lib/components/CommitCard.svelte b/gitbutler-ui/src/lib/components/CommitCard.svelte index 90f67e011..2708bf9dd 100644 --- a/gitbutler-ui/src/lib/components/CommitCard.svelte +++ b/gitbutler-ui/src/lib/components/CommitCard.svelte @@ -113,6 +113,7 @@ {selectedOwnership} {selectedFiles} {isUnapplied} + readonly={true} /> {:else}
; let rsViewport: HTMLElement; @@ -74,6 +75,7 @@ filePath={file.path} isLarge={file.large} isBinary={file.binary} + {readonly} {sections} {projectPath} {isFileLocked} diff --git a/gitbutler-ui/src/lib/components/FileDiff.svelte b/gitbutler-ui/src/lib/components/FileDiff.svelte index 49e09207e..80874b646 100644 --- a/gitbutler-ui/src/lib/components/FileDiff.svelte +++ b/gitbutler-ui/src/lib/components/FileDiff.svelte @@ -18,6 +18,7 @@ export let selectable = false; export let selectedOwnership: Writable | undefined = undefined; export let isFileLocked = false; + export let readonly: boolean = false; function getGutterMinWidth(max: number) { if (max >= 10000) return 2.5; @@ -61,6 +62,7 @@ {branchController} {isFileLocked} {minWidth} + {readonly} />
{/if} diff --git a/gitbutler-ui/src/lib/components/FileListItem.svelte b/gitbutler-ui/src/lib/components/FileListItem.svelte index f630396f2..d063e01d3 100644 --- a/gitbutler-ui/src/lib/components/FileListItem.svelte +++ b/gitbutler-ui/src/lib/components/FileListItem.svelte @@ -15,6 +15,7 @@ export let showCheckbox: boolean = false; export let selectedOwnership: Writable; export let selectedFiles: Writable; + export let readonly = false; let checked = false; let indeterminate = false; @@ -40,7 +41,7 @@ }} use:draggable={{ ...draggableFile(branchId, file, selectedFiles), - disabled: isUnapplied, + disabled: readonly || isUnapplied, selector: '.selected-draggable' }} role="button" diff --git a/gitbutler-ui/src/lib/components/HunkLine.svelte b/gitbutler-ui/src/lib/components/HunkLine.svelte index 49182a18e..aa6f85db5 100644 --- a/gitbutler-ui/src/lib/components/HunkLine.svelte +++ b/gitbutler-ui/src/lib/components/HunkLine.svelte @@ -10,6 +10,7 @@ export let minWidth = 1.75; export let selectable: boolean = false; export let selected: boolean = true; + export let readonly: boolean = false; const dispatch = createEventDispatcher<{ selected: boolean }>(); @@ -59,6 +60,7 @@
@@ -80,8 +82,9 @@ .line { flex-grow: 1; - cursor: grab; - padding-left: var(--space-4); + &:not(.readonly) { + cursor: grab; + } } .code-line__numbers-line { @@ -93,5 +96,6 @@ .selectable-wrapper { cursor: text; display: inline-block; + text-indent: var(--space-4); } diff --git a/gitbutler-ui/src/lib/components/HunkViewer.svelte b/gitbutler-ui/src/lib/components/HunkViewer.svelte index 9c48ca9f0..2c5f212ec 100644 --- a/gitbutler-ui/src/lib/components/HunkViewer.svelte +++ b/gitbutler-ui/src/lib/components/HunkViewer.svelte @@ -19,6 +19,7 @@ export let selectable = false; export let isUnapplied: boolean; export let isFileLocked: boolean; + export let readonly: boolean = false; export let branchController: BranchController; export let selectedOwnership: Writable | undefined = undefined; @@ -54,10 +55,11 @@ role="cell" use:draggable={{ ...draggableHunk(branchId, section.hunk), - disabled: isUnapplied || section.hunk.locked || !branchId + disabled: readonly || isUnapplied || section.hunk.locked || !branchId }} on:contextmenu|preventDefault class="hunk" + class:readonly class:opacity-60={section.hunk.locked && !isFileLocked} >
@@ -67,6 +69,7 @@