瀏覽代碼

Refs #1133 - handles no remote providers

main
Eric Amodio 4 年之前
父節點
當前提交
96b48f8456
共有 1 個檔案被更改,包括 38 行新增9 行删除
  1. +38
    -9
      src/quickpicks/remoteProviderPicker.ts

+ 38
- 9
src/quickpicks/remoteProviderPicker.ts 查看文件

@ -1,5 +1,5 @@
'use strict';
import { Disposable, window } from 'vscode';
import { Disposable, env, Uri, window } from 'vscode';
import { Commands, OpenOnRemoteCommandArgs } from '../commands';
import { GlyphChars } from '../constants';
import {
@ -13,6 +13,16 @@ import {
import { Keys } from '../keyboard';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickpicks';
export class ConfigureCustomRemoteProviderCommandQuickPickItem extends CommandQuickPickItem {
constructor() {
super({ label: 'See how to configure a custom remote provider...' });
}
async execute(): Promise<void> {
await env.openExternal(Uri.parse('https://github.com/eamodio/vscode-gitlens#custom-remotes-settings'));
}
}
export class CopyOrOpenRemoteCommandQuickPickItem extends CommandQuickPickItem {
constructor(
private readonly remote: GitRemote<RemoteProvider>,
@ -115,18 +125,34 @@ export namespace RemoteProviderPicker {
resource: RemoteResource,
remotes: GitRemote<RemoteProvider>[],
options?: { clipboard?: boolean; setDefault?: boolean },
): Promise<CopyOrOpenRemoteCommandQuickPickItem | SetADefaultRemoteCommandQuickPickItem | undefined> {
): Promise<
| ConfigureCustomRemoteProviderCommandQuickPickItem
| CopyOrOpenRemoteCommandQuickPickItem
| SetADefaultRemoteCommandQuickPickItem
| undefined
> {
const { clipboard, setDefault } = { clipboard: false, setDefault: true, ...options };
const items: (CopyOrOpenRemoteCommandQuickPickItem | SetADefaultRemoteCommandQuickPickItem)[] = remotes.map(
r => new CopyOrOpenRemoteCommandQuickPickItem(r, resource, clipboard),
);
if (setDefault) {
items.push(new SetADefaultRemoteCommandQuickPickItem(remotes));
let items: (
| ConfigureCustomRemoteProviderCommandQuickPickItem
| CopyOrOpenRemoteCommandQuickPickItem
| SetADefaultRemoteCommandQuickPickItem
)[];
if (remotes.length === 0) {
items = [new ConfigureCustomRemoteProviderCommandQuickPickItem()];
//
placeHolder = 'No auto-detected or configured remote providers found';
} else {
items = remotes.map(r => new CopyOrOpenRemoteCommandQuickPickItem(r, resource, clipboard));
if (setDefault) {
items.push(new SetADefaultRemoteCommandQuickPickItem(remotes));
}
}
const quickpick = window.createQuickPick<
CopyOrOpenRemoteCommandQuickPickItem | SetADefaultRemoteCommandQuickPickItem
| ConfigureCustomRemoteProviderCommandQuickPickItem
| CopyOrOpenRemoteCommandQuickPickItem
| SetADefaultRemoteCommandQuickPickItem
>();
quickpick.ignoreFocusOut = getQuickPickIgnoreFocusOut();
@ -134,7 +160,10 @@ export namespace RemoteProviderPicker {
try {
const pick = await new Promise<
CopyOrOpenRemoteCommandQuickPickItem | SetADefaultRemoteCommandQuickPickItem | undefined
| ConfigureCustomRemoteProviderCommandQuickPickItem
| CopyOrOpenRemoteCommandQuickPickItem
| SetADefaultRemoteCommandQuickPickItem
| undefined
>(resolve => {
disposables.push(
quickpick.onDidHide(() => resolve(undefined)),

Loading…
取消
儲存