Skip to content

Commit a8002d5

Browse files
authored
create-branch-for-commits (#9870)
* feat(ui): simplify context menu labels for branch creation above/below * feat(commit-menu): put back "branch from/after commit" actions to menu
1 parent 2a4e590 commit a8002d5

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

apps/desktop/src/components/BranchHeaderContextMenu.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
{#if stackId}
195195
<ContextMenuSection>
196196
<ContextMenuItem
197-
label="Create dependent branch above"
197+
label="Create branch above"
198198
disabled={refCreation.current.isLoading}
199199
testId={TestId.BranchHeaderContextMenu_AddDependentBranch}
200200
onclick={async () => {
@@ -203,7 +203,7 @@
203203
}}
204204
/>
205205
<ContextMenuItem
206-
label="Create dependent branch below"
206+
label="Create branch below"
207207
disabled={refCreation.current.isLoading}
208208
onclick={async () => {
209209
await handleCreateNewRef(stackId, 'Below');

apps/desktop/src/components/CommitContextMenu.svelte

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
KebabButton,
5656
TestId
5757
} from '@gitbutler/ui';
58+
import type { AnchorPosition } from '$lib/stacks/stack';
5859
5960
type Props = {
6061
flat?: boolean;
@@ -70,6 +71,7 @@
7071
const stackService = inject(STACK_SERVICE);
7172
const clipboardService = inject(CLIPBOARD_SERVICE);
7273
const [insertBlankCommitInBranch, commitInsertion] = stackService.insertBlankCommit;
74+
const [createRef, refCreation] = stackService.createReference;
7375
7476
let contextMenu = $state<ReturnType<typeof ContextMenu>>();
7577
let kebabButtonElement = $state<HTMLElement>();
@@ -87,6 +89,24 @@
8789
});
8890
}
8991
92+
async function handleCreateNewRef(stackId: string, commitId: string, position: AnchorPosition) {
93+
const newName = await stackService.fetchNewBranchName(projectId);
94+
await createRef({
95+
projectId,
96+
stackId,
97+
request: {
98+
newName,
99+
anchor: {
100+
type: 'atCommit',
101+
subject: {
102+
commit_id: commitId,
103+
position
104+
}
105+
}
106+
}
107+
});
108+
}
109+
90110
function close() {
91111
contextMenu?.close();
92112
}
@@ -194,6 +214,24 @@
194214
}}
195215
/>
196216
</ContextMenuSection>
217+
<ContextMenuSection>
218+
<ContextMenuItem
219+
label="Branch from this commit"
220+
disabled={refCreation.current.isLoading}
221+
onclick={async () => {
222+
await handleCreateNewRef(ensureValue(stackId), commitId, 'Above');
223+
close();
224+
}}
225+
/>
226+
<ContextMenuItem
227+
label="Branch after this commit"
228+
disabled={refCreation.current.isLoading}
229+
onclick={async () => {
230+
await handleCreateNewRef(ensureValue(stackId), commitId, 'Below');
231+
close();
232+
}}
233+
/>
234+
</ContextMenuSection>
197235
{/if}
198236
<ContextMenuSection>
199237
<ContextMenuItem

0 commit comments

Comments
 (0)