Skip to content

Commit d9a9836

Browse files
authored
add-hotkey-tip-to-create-pr (#9898)
* feat(ui/desktop): add hotkey prop to dropdown and review submit * fix: rename DropDownButton to DropdownButton and adjust usages, plus tweak commit view height to 50vh * feat: submit on Ctrl/CmdEnter in editor We were able to submit using hotkey on the PR body level but it should be on the title as well
1 parent c91811b commit d9a9836

File tree

10 files changed

+35
-25
lines changed

10 files changed

+35
-25
lines changed

apps/desktop/src/components/CommitView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
.commit-view {
258258
position: relative;
259259
/* Limit the commit view to at most 40vh to ensure other sections remain visible */
260-
max-height: 40vh;
260+
max-height: 50vh;
261261
background-color: var(--clr-bg-1);
262262
}
263263

apps/desktop/src/components/MergeButton.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { MergeMethod } from '$lib/forge/interface/types';
33
import { persisted, type Persisted } from '@gitbutler/shared/persisted';
44
5-
import { ContextMenuItem, ContextMenuSection, DropDownButton } from '@gitbutler/ui';
5+
import { ContextMenuItem, ContextMenuSection, DropdownButton } from '@gitbutler/ui';
66
import type { ButtonProps } from '@gitbutler/ui';
77
88
interface Props {
@@ -32,7 +32,7 @@
3232
3333
const action = persistedAction(projectId);
3434
35-
let dropDown: ReturnType<typeof DropDownButton> | undefined;
35+
let dropDown: ReturnType<typeof DropdownButton> | undefined;
3636
let loading = $state(false);
3737
3838
const labels = {
@@ -42,7 +42,7 @@
4242
};
4343
</script>
4444

45-
<DropDownButton
45+
<DropdownButton
4646
bind:this={dropDown}
4747
onclick={async () => {
4848
loading = true;
@@ -73,4 +73,4 @@
7373
{/each}
7474
</ContextMenuSection>
7575
{/snippet}
76-
</DropDownButton>
76+
</DropdownButton>

apps/desktop/src/components/ReviewCreation.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@
386386
messageEditor?.focus();
387387
}
388388

389+
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
390+
e.preventDefault();
391+
createReview();
392+
return true;
393+
}
394+
389395
if (e.key === 'Escape') {
390396
e.preventDefault();
391397
onClose();

apps/desktop/src/components/ReviewCreationControls.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Button,
66
ContextMenuItem,
77
ContextMenuSection,
8-
DropDownButton,
8+
DropdownButton,
99
TestId
1010
} from '@gitbutler/ui';
1111
@@ -22,7 +22,7 @@
2222
$props();
2323
2424
const unit = $derived(reviewUnit ?? 'PR');
25-
let commitButton = $state<DropDownButton>();
25+
let commitButton = $state<DropdownButton>();
2626
2727
const createDraft = persisted<boolean>(false, 'createDraftPr');
2828
</script>
@@ -36,7 +36,7 @@
3636
onclick={onCancel}>Cancel</Button
3737
>
3838

39-
<DropDownButton
39+
<DropdownButton
4040
testId={TestId.ReviewCreateButton}
4141
bind:this={commitButton}
4242
onclick={() => {
@@ -47,6 +47,7 @@
4747
style="pop"
4848
loading={isSubmitting}
4949
disabled={submitDisabled}
50+
hotkey="⌘↵"
5051
>
5152
{$createDraft ? `Create ${unit} draft` : `Create ${unit}`}
5253

@@ -70,7 +71,7 @@
7071
/>
7172
</ContextMenuSection>
7273
{/snippet}
73-
</DropDownButton>
74+
</DropdownButton>
7475
</div>
7576

7677
<style lang="postcss">

apps/desktop/src/components/editor/MessageEditor.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Checkbox,
2525
ContextMenuItem,
2626
ContextMenuSection,
27-
DropDownButton,
27+
DropdownButton,
2828
EmojiPickerButton,
2929
Modal,
3030
RichTextEditor,
@@ -416,7 +416,7 @@
416416
{/if}
417417
{/if}
418418
</div>
419-
<DropDownButton
419+
<DropdownButton
420420
kind="outline"
421421
icon="ai-small"
422422
shrinkable
@@ -448,7 +448,7 @@
448448
</ContextMenuItem>
449449
</ContextMenuSection>
450450
{/snippet}
451-
</DropDownButton>
451+
</DropdownButton>
452452
</div>
453453
</div>
454454
</div>

apps/web/src/lib/components/chat/ChatInput.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Button,
2121
ContextMenuItem,
2222
ContextMenuSection,
23-
DropDownButton,
23+
DropdownButton,
2424
EmojiPickerButton,
2525
Mention as MentionsPlugin,
2626
RichTextEditor
@@ -169,7 +169,7 @@
169169
type Action = keyof typeof actionLabels;
170170
171171
let action = $state<Action>('approve');
172-
let dropDownButton = $state<ReturnType<typeof DropDownButton>>();
172+
let dropDownButton = $state<ReturnType<typeof DropdownButton>>();
173173
174174
async function approve() {
175175
await patchCommitService.updatePatch(branchUuid, changeId, {
@@ -312,7 +312,7 @@
312312

313313
<div class="chat-input__action-buttons">
314314
{#if isPatchAuthor === false}
315-
<DropDownButton
315+
<DropdownButton
316316
bind:this={dropDownButton}
317317
loading={isSendingMessage || isExecuting}
318318
style="neutral"
@@ -345,7 +345,7 @@
345345
/>
346346
</ContextMenuSection>
347347
{/snippet}
348-
</DropDownButton>
348+
</DropdownButton>
349349
{/if}
350350
<Button
351351
style="pop"

apps/web/src/lib/components/review/ChangeActionButton.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
CommitStatusBadge,
99
ContextMenuItem,
1010
ContextMenuSection,
11-
DropDownButton
11+
DropdownButton
1212
} from '@gitbutler/ui';
1313
1414
interface Props {
@@ -45,7 +45,7 @@
4545
let loginModal = $state<LoginModal>();
4646
let action = $state<Action>('approve');
4747
let isExecuting = $state(false);
48-
let dropDownButton = $state<ReturnType<typeof DropDownButton>>();
48+
let dropDownButton = $state<ReturnType<typeof DropdownButton>>();
4949
5050
const buttonColor = $derived.by(() => {
5151
switch (action) {
@@ -134,7 +134,7 @@
134134
</button>
135135
</div>
136136
{:else}
137-
<DropDownButton
137+
<DropdownButton
138138
bind:this={dropDownButton}
139139
loading={isExecuting}
140140
menuPosition="top"
@@ -161,7 +161,7 @@
161161
/>
162162
</ContextMenuSection>
163163
{/snippet}
164-
</DropDownButton>
164+
</DropdownButton>
165165
{/if}
166166

167167
<LoginModal bind:this={loginModal}>

packages/shared/src/lib/organizations/PermissionsSelector.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { PROJECT_SERVICE } from '$lib/organizations/projectService';
55
import { getProjectByRepositoryId } from '$lib/organizations/projectsPreview.svelte';
66
import { ShareLevel } from '$lib/permissions';
7-
import { ContextMenuItem, ContextMenuSection, DropDownButton } from '@gitbutler/ui';
7+
import { ContextMenuItem, ContextMenuSection, DropdownButton } from '@gitbutler/ui';
88
99
type Props = {
1010
repositoryId: string;
@@ -41,13 +41,13 @@
4141
}
4242
}
4343
44-
let dropDownButton = $state<DropDownButton>();
44+
let dropDownButton = $state<DropdownButton>();
4545
let dropDownEnabled = $state(true);
4646
</script>
4747

4848
<Loading loadable={project.current}>
4949
{#snippet children(project)}
50-
<DropDownButton bind:this={dropDownButton} loading={!dropDownEnabled} kind="outline">
50+
<DropdownButton bind:this={dropDownButton} loading={!dropDownEnabled} kind="outline">
5151
{options.find((option) => option.key === project.permissions.shareLevel)?.label}
5252

5353
{#snippet contextMenuSlot()}
@@ -61,6 +61,6 @@
6161
{/each}
6262
</ContextMenuSection>
6363
{/snippet}
64-
</DropDownButton>
64+
</DropdownButton>
6565
{/snippet}
6666
</Loading>

packages/ui/src/lib/components/DropDownButton.svelte renamed to packages/ui/src/lib/components/DropdownButton.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
type?: 'button' | 'submit' | 'reset';
2222
menuPosition?: 'top' | 'bottom';
2323
shrinkable?: boolean;
24+
hotkey?: string;
2425
children?: Snippet;
2526
contextMenuSlot: Snippet;
2627
onclick?: (e: MouseEvent) => void;
@@ -41,6 +42,7 @@
4142
tooltip,
4243
menuPosition = 'bottom',
4344
shrinkable,
45+
hotkey,
4446
children,
4547
contextMenuSlot,
4648
onclick
@@ -76,6 +78,7 @@
7678
{shrinkable}
7779
{type}
7880
{width}
81+
{hotkey}
7982
reversedDirection
8083
disabled={disabled || loading}
8184
dropdownChild

packages/ui/src/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export {
1111
export { default as ContextMenu } from '$components/ContextMenu.svelte';
1212
export { default as ContextMenuItem } from '$components/ContextMenuItem.svelte';
1313
export { default as ContextMenuSection } from '$components/ContextMenuSection.svelte';
14-
export { default as DropDownButton } from '$components/DropDownButton.svelte';
14+
export { default as DropdownButton } from '$components/DropdownButton.svelte';
1515
export { default as EditorLogo } from '$components/EditorLogo.svelte';
1616
export { default as EmptyStatePlaceholder } from '$components/EmptyStatePlaceholder.svelte';
1717
export { default as HunkDiff, type LineClickParams } from '$components/hunkDiff/HunkDiff.svelte';

0 commit comments

Comments
 (0)