From dc043da5070775b3aba26bb453906f7c6acd421c Mon Sep 17 00:00:00 2001 From: Pavel Laptev Date: Fri, 15 Nov 2024 16:06:54 +0100 Subject: [PATCH] refactor `CommitAction` component --- .../src/lib/commit/CommitAction.svelte | 54 ++++++---------- apps/desktop/src/lib/commit/CommitList.svelte | 62 ++++++++++++------- .../commit/UpstreamCommitsAccordion.svelte | 17 ++--- .../src/lib/components/BaseBranch.svelte | 10 +-- apps/desktop/src/lib/stack/SeriesList.svelte | 4 -- packages/ui/src/lib/commitLines/Cell.svelte | 2 +- 6 files changed, 68 insertions(+), 81 deletions(-) diff --git a/apps/desktop/src/lib/commit/CommitAction.svelte b/apps/desktop/src/lib/commit/CommitAction.svelte index fdc900b17..f9b93157c 100644 --- a/apps/desktop/src/lib/commit/CommitAction.svelte +++ b/apps/desktop/src/lib/commit/CommitAction.svelte @@ -1,43 +1,22 @@ -
{ - if (entry?.isIntersecting) { - isNotInViewport = false; - } else { - isNotInViewport = true; - } - }, - options: { - root: null, - rootMargin: `-100% 0px 0px 0px`, - threshold: 0 - } - }} -> -
- {@render lines()} +
+
+
+
{@render action()}
@@ -47,10 +26,9 @@ .action-row { position: relative; display: flex; - + background-color: var(--clr-bg-1); + border-top: 1px solid var(--clr-border-3); overflow: hidden; - - transition: border-top var(--transition-fast); } .background-color { @@ -61,9 +39,15 @@ display: flex; flex-direction: column; width: 100%; - padding-top: 10px; + padding-top: 14px; padding-right: 14px; - padding-bottom: 10px; + padding-bottom: 14px; + } + + .commit-line-wrapper { + position: relative; + margin-left: 20px; + margin-right: 20px; } /* MODIFIERS */ diff --git a/apps/desktop/src/lib/commit/CommitList.svelte b/apps/desktop/src/lib/commit/CommitList.svelte index 7d1ddaae0..0d40a9210 100644 --- a/apps/desktop/src/lib/commit/CommitList.svelte +++ b/apps/desktop/src/lib/commit/CommitList.svelte @@ -15,14 +15,13 @@ BranchController, type SeriesIntegrationStrategy } from '$lib/vbranches/branchController'; - import { DetailedCommit, VirtualBranch, type CommitStatus } from '$lib/vbranches/types'; + import { DetailedCommit, VirtualBranch } from '$lib/vbranches/types'; import { getContext } from '@gitbutler/shared/context'; import { getContextStore } from '@gitbutler/shared/context'; import Button from '@gitbutler/ui/Button.svelte'; import Modal from '@gitbutler/ui/Modal.svelte'; import Line from '@gitbutler/ui/commitLines/Line.svelte'; - import { LineManagerFactory, LineSpacer } from '@gitbutler/ui/commitLines/lineManager'; - import type { Snippet } from 'svelte'; + import { LineManagerFactory } from '@gitbutler/ui/commitLines/lineManager'; const integrationStrategies = { default: { @@ -32,7 +31,7 @@ action: integrate }, reset: { - label: 'Reset to remote', + label: 'Reset to remoteā€¦', stretegy: 'hardreset', style: 'error', action: confirmReset @@ -46,8 +45,6 @@ patches: DetailedCommit[]; seriesName: string; isUnapplied: boolean; - pushButton?: Snippet<[{ disabled: boolean }]>; - hasConflicts: boolean; stackingReorderDropzoneManager: StackingReorderDropzoneManager; isBottom?: boolean; } @@ -56,8 +53,6 @@ patches, seriesName, isUnapplied, - pushButton, - hasConflicts, stackingReorderDropzoneManager, isBottom = false }: Props = $props(); @@ -86,9 +81,9 @@ const hasRemoteCommits = $derived(remoteOnlyPatches.length > 0); let isIntegratingCommits = $state(false); - const topPatch = $derived(patches[0]); - const branchType = $derived(topPatch?.status ?? 'local'); - const isBranchIntegrated = $derived(branchType === 'integrated'); + // const topPatch = $derived(patches[0]); + // const branchType = $derived(topPatch?.status ?? 'local'); + // const isBranchIntegrated = $derived(branchType === 'integrated'); let confirmResetModal = $state>(); @@ -139,18 +134,22 @@ isHeadCommit={commit.id === headCommit?.id} > {#snippet lines()} - + {/snippet} {/each} - {#snippet action()} - {@render integrateUpstreamButton('default')} - {/snippet} + + + {#snippet action()} + {@render integrateUpstreamButton('default')} + {/snippet} + {/if} - - {#if patches.length > 0}
@@ -183,17 +182,23 @@ {#if lastDivergentCommit?.id === commit.id} -
+ + {#snippet action()} + {@render integrateUpstreamButton('reset')} + {/snippet} + + {/if} {/each}
{/if} - {#if remoteOnlyPatches.length > 0 && patches.length === 0 && !isBranchIntegrated && pushButton} + +
{@render children()}
- -
-
-
- {@render action()} -
-
{/if}
@@ -89,7 +82,7 @@ } } - .accordion-row__actions { + /* .accordion-row__actions { display: flex; width: 100%; align-items: stretch; @@ -102,7 +95,7 @@ flex-direction: column; flex: 1; padding: 14px 0 14px; - } + } */ .accordion-row__header { display: flex; @@ -164,6 +157,6 @@ min-height: 44px; align-items: stretch; text-align: left; - border-bottom: 1px solid var(--clr-border-3); + /* border-bottom: 1px solid var(--clr-border-3); */ } diff --git a/apps/desktop/src/lib/components/BaseBranch.svelte b/apps/desktop/src/lib/components/BaseBranch.svelte index 02f9f4c93..15a72ddf2 100644 --- a/apps/desktop/src/lib/components/BaseBranch.svelte +++ b/apps/desktop/src/lib/components/BaseBranch.svelte @@ -220,10 +220,7 @@ {/each} {#if base.diverged} - - {#snippet lines()} - - {/snippet} + {#snippet action()}