mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-08-16 15:50:37 +03:00
Remove virtual flag from front end
This commit is contained in:
parent
2d0dc3a9ff
commit
5b42e6e9e6
@ -15,16 +15,7 @@
|
||||
</script>
|
||||
|
||||
{#if !remoteExists}
|
||||
{#if !$branch.active}
|
||||
<Button
|
||||
clickable={false}
|
||||
size="tag"
|
||||
icon="virtual-branch-small"
|
||||
style="neutral"
|
||||
help="These changes are stashed away from your working directory."
|
||||
reversedDirection>unapplied</Button
|
||||
>
|
||||
{:else if hasIntegratedCommits}
|
||||
{#if hasIntegratedCommits}
|
||||
<Button
|
||||
clickable={false}
|
||||
size="tag"
|
||||
|
@ -110,7 +110,7 @@
|
||||
<div
|
||||
class="branch-card hide-native-scrollbar"
|
||||
data-tauri-drag-region
|
||||
class:target-branch={branch.active && branch.selectedForChanges}
|
||||
class:target-branch={branch.selectedForChanges}
|
||||
>
|
||||
<ScrollableContainer
|
||||
wide
|
||||
@ -148,7 +148,7 @@
|
||||
showCheckboxes={$commitBoxOpen}
|
||||
allowMultiple
|
||||
/>
|
||||
{#if branch.active && branch.conflicted}
|
||||
{#if branch.conflicted}
|
||||
<div class="card-notifications">
|
||||
<InfoMessage filled outlined={false} style="error">
|
||||
<svelte:fragment slot="title">
|
||||
@ -164,18 +164,16 @@
|
||||
{/if}
|
||||
</Dropzones>
|
||||
|
||||
{#if branch.active}
|
||||
<CommitDialog
|
||||
projectId={project.id}
|
||||
expanded={commitBoxOpen}
|
||||
hasSectionsAfter={branch.commits.length > 0}
|
||||
on:action={(e) => {
|
||||
if (e.detail === 'generate-branch-name') {
|
||||
generateBranchName();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
<CommitDialog
|
||||
projectId={project.id}
|
||||
expanded={commitBoxOpen}
|
||||
hasSectionsAfter={branch.commits.length > 0}
|
||||
on:action={(e) => {
|
||||
if (e.detail === 'generate-branch-name') {
|
||||
generateBranchName();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{:else if branch.commits.length === 0}
|
||||
<Dropzones>
|
||||
|
@ -182,33 +182,31 @@
|
||||
|
||||
<div class="header__actions">
|
||||
<div class="header__buttons">
|
||||
{#if branch.active}
|
||||
{#if branch.selectedForChanges}
|
||||
<Button
|
||||
style="pop"
|
||||
kind="soft"
|
||||
help="New changes will land here"
|
||||
icon="target"
|
||||
clickable={false}
|
||||
disabled={isUnapplied}
|
||||
>
|
||||
Default branch
|
||||
</Button>
|
||||
{:else}
|
||||
<Button
|
||||
style="ghost"
|
||||
outline
|
||||
help="When selected, new changes will land here"
|
||||
icon="target"
|
||||
disabled={isUnapplied}
|
||||
on:click={async () => {
|
||||
isTargetBranchAnimated = true;
|
||||
await branchController.setSelectedForChanges(branch.id);
|
||||
}}
|
||||
>
|
||||
Set as default
|
||||
</Button>
|
||||
{/if}
|
||||
{#if branch.selectedForChanges}
|
||||
<Button
|
||||
style="pop"
|
||||
kind="soft"
|
||||
help="New changes will land here"
|
||||
icon="target"
|
||||
clickable={false}
|
||||
disabled={isUnapplied}
|
||||
>
|
||||
Default branch
|
||||
</Button>
|
||||
{:else}
|
||||
<Button
|
||||
style="ghost"
|
||||
outline
|
||||
help="When selected, new changes will land here"
|
||||
icon="target"
|
||||
disabled={isUnapplied}
|
||||
on:click={async () => {
|
||||
isTargetBranchAnimated = true;
|
||||
await branchController.setSelectedForChanges(branch.id);
|
||||
}}
|
||||
>
|
||||
Set as default
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
@ -191,8 +191,7 @@
|
||||
}}
|
||||
disabled={isUnapplied ||
|
||||
!($aiGenEnabled && aiConfigurationValid) ||
|
||||
branch.files?.length === 0 ||
|
||||
!branch.active}
|
||||
branch.files?.length === 0}
|
||||
/>
|
||||
</ContextMenuSection>
|
||||
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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}`;
|
||||
}
|
||||
|
@ -156,7 +156,6 @@ export const file1 = {
|
||||
};
|
||||
|
||||
export const virtualBranch = {
|
||||
active: true,
|
||||
baseCurrent: true,
|
||||
commits: [],
|
||||
conflicted: false,
|
||||
|
@ -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)
|
||||
|
@ -24,7 +24,6 @@ import { writable, type Readable } from 'svelte/store';
|
||||
|
||||
export class VirtualBranchService {
|
||||
branches$: Observable<Branch[] | undefined>;
|
||||
stashedBranches$: Observable<Branch[] | undefined>;
|
||||
activeBranches$: Observable<Branch[] | undefined>;
|
||||
branchesError = writable<any>();
|
||||
private reload$ = new BehaviorSubject<void>(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;
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
|
@ -1,71 +0,0 @@
|
||||
<script lang="ts">
|
||||
// This page is displayed when:
|
||||
// - A vbranch is found
|
||||
// It may also display details about a cooresponding remote and/or pr if they exist
|
||||
import BranchLane from '$lib/branch/BranchLane.svelte';
|
||||
import FullviewLoading from '$lib/components/FullviewLoading.svelte';
|
||||
import Button from '$lib/shared/Button.svelte';
|
||||
import Modal from '$lib/shared/Modal.svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let applyConflictedModal: Modal;
|
||||
let deleteBranchModal: Modal;
|
||||
|
||||
$: ({ projectId, branchController, vbranchService } = data);
|
||||
$: branches$ = vbranchService.branches$;
|
||||
$: error = vbranchService.branchesError;
|
||||
|
||||
$: branch = $branches$?.find((b) => b.id === $page.params.branchId);
|
||||
</script>
|
||||
|
||||
{#if $error}
|
||||
<p>{JSON.stringify($error)}</p>
|
||||
{:else if !$branches$}
|
||||
<FullviewLoading />
|
||||
{:else if branch}
|
||||
<BranchLane {branch} isUnapplied={!branch.active} />
|
||||
{:else}
|
||||
<p>Branch no longer exists</p>
|
||||
{/if}
|
||||
|
||||
<Modal width="small" title="Merge conflicts" bind:this={applyConflictedModal}>
|
||||
<p>Applying this branch will introduce merge conflicts.</p>
|
||||
{#snippet controls(close, item)}
|
||||
<Button style="ghost" outline on:click={close}>Cancel</Button>
|
||||
<Button
|
||||
style="pop"
|
||||
kind="solid"
|
||||
on:click={() => {
|
||||
branchController.applyBranch(item.id);
|
||||
close();
|
||||
goto(`/${projectId}/board`);
|
||||
}}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
{/snippet}
|
||||
</Modal>
|
||||
|
||||
<Modal width="small" title="Delete branch" bind:this={deleteBranchModal}>
|
||||
{#snippet children(item)}
|
||||
Deleting <code class="code-string">{item.name}</code> cannot be undone.
|
||||
{/snippet}
|
||||
{#snippet controls(close, item)}
|
||||
<Button style="ghost" outline on:mousedown={close}>Cancel</Button>
|
||||
<Button
|
||||
style="error"
|
||||
kind="solid"
|
||||
on:click={() => {
|
||||
branchController.deleteBranch(item.id);
|
||||
close();
|
||||
goto(`/${projectId}/board`);
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
{/snippet}
|
||||
</Modal>
|
Loading…
Reference in New Issue
Block a user