提交 99e822ef 编写于 作者: A Alex Ross

Tweak strings in tunnel UI

上级 b8025bcf
......@@ -12,7 +12,7 @@ export const ITunnelService = createDecorator<ITunnelService>('tunnelService');
export interface RemoteTunnel {
readonly tunnelRemotePort: number;
readonly tunnelLocalPort: number;
readonly localAddress?: URI;
readonly localAddress?: string;
dispose(): void;
}
......
......@@ -29,7 +29,6 @@ import { IMenuService, MenuId, IMenu, MenuRegistry, MenuItemAction } from 'vs/pl
import { createAndFillInContextMenuActions, createAndFillInActionBarActions, ContextAwareMenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { IRemoteExplorerService, TunnelModel } from 'vs/workbench/services/remote/common/remoteExplorerService';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { URI } from 'vs/workbench/workbench.web.api';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { InputBox, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
import { attachInputBoxStyler } from 'vs/platform/theme/common/styler';
......@@ -37,6 +36,7 @@ import { once } from 'vs/base/common/functional';
import { KeyCode } from 'vs/base/common/keyCodes';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { URI } from 'vs/base/common/uri';
class TunnelTreeVirtualDelegate implements IListVirtualDelegate<ITunnelItem> {
getHeight(element: ITunnelItem): number {
......@@ -103,13 +103,13 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
get forwarded(): TunnelItem[] {
return Array.from(this.model.forwarded.values()).map(tunnel => {
return new TunnelItem(TunnelType.Forwarded, tunnel.remote, tunnel.closeable, tunnel.name, tunnel.description, tunnel.local);
return new TunnelItem(TunnelType.Forwarded, tunnel.remote, tunnel.localAddress, tunnel.closeable, tunnel.name, tunnel.description);
});
}
get published(): TunnelItem[] {
return Array.from(this.model.published.values()).map(tunnel => {
return new TunnelItem(TunnelType.Published, tunnel.remote, false, tunnel.name, tunnel.description, tunnel.local);
return new TunnelItem(TunnelType.Published, tunnel.remote, tunnel.localAddress, false, tunnel.name, tunnel.description);
});
}
......@@ -119,7 +119,7 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
let iterator = values.next();
while (!iterator.done) {
if (!this.model.forwarded.has(iterator.value.remote) && !this.model.published.has(iterator.value.remote)) {
candidates.push(new TunnelItem(TunnelType.Candidate, iterator.value.remote, false, undefined, iterator.value.description));
candidates.push(new TunnelItem(TunnelType.Candidate, iterator.value.remote, iterator.value.localAddress, false, undefined, iterator.value.description));
}
iterator = values.next();
}
......@@ -333,7 +333,7 @@ interface ITunnelGroup {
interface ITunnelItem {
tunnelType: TunnelType;
remote: number;
local?: number;
localAddress?: string;
name?: string;
closeable?: boolean;
readonly description?: string;
......@@ -344,33 +344,28 @@ class TunnelItem implements ITunnelItem {
constructor(
public tunnelType: TunnelType,
public remote: number,
public localAddress?: string,
public closeable?: boolean,
public name?: string,
private _description?: string,
public local?: number,
) { }
get label(): string {
if (this.name && this.local) {
if (this.name) {
return nls.localize('remote.tunnelsView.forwardedPortLabel0', "{0}", this.name);
} else if (this.local === this.remote) {
return nls.localize('remote.tunnelsView.forwardedPortLabel1', "{0} to localhost", this.remote);
} else if (this.local) {
return nls.localize('remote.tunnelsView.forwardedPortLabel2', "{0} to localhost:{1}", this.remote, this.local);
} else if (this.localAddress) {
return nls.localize('remote.tunnelsView.forwardedPortLabel2', "{0} to {1}", this.remote, this.localAddress);
} else {
return nls.localize('remote.tunnelsView.forwardedPortLabel3', "{0} not forwarded", this.remote);
}
}
get description(): string | undefined {
if (this.name) {
return nls.localize('remote.tunnelsView.forwardedPortDescription0', "remote {0} available at {1}", this.remote, this.local);
} else if (this.local === this.remote) {
return nls.localize('remote.tunnelsView.forwardedPortDescription1', "available at {0}", this.local);
} else if (this.local) {
return this._description;
} else {
if (this._description) {
return this._description;
} else if (this.name) {
return nls.localize('remote.tunnelsView.forwardedPortDescription0', "{0} to {1}", this.remote, this.localAddress);
}
return undefined;
}
}
......@@ -562,7 +557,7 @@ export class TunnelPanelDescriptor implements IViewDescriptor {
namespace NameTunnelAction {
export const ID = 'remote.tunnel.name';
export const LABEL = nls.localize('remote.tunnel.name', "Name Tunnel");
export const LABEL = nls.localize('remote.tunnel.name', "Rename");
export function handler(): ICommandHandler {
return async (accessor, arg) => {
......@@ -576,7 +571,7 @@ namespace NameTunnelAction {
remoteExplorerService.setEditable(arg.remote, null);
},
validationMessage: () => null,
placeholder: nls.localize('remote.tunnelsView.namePlaceholder', "Name port"),
placeholder: nls.localize('remote.tunnelsView.namePlaceholder', "Port name"),
startingValue: arg.name
});
}
......@@ -644,9 +639,9 @@ namespace OpenPortInBrowserAction {
const model = accessor.get(IRemoteExplorerService).tunnelModel;
const openerService = accessor.get(IOpenerService);
const tunnel = model.forwarded.has(arg.remote) ? model.forwarded.get(arg.remote) : model.published.get(arg.remote);
let address: URI | undefined;
if (tunnel && tunnel.localUri && (address = model.address(tunnel.remote))) {
return openerService.open(address);
let address: string | undefined;
if (tunnel && tunnel.localAddress && (address = model.address(tunnel.remote))) {
return openerService.open(URI.parse(address));
}
return Promise.resolve();
}
......
......@@ -10,7 +10,6 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ExtensionsRegistry, IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { URI } from 'vs/base/common/uri';
import { ITunnelService } from 'vs/platform/remote/common/tunnel';
import { Disposable } from 'vs/base/common/lifecycle';
import { IEditableData } from 'vs/workbench/common/views';
......@@ -20,7 +19,7 @@ export const REMOTE_EXPLORER_TYPE_KEY: string = 'remote.explorerType';
export interface Tunnel {
remote: number;
localUri: URI;
localAddress: string;
local?: number;
name?: string;
description?: string;
......@@ -47,7 +46,7 @@ export class TunnelModel extends Disposable {
if (tunnel.localAddress) {
this.forwarded.set(tunnel.tunnelRemotePort, {
remote: tunnel.tunnelRemotePort,
localUri: tunnel.localAddress,
localAddress: tunnel.localAddress,
local: tunnel.tunnelLocalPort
});
}
......@@ -63,7 +62,7 @@ export class TunnelModel extends Disposable {
if (!this.forwarded.has(tunnel.tunnelRemotePort) && tunnel.localAddress) {
this.forwarded.set(tunnel.tunnelRemotePort, {
remote: tunnel.tunnelRemotePort,
localUri: tunnel.localAddress,
localAddress: tunnel.localAddress,
local: tunnel.tunnelLocalPort
});
}
......@@ -86,7 +85,7 @@ export class TunnelModel extends Disposable {
local: tunnel.tunnelLocalPort,
name: name,
closeable: true,
localUri: tunnel.localAddress
localAddress: tunnel.localAddress
};
this.forwarded.set(remote, newForward);
this._onForwardPort.fire(newForward);
......@@ -105,8 +104,8 @@ export class TunnelModel extends Disposable {
return this.tunnelService.closeTunnel(remote);
}
address(remote: number): URI | undefined {
return (this.forwarded.get(remote) || this.published.get(remote))?.localUri;
address(remote: number): string | undefined {
return (this.forwarded.get(remote) || this.published.get(remote))?.localAddress;
}
}
......
......@@ -17,7 +17,6 @@ import { ISignService } from 'vs/platform/sign/common/sign';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ILogService } from 'vs/platform/log/common/log';
import { findFreePort } from 'vs/base/node/ports';
import { URI } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
export async function createRemoteTunnel(options: IConnectionOptions, tunnelRemotePort: number, tunnelLocalPort?: number): Promise<RemoteTunnel> {
......@@ -29,7 +28,7 @@ class NodeRemoteTunnel extends Disposable implements RemoteTunnel {
public readonly tunnelRemotePort: number;
public tunnelLocalPort!: number;
public localAddress?: URI;
public localAddress?: string;
private readonly _options: IConnectionOptions;
private readonly _server: net.Server;
......@@ -71,7 +70,7 @@ class NodeRemoteTunnel extends Disposable implements RemoteTunnel {
this.tunnelLocalPort = address.port;
await this._barrier.wait();
this.localAddress = URI.from({ scheme: 'http', authority: 'localhost:' + address.port });
this.localAddress = 'localhost:' + address.port;
return this;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册