Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 6 additions & 4 deletions apps/desktop/src/components/BranchHeaderContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@
<ReduxResult {projectId} {stackId} result={prQuery?.result}>
{#snippet children(pr)}
<ContextMenuSection>
<ContextMenuItemSubmenu label="Pull Request" icon="pr">
<ContextMenuItemSubmenu label={forge.reviewUnitName} icon="pr">
{#snippet submenu({ close: closeSubmenu })}
<ContextMenuSection>
<ContextMenuItem
label="Open PR in browser"
label="Open {forge.reviewUnitAbbr} in browser"
testId={TestId.BranchHeaderContextMenu_OpenPRInBrowser}
onclick={() => {
urlService.openExternalUrl(pr.htmlUrl);
Expand All @@ -316,10 +316,12 @@
}}
/>
<ContextMenuItem
label="Copy PR link"
label="Copy {forge.reviewUnitAbbr} link"
testId={TestId.BranchHeaderContextMenu_CopyPRLink}
onclick={() => {
clipboardService.write(pr.htmlUrl, { message: 'PR link copied' });
clipboardService.write(pr.htmlUrl, {
message: `${forge.reviewUnitAbbr} link copied`
});
closeSubmenu();
close();
}}
Expand Down
10 changes: 5 additions & 5 deletions apps/desktop/src/components/BranchReview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@
<Modal
width="small"
type="warning"
title="Create Pull Request"
title="Create {forge.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 {forge.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 {forge.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 {forge.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 {forge.reviewUnitAbbr} 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 {forge.reviewUnitName}"
width="small"
bind:this={createRemoteModal}
onSubmit={async () => await handleConfirmRemote(pr)}
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/CanPublishReviewPlugin.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

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

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

export const imports = {
get allowedToPublishPR() {
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/components/PRBranchView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
const forge = inject(DEFAULT_FORGE_FACTORY);
const prService = $derived(forge.current.prService);
const prQuery = $derived(prService?.get(prNumber, { forceRefetch: true }));
const unitSymbol = $derived(prService?.unit.symbol ?? '');
</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">{forge.reviewUnitAbbr} {forge.reviewUnitSymbol}{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
5 changes: 3 additions & 2 deletions apps/desktop/src/components/ReviewCreation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@
onClose();
}
})}
placeholder="PR title"
placeholder="{forge.reviewUnitAbbr} title"
showCount={false}
oninput={imeHandler.handleInput((e: Event) => {
const target = e.target as HTMLInputElement;
Expand All @@ -439,8 +439,9 @@
initialValue={$prBody}
enableFileUpload
enableSmiles
placeholder="PR Description"
placeholder="{forge.reviewUnitAbbr} Description"
messageType="pr"
reviewUnitAbbr={forge.reviewUnitAbbr}
{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
Expand Up @@ -20,11 +20,11 @@

<CardGroup.Item labelFor="autoFillPrDescription">
{#snippet title()}
Auto-fill PR descriptions from commit
Auto-fill PR/MR 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.
When creating a pull request or merge request for a branch with just one commit, automatically
use that commit's message as the PR/MR title and description.
{/snippet}
{#snippet actions()}
<Toggle
Expand Down
21 changes: 21 additions & 0 deletions apps/desktop/src/lib/forge/forgeFactory.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ export class DefaultForgeFactory implements Reactive<Forge> {
return this._canSetupIntegration;
}

/**
* Get review unit abbreviation with fallback to 'PR'
*/
get reviewUnitAbbr(): string {
return this._forge.prService?.unit.abbr ?? 'PR';
}

/**
* Get review unit name with fallback to 'Pull request'
*/
get reviewUnitName(): string {
return this._forge.prService?.unit.name ?? 'Pull request';
}

/**
* Get review unit symbol with fallback to '#'
*/
get reviewUnitSymbol(): string {
return this._forge.prService?.unit.symbol ?? '#';
}

setConfig(config: ForgeConfig) {
if (deepCompare(config, this._config)) {
return;
Expand Down
Loading