Skip to content

Commit 6ef2437

Browse files
committed
Fixes publishing branch from home view
1 parent aeb49a3 commit 6ef2437

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/webviews/apps/plus/home/components/active-work.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export class GlActiveBranchCard extends GlBranchCardBase {
283283
<gl-button
284284
aria-busy=${ifDefined(isFetching)}
285285
?disabled=${isFetching}
286-
href=${createWebviewCommandLink('gitlens.views.home.publishBranch', 'gitlens.views.home', '')}
286+
href=${this.createWebviewCommandLink('gitlens.views.home.publishBranch')}
287287
full
288288
appearance="secondary"
289289
><code-icon icon="cloud-upload" slot="prefix"></code-icon> Publish Branch<span slot="tooltip"

src/webviews/apps/plus/home/components/branch-card.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { customElement, property, state } from 'lit/decorators.js';
55
import { classMap } from 'lit/directives/class-map.js';
66
import { when } from 'lit/directives/when.js';
77
import type { GlCommands } from '../../../../../constants.commands';
8+
import type { WebviewIds, WebviewViewIds } from '../../../../../constants.views';
89
import type { LaunchpadCommandArgs } from '../../../../../plus/launchpad/launchpad';
910
import {
1011
actionGroupMap,
@@ -16,6 +17,7 @@ import type { AssociateIssueWithBranchCommandArgs } from '../../../../../plus/st
1617
import { createCommandLink } from '../../../../../system/commands';
1718
import { fromNow } from '../../../../../system/date';
1819
import { interpolate, pluralize } from '../../../../../system/string';
20+
import { createWebviewCommandLink } from '../../../../../system/webview';
1921
import type {
2022
BranchRef,
2123
CreatePullRequestCommandArgs,
@@ -694,6 +696,18 @@ export abstract class GlBranchCardBase extends GlElement {
694696
return html`<action-nav class="branch-item__collapsed-actions">${actions}</action-nav>`;
695697
}
696698

699+
protected createWebviewCommandLink<T>(
700+
command: `${WebviewIds | WebviewViewIds}.${string}` | `gitlens.plus.${string}`,
701+
args?: T | any,
702+
): string {
703+
return createWebviewCommandLink<T>(
704+
command,
705+
'gitlens.views.home',
706+
'',
707+
args ? { ...args, ...this.branchRef } : this.branchRef,
708+
);
709+
}
710+
697711
protected createCommandLink<T>(command: GlCommands, args?: T | any): string {
698712
return createCommandLink<T>(command, args ? { ...args, ...this.branchRef } : this.branchRef);
699713
}

src/webviews/home/homeWebview.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
284284
return Promise.resolve();
285285
}
286286

287+
private async publishBranch(ref: BranchRef) {
288+
const { repo, branch } = await this.getRepoInfoFromRef(ref);
289+
if (branch == null) return;
290+
291+
return RepoActions.push(repo, undefined, getReferenceFromBranch(branch));
292+
}
293+
287294
private async pull() {
288295
const repo = this.getSelectedRepository();
289296
if (repo) {
@@ -305,7 +312,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
305312
},
306313
this,
307314
),
308-
registerCommand(`${this.host.id}.publishBranch`, this.push, this),
315+
registerCommand(`${this.host.id}.publishBranch`, this.publishBranch, this),
309316
registerCommand(`${this.host.id}.refresh`, () => this.host.refresh(true), this),
310317
registerCommand(`${this.host.id}.disablePreview`, () => this.onTogglePreviewEnabled(false), this),
311318
registerCommand(`${this.host.id}.enablePreview`, () => this.onTogglePreviewEnabled(true), this),

0 commit comments

Comments
 (0)