File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed
apps/desktop/src/components Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 194
194
{#if stackId }
195
195
<ContextMenuSection >
196
196
<ContextMenuItem
197
- label =" Create dependent branch above"
197
+ label =" Create branch above"
198
198
disabled ={refCreation .current .isLoading }
199
199
testId ={TestId .BranchHeaderContextMenu_AddDependentBranch }
200
200
onclick ={async () => {
203
203
}}
204
204
/>
205
205
<ContextMenuItem
206
- label =" Create dependent branch below"
206
+ label =" Create branch below"
207
207
disabled ={refCreation .current .isLoading }
208
208
onclick ={async () => {
209
209
await handleCreateNewRef (stackId , ' Below' );
Original file line number Diff line number Diff line change 55
55
KebabButton ,
56
56
TestId
57
57
} from ' @gitbutler/ui' ;
58
+ import type { AnchorPosition } from ' $lib/stacks/stack' ;
58
59
59
60
type Props = {
60
61
flat? : boolean ;
70
71
const stackService = inject (STACK_SERVICE );
71
72
const clipboardService = inject (CLIPBOARD_SERVICE );
72
73
const [insertBlankCommitInBranch, commitInsertion] = stackService .insertBlankCommit ;
74
+ const [createRef, refCreation] = stackService .createReference ;
73
75
74
76
let contextMenu = $state <ReturnType <typeof ContextMenu >>();
75
77
let kebabButtonElement = $state <HTMLElement >();
87
89
});
88
90
}
89
91
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
+
90
110
function close() {
91
111
contextMenu ?.close ();
92
112
}
194
214
}}
195
215
/>
196
216
</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 >
197
235
{/if }
198
236
<ContextMenuSection >
199
237
<ContextMenuItem
You can’t perform that action at this time.
0 commit comments