From 5b42e6e9e6d7230e6333dfc740a159fc24a14c81 Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Wed, 3 Jul 2024 17:18:11 +0200 Subject: [PATCH] Remove virtual flag from front end --- app/src/lib/branch/ActiveBranchStatus.svelte | 11 +-- app/src/lib/branch/BranchCard.svelte | 26 ++++--- app/src/lib/branch/BranchHeader.svelte | 52 +++++++------- app/src/lib/branch/BranchLanePopupMenu.svelte | 3 +- app/src/lib/branches/service.ts | 2 +- app/src/lib/branches/types.ts | 3 +- app/src/lib/commit/CommitCard.svelte | 2 +- .../lib/components/PullRequestPreview.svelte | 13 +--- app/src/lib/navigation/BranchItem.svelte | 3 +- app/src/lib/testing/fixtures.ts | 1 - app/src/lib/vbranches/types.ts | 2 - app/src/lib/vbranches/virtualBranch.ts | 47 ++++++------ .../stashed/[branchId]/+page.svelte | 71 ------------------- 13 files changed, 64 insertions(+), 172 deletions(-) delete mode 100644 app/src/routes/[projectId]/stashed/[branchId]/+page.svelte diff --git a/app/src/lib/branch/ActiveBranchStatus.svelte b/app/src/lib/branch/ActiveBranchStatus.svelte index 1e0b60e73..9666daa8f 100644 --- a/app/src/lib/branch/ActiveBranchStatus.svelte +++ b/app/src/lib/branch/ActiveBranchStatus.svelte @@ -15,16 +15,7 @@ {#if !remoteExists} - {#if !$branch.active} - - {:else if hasIntegratedCommits} + {#if hasIntegratedCommits} - {:else} - - {/if} + {#if branch.selectedForChanges} + + {:else} + {/if} diff --git a/app/src/lib/branch/BranchLanePopupMenu.svelte b/app/src/lib/branch/BranchLanePopupMenu.svelte index 2a5aa4c30..edc6e6a44 100644 --- a/app/src/lib/branch/BranchLanePopupMenu.svelte +++ b/app/src/lib/branch/BranchLanePopupMenu.svelte @@ -191,8 +191,7 @@ }} disabled={isUnapplied || !($aiGenEnabled && aiConfigurationValid) || - branch.files?.length === 0 || - !branch.active} + branch.files?.length === 0} /> diff --git a/app/src/lib/branches/service.ts b/app/src/lib/branches/service.ts index 5e548c262..bf68a6430 100644 --- a/app/src/lib/branches/service.ts +++ b/app/src/lib/branches/service.ts @@ -137,7 +137,7 @@ function mergeBranchesAndPrs( // This should be everything considered a branch in one list const filtered = contributions - .filter((b) => !b.vbranch || !b.vbranch.active) + .filter((b) => !b.vbranch) .sort((a, b) => { return (a.modifiedAt || new Date(0)) < (b.modifiedAt || new Date(0)) ? 1 : -1; }); diff --git a/app/src/lib/branches/types.ts b/app/src/lib/branches/types.ts index 8cd1439ad..b373678ee 100644 --- a/app/src/lib/branches/types.ts +++ b/app/src/lib/branches/types.ts @@ -64,10 +64,9 @@ export class CombinedBranch { } // GH colors reference https://github.blog/changelog/2021-06-08-new-issue-and-pull-request-state-icons - get color(): 'neutral' | 'success' | 'pop' | 'purple' | undefined { + get color(): 'neutral' | 'success' | 'purple' | undefined { if (this.pr?.mergedAt) return 'purple'; // merged PR if (this.pr) return 'success'; // open PR - if (this.vbranch && this.vbranch.active === false) return 'pop'; // stashed virtual branches // if (this.remoteBranch?.isMergeable) return 'success'; // remote branches return 'neutral'; } diff --git a/app/src/lib/commit/CommitCard.svelte b/app/src/lib/commit/CommitCard.svelte index e6c02209a..0d13d59c1 100644 --- a/app/src/lib/commit/CommitCard.svelte +++ b/app/src/lib/commit/CommitCard.svelte @@ -74,7 +74,7 @@ branchController.undoCommit(branch.id, commit.id); } - let isUndoable = !!branch?.active && commit instanceof Commit; + let isUndoable = commit instanceof Commit; const hasCommitUrl = !commit.isLocal && commitUrl; diff --git a/app/src/lib/components/PullRequestPreview.svelte b/app/src/lib/components/PullRequestPreview.svelte index 86f15d1a1..b32e22507 100644 --- a/app/src/lib/components/PullRequestPreview.svelte +++ b/app/src/lib/components/PullRequestPreview.svelte @@ -70,20 +70,9 @@ `refs/remotes/${remoteName}/${pullrequest.sourceBranch}` ); await virtualBranchService.reload(); - const vbranch = await virtualBranchService.getByUpstreamSha(pullrequest.sha); // This is a little absurd, but it makes it soundly typed - if (!vbranch) { - goto(`/${project.id}/board`); - return; - } - - // Active seems to be a more reliable metric to determine whether to go to the branch page - if (vbranch.active) { - goto(`/${project.id}/board`); - } else { - goto(`/${project.id}/stashed/${vbranch.id}`); - } + goto(`/${project.id}/board`); createRemoteModal?.close(); } finally { diff --git a/app/src/lib/navigation/BranchItem.svelte b/app/src/lib/navigation/BranchItem.svelte index a7e9f09e2..ed2925bf9 100644 --- a/app/src/lib/navigation/BranchItem.svelte +++ b/app/src/lib/navigation/BranchItem.svelte @@ -9,8 +9,7 @@ export let branch: CombinedBranch; function getBranchLink(b: CombinedBranch): string | undefined { - if (b.vbranch?.active) return `/${projectId}/board/`; - if (b.vbranch) return `/${projectId}/stashed/${b.vbranch.id}`; + if (b.vbranch) return `/${projectId}/board/`; if (b.remoteBranch) return `/${projectId}/remote/${branch?.remoteBranch?.displayName}`; if (b.pr) return `/${projectId}/pull/${b.pr.number}`; } diff --git a/app/src/lib/testing/fixtures.ts b/app/src/lib/testing/fixtures.ts index ca95b09e2..d7a800a3c 100644 --- a/app/src/lib/testing/fixtures.ts +++ b/app/src/lib/testing/fixtures.ts @@ -156,7 +156,6 @@ export const file1 = { }; export const virtualBranch = { - active: true, baseCurrent: true, commits: [], conflicted: false, diff --git a/app/src/lib/vbranches/types.ts b/app/src/lib/vbranches/types.ts index ee4d13890..0d37e631c 100644 --- a/app/src/lib/vbranches/types.ts +++ b/app/src/lib/vbranches/types.ts @@ -99,8 +99,6 @@ export class Branch { id!: string; name!: string; notes!: string; - // Active means the branch has been applied to the workspace - active!: boolean; @Type(() => LocalFile) files!: LocalFile[]; @Type(() => Commit) diff --git a/app/src/lib/vbranches/virtualBranch.ts b/app/src/lib/vbranches/virtualBranch.ts index 56ee16b9e..a91c07875 100644 --- a/app/src/lib/vbranches/virtualBranch.ts +++ b/app/src/lib/vbranches/virtualBranch.ts @@ -24,7 +24,6 @@ import { writable, type Readable } from 'svelte/store'; export class VirtualBranchService { branches$: Observable; - stashedBranches$: Observable; activeBranches$: Observable; branchesError = writable(); private reload$ = new BehaviorSubject(undefined); @@ -67,10 +66,6 @@ export class VirtualBranchService { shareReplay(1) ); - this.stashedBranches$ = this.branches$.pipe( - map((branches) => branches?.filter((b) => !b.active)) - ); - // We need upstream data to be part of the branch without delay since the way we render // commits depends on it. // TODO: Move this async behavior into the rust code. @@ -80,29 +75,27 @@ export class VirtualBranchService { switchMap((branches) => { if (!branches) return of(); return Promise.all( - branches - .filter((b) => b.active) - .map(async (b) => { - const upstreamName = b.upstream?.name; - if (upstreamName) { - try { - const data = await getRemoteBranchData(projectId, upstreamName); - const commits = data.commits; - commits.forEach((uc) => { - const match = b.commits.find((c) => commitCompare(uc, c)); - if (match) { - match.relatedTo = uc; - uc.relatedTo = match; - } - }); - linkAsParentChildren(commits); - b.upstreamData = data; - } catch (e: any) { - console.log(e); - } + branches.map(async (b) => { + const upstreamName = b.upstream?.name; + if (upstreamName) { + try { + const data = await getRemoteBranchData(projectId, upstreamName); + const commits = data.commits; + commits.forEach((uc) => { + const match = b.commits.find((c) => commitCompare(uc, c)); + if (match) { + match.relatedTo = uc; + uc.relatedTo = match; + } + }); + linkAsParentChildren(commits); + b.upstreamData = data; + } catch (e: any) { + console.log(e); } - return b; - }) + } + return b; + }) ); }) ); diff --git a/app/src/routes/[projectId]/stashed/[branchId]/+page.svelte b/app/src/routes/[projectId]/stashed/[branchId]/+page.svelte deleted file mode 100644 index b2aaf43ff..000000000 --- a/app/src/routes/[projectId]/stashed/[branchId]/+page.svelte +++ /dev/null @@ -1,71 +0,0 @@ - - -{#if $error} -

{JSON.stringify($error)}

-{:else if !$branches$} - -{:else if branch} - -{:else} -

Branch no longer exists

-{/if} - - -

Applying this branch will introduce merge conflicts.

- {#snippet controls(close, item)} - - - {/snippet} -
- - - {#snippet children(item)} - Deleting {item.name} cannot be undone. - {/snippet} - {#snippet controls(close, item)} - - - {/snippet} -