diff --git a/apps/desktop/src/lib/components/BaseBranch.svelte b/apps/desktop/src/lib/components/BaseBranch.svelte index a19cfb1e06..56510a3eca 100644 --- a/apps/desktop/src/lib/components/BaseBranch.svelte +++ b/apps/desktop/src/lib/components/BaseBranch.svelte @@ -1,8 +1,8 @@
@@ -51,23 +62,14 @@
{#if base.upstreamCommits?.length > 0} - + diff --git a/apps/desktop/src/lib/components/IntegrateUpstreamModal.svelte b/apps/desktop/src/lib/components/IntegrateUpstreamModal.svelte new file mode 100644 index 0000000000..0899e381ee --- /dev/null +++ b/apps/desktop/src/lib/components/IntegrateUpstreamModal.svelte @@ -0,0 +1,258 @@ + + + + + + + + {#snippet controls()} + + + {/snippet} + + + diff --git a/apps/desktop/src/lib/components/UpdateBaseButton.svelte b/apps/desktop/src/lib/components/UpdateBaseButton.svelte index 5160223506..0ce4069847 100644 --- a/apps/desktop/src/lib/components/UpdateBaseButton.svelte +++ b/apps/desktop/src/lib/components/UpdateBaseButton.svelte @@ -1,130 +1,30 @@ - - - {#if $base} -
- {#each $base.upstreamCommits.slice(0, 2) as commit, index} - { - if (expanded) { - return $base.upstreamCommits.length - 1 === index; - } else { - if ($base.upstreamCommits.length > 2) { - return index === 1; - } else { - return $base.upstreamCommits.length - 1 === index; - } - } - })()} - isUnapplied={true} - commitUrl={$gitHost?.commitUrl(commit.id)} - type="remote" - filesToggleable={false} - /> - {/each} - {#if $base.upstreamCommits.length > 2} - {#if expanded} - {#each $base.upstreamCommits.slice(2) as commit, index} - - {/each} -
- -
- {:else} -
- -
- {/if} - {/if} -
- {/if} -
- {#each statuses as { branch, status }} -
-
-
{branch?.name || 'Unknown'}
- {#if status.type === 'conflicted'} -

Conflicted

- {:else if status.type === 'saflyUpdatable' || status.type === 'empty'} -

No Conflicts

- {:else if status.type === 'fullyIntegrated'} -

Integrated

- {/if} -
- -
- {#if status.type === 'fullyIntegrated'} -

Changes included in base branch

- {:else if results.get(branch.id)} - - {/if} -
-
- {/each} -
-
- - {#snippet controls()} - - - {/snippet} -
- -{#if showButton && ($base?.upstreamCommits.length || 0) > 0} +{#if displayButton} {/if} - - diff --git a/apps/desktop/src/lib/vbranches/upstreamIntegrationService.ts b/apps/desktop/src/lib/vbranches/upstreamIntegrationService.ts index 3079797e2f..2f8ab47e4c 100644 --- a/apps/desktop/src/lib/vbranches/upstreamIntegrationService.ts +++ b/apps/desktop/src/lib/vbranches/upstreamIntegrationService.ts @@ -16,14 +16,7 @@ export type BranchStatus = }; }; -type BranchStatuses = - | { - type: 'upToDate'; - } - | { - type: 'updatesRequired'; - subject: [string, BranchStatus][]; - }; +export type BranchStatusInfo = { branch: VirtualBranch; status: BranchStatus }; export type BranchStatusesWithBranches = | { @@ -31,7 +24,7 @@ export type BranchStatusesWithBranches = } | { type: 'updatesRequired'; - subject: { branch: VirtualBranch; status: BranchStatus }[]; + subject: BranchStatusInfo[]; }; export type ResolutionApproach = { @@ -44,6 +37,42 @@ export type Resolution = { approach: ResolutionApproach; }; +export function getResolutionApproach(statusInfo: BranchStatusInfo): ResolutionApproach { + if (statusInfo.status.type === 'fullyIntegrated') { + return { type: 'delete' }; + } + + if (statusInfo.branch.allowRebasing) { + return { type: 'rebase' }; + } + + return { type: 'merge' }; +} + +export function sortStatusInfo(a: BranchStatusInfo, b: BranchStatusInfo): number { + if ( + (a.status.type !== 'fullyIntegrated' && b.status.type !== 'fullyIntegrated') || + (a.status.type === 'fullyIntegrated' && b.status.type === 'fullyIntegrated') + ) { + return (a.branch?.name || 'Unknown').localeCompare(b.branch?.name || 'Unknown'); + } + + if (a.status.type === 'fullyIntegrated') { + return 1; + } else { + return -1; + } +} + +type BranchStatusesResponse = + | { + type: 'upToDate'; + } + | { + type: 'updatesRequired'; + subject: [string, BranchStatus][]; + }; + export class UpstreamIntegrationService { constructor( private project: Project, @@ -51,10 +80,10 @@ export class UpstreamIntegrationService { ) {} upstreamStatuses(): Readable { - const branchStatuses = readable(undefined, (set) => { - invoke('upstream_integration_statuses', { projectId: this.project.id }).then( - set - ); + const branchStatuses = readable(undefined, (set) => { + invoke('upstream_integration_statuses', { + projectId: this.project.id + }).then(set); }); const branchStatusesWithBranches = derived( @@ -85,7 +114,6 @@ export class UpstreamIntegrationService { } async integrateUpstream(resolutions: Resolution[]) { - console.log(resolutions); return await invoke('integrate_upstream', { projectId: this.project.id, resolutions }); } } diff --git a/packages/ui/src/lib/Modal.svelte b/packages/ui/src/lib/Modal.svelte index 34b18e4360..6135a3acf4 100644 --- a/packages/ui/src/lib/Modal.svelte +++ b/packages/ui/src/lib/Modal.svelte @@ -42,6 +42,12 @@ onClose?.(); dialogElement?.close(); } + + export const imports = { + get open() { + return open; + } + };