Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions apps/desktop/src/components/BranchHeaderContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
const aiService = inject(AI_SERVICE);
const stackService = inject(STACK_SERVICE);
const forge = inject(DEFAULT_FORGE_FACTORY);
const prService = $derived(forge.current.prService);
const prUnit = $derived(prService?.unit);
const promptService = inject(PROMPT_SERVICE);
const urlService = inject(URL_SERVICE);
const clipboardService = inject(CLIPBOARD_SERVICE);
Expand Down Expand Up @@ -303,11 +305,11 @@
<ReduxResult {projectId} {stackId} result={prQuery?.result}>
{#snippet children(pr)}
<ContextMenuSection>
<ContextMenuItemSubmenu label="Pull Request" icon="pr">
<ContextMenuItemSubmenu label={prUnit?.name ?? 'Pull Request'} icon="pr">
{#snippet submenu({ close: closeSubmenu })}
<ContextMenuSection>
<ContextMenuItem
label="Open PR in browser"
label="Open {prUnit?.abbr ?? 'PR'} in browser"
testId={TestId.BranchHeaderContextMenu_OpenPRInBrowser}
onclick={() => {
urlService.openExternalUrl(pr.htmlUrl);
Expand All @@ -316,10 +318,12 @@
}}
/>
<ContextMenuItem
label="Copy PR link"
label="Copy {prUnit?.abbr ?? 'PR'} link"
testId={TestId.BranchHeaderContextMenu_CopyPRLink}
onclick={() => {
clipboardService.write(pr.htmlUrl, { message: 'PR link copied' });
clipboardService.write(pr.htmlUrl, {
message: `${prUnit?.abbr ?? 'PR'} link copied`
});
closeSubmenu();
close();
}}
Expand Down
11 changes: 6 additions & 5 deletions apps/desktop/src/components/BranchReview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
const forge = inject(DEFAULT_FORGE_FACTORY);
const prService = $derived(forge.current.prService);
const reviewUnit = $derived(prService?.unit.abbr);
const reviewUnitName = $derived(prService?.unit.name ?? 'Pull request');

const canPublishPR = $derived(!!canPublishReviewPlugin?.imports.canPublishPR);

Expand All @@ -49,21 +50,21 @@
<Modal
width="small"
type="warning"
title="Create Pull Request"
title="Create {reviewUnitName}"
bind:this={confirmCreatePrModal}
onSubmit={() => {
modal?.show();
}}
>
<p class="text-13 text-body helper-text">
It's strongly recommended to create pull requests starting with the branch at the base of the
stack.
It's strongly recommended to create {reviewUnitName.toLowerCase()}s starting with the branch
at the base of the stack.
<br />
Do you still want to create this pull request?
Do you still want to create this {reviewUnitName.toLowerCase()}?
</p>
{#snippet controls(close)}
<Button kind="outline" onclick={close}>Cancel</Button>
<Button style="warning" type="submit">Create Pull Request</Button>
<Button style="warning" type="submit">Create {reviewUnitName}</Button>
{/snippet}
</Modal>

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/BranchesView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
icon="workbench"
onclick={applyFromFork}
>
Apply PR to workspace
Apply {prUnit?.abbr ?? 'PR'} to workspace
</Button>
{/if}
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/BranchesViewPR.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

<Modal
testId={TestId.BranchesView_CreateRemoteModal}
title="Apply Pull Request"
title="Apply {prUnit?.name ?? 'Pull Request'}"
width="small"
bind:this={createRemoteModal}
onSubmit={async () => await handleConfirmRemote(pr)}
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/components/CanPublishReviewPlugin.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
const prService = $derived(forge.current.prService);
const prQuery = $derived(prNumber ? prService?.get(prNumber) : undefined);
const pr = $derived(prQuery?.response);
const reviewUnitName = $derived(prService?.unit.name ?? 'Pull request');

const canPublishPR = $derived(forge.current.authenticated && !pr);

const ctaLabel = 'Create Pull Request…';
const ctaLabel = $derived(`Create ${reviewUnitName}…`);

export const imports = {
get allowedToPublishPR() {
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/components/PRBranchView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
const prService = $derived(forge.current.prService);
const prQuery = $derived(prService?.get(prNumber, { forceRefetch: true }));
const unitSymbol = $derived(prService?.unit.symbol ?? '');
const unitAbbr = $derived(prService?.unit.abbr ?? 'PR');
</script>

<ReduxResult result={prQuery?.result} {projectId} {onerror}>
{#snippet children(pr)}
<Drawer testId={TestId.PRBranchDrawer} persistId="pr-branch-drawer-{projectId}-{pr.number}">
{#snippet header()}
<h3 class="text-14 text-semibold truncate">
<span class="clr-text-2">PR {unitSymbol}{pr.number}:</span>
<span class="clr-text-2">{unitAbbr} {unitSymbol}{pr.number}:</span>
<span> {pr.title}</span>
</h3>
{/snippet}
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/components/PullRequestCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<ContextMenuItem
label="Copy link"
onclick={() => {
clipboardService.write(pr.htmlUrl, { message: 'PR link copied' });
clipboardService.write(pr.htmlUrl, { message: `${abbr} link copied` });
contextMenuEl?.close();
}}
/>
Expand Down Expand Up @@ -179,7 +179,7 @@
icon="copy-small"
tooltip="Copy {abbr} link"
onclick={() => {
clipboardService.write(pr.htmlUrl, { message: 'PR link copied' });
clipboardService.write(pr.htmlUrl, { message: `${abbr} link copied` });
}}
/>
<Button
Expand Down
6 changes: 4 additions & 2 deletions apps/desktop/src/components/ReviewCreation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
const baseBranchName = $derived(baseBranch?.shortName);
const forge = inject(DEFAULT_FORGE_FACTORY);
const prService = $derived(forge.current.prService);
const prUnit = $derived(prService?.unit);
const stackService = inject(STACK_SERVICE);
const aiService = inject(AI_SERVICE);
const remotesService = inject(REMOTES_SERVICE);
Expand Down Expand Up @@ -423,7 +424,7 @@
onClose();
}
})}
placeholder="PR title"
placeholder="{prUnit?.abbr ?? 'PR'} title"
showCount={false}
oninput={imeHandler.handleInput((e: Event) => {
const target = e.target as HTMLInputElement;
Expand All @@ -439,8 +440,9 @@
initialValue={$prBody}
enableFileUpload
enableSmiles
placeholder="PR Description"
placeholder="{prUnit?.abbr ?? 'PR'} Description"
messageType="pr"
reviewUnitAbbr={prUnit?.abbr}
{onAiButtonClick}
{canUseAI}
{aiIsLoading}
Expand Down
12 changes: 7 additions & 5 deletions apps/desktop/src/components/editor/MessageEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
forceSansFont?: boolean;
useRuler?: boolean;
messageType: 'commit' | 'pr';
reviewUnitAbbr?: string;
}

let {
Expand All @@ -80,7 +81,8 @@
testId,
forceSansFont,
useRuler,
messageType
messageType,
reviewUnitAbbr
}: Props = $props();

const MIN_RULER_VALUE = 30;
Expand Down Expand Up @@ -230,17 +232,17 @@
medium: 320
};

const GENERATE_MESSAGES: Record<typeof messageType, string> = {
const generateMessages = $derived.by(() => ({
commit: 'Generate commit message',
pr: 'Generate PR description'
};
pr: `Generate ${reviewUnitAbbr ?? 'PR'} description`
}));

function getTooltipText(): string | undefined {
if (!canUseAI) {
return 'You need to enable AI in the project settings to use this feature';
}
if (currentEditorWidth <= DROPDOWN_BTN_BREAKPOINTS.medium) {
return GENERATE_MESSAGES[messageType];
return generateMessages[messageType];
}
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<script lang="ts">
import GithubIntegration from '$components/GithubIntegration.svelte';
import { SETTINGS_SERVICE } from '$lib/config/appSettingsV2';
import { DEFAULT_FORGE_FACTORY } from '$lib/forge/forgeFactory.svelte';
import { inject } from '@gitbutler/core/context';
import { CardGroup, Spacer, Toggle } from '@gitbutler/ui';

const settingsService = inject(SETTINGS_SERVICE);
const appSettings = settingsService.appSettings;
const forge = inject(DEFAULT_FORGE_FACTORY);
const prService = $derived(forge.current.prService);
const prUnit = $derived(prService?.unit);

async function toggleAutoFillPrDescription() {
await settingsService.updateReviews({
Expand All @@ -20,11 +24,11 @@

<CardGroup.Item labelFor="autoFillPrDescription">
{#snippet title()}
Auto-fill PR descriptions from commit
Auto-fill {prUnit?.abbr ?? 'PR'} descriptions from commit
{/snippet}
{#snippet caption()}
When creating a pull request for a branch with just one commit, automatically use that commit's
message as the PR title and description.
Comment on lines 22 to 27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make sense to dynamically switch here since it's in the global settings.

If we want to be "inclusive" about this one, we should say "PR/MR" here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1cf4d11. Changed to static "PR/MR" text since this is in global settings and not project-specific.

When creating a {prUnit?.name.toLowerCase() ?? 'pull request'} for a branch with just one commit,
automatically use that commit's message as the {prUnit?.abbr ?? 'PR'} title and description.
{/snippet}
{#snippet actions()}
<Toggle
Expand Down
Loading