Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
53d3fc8d
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
53d3fc8d
编写于
1月 22, 2020
作者:
A
Alex Ross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Stop forwarding port command
上级
f4852c56
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
9 deletion
+63
-9
src/vs/workbench/contrib/remote/browser/tunnelView.ts
src/vs/workbench/contrib/remote/browser/tunnelView.ts
+63
-9
未找到文件。
src/vs/workbench/contrib/remote/browser/tunnelView.ts
浏览文件 @
53d3fc8d
...
...
@@ -14,7 +14,7 @@ import { IContextKeyService, IContextKey, RawContextKey, ContextKeyExpr } from '
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IQuickInputService
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
QuickPickInput
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
ICommandService
,
ICommandHandler
,
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
...
...
@@ -26,7 +26,7 @@ import { IconLabel } from 'vs/base/browser/ui/iconLabel/iconLabel';
import
{
ActionRunner
,
IAction
}
from
'
vs/base/common/actions
'
;
import
{
IMenuService
,
MenuId
,
IMenu
,
MenuRegistry
,
MenuItemAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
createAndFillInContextMenuActions
,
createAndFillInActionBarActions
,
ContextAwareMenuEntryActionViewItem
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
import
{
IRemoteExplorerService
,
TunnelModel
,
MakeAddress
,
TunnelType
,
ITunnelItem
}
from
'
vs/workbench/services/remote/common/remoteExplorerService
'
;
import
{
IRemoteExplorerService
,
TunnelModel
,
MakeAddress
,
TunnelType
,
ITunnelItem
,
Tunnel
}
from
'
vs/workbench/services/remote/common/remoteExplorerService
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
InputBox
,
MessageType
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
...
...
@@ -116,7 +116,7 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
get
forwarded
():
TunnelItem
[]
{
const
forwarded
=
Array
.
from
(
this
.
model
.
forwarded
.
values
()).
map
(
tunnel
=>
{
return
new
TunnelItem
(
TunnelType
.
Forwarded
,
tunnel
.
remoteHost
,
tunnel
.
remotePort
,
tunnel
.
localAddress
,
tunnel
.
closeable
,
tunnel
.
name
,
tunnel
.
description
);
return
TunnelItem
.
createFromTunnel
(
tunnel
);
});
if
(
this
.
remoteExplorerService
.
getEditableData
(
undefined
))
{
forwarded
.
push
(
this
.
_input
);
...
...
@@ -126,7 +126,7 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
get
detected
():
TunnelItem
[]
{
return
Array
.
from
(
this
.
model
.
detected
.
values
()).
map
(
tunnel
=>
{
return
new
TunnelItem
(
TunnelType
.
Detected
,
tunnel
.
remoteHost
,
tunnel
.
remotePort
,
tunnel
.
localAddress
,
false
,
tunnel
.
name
,
tunnel
.
description
);
return
TunnelItem
.
createFromTunnel
(
tunnel
,
TunnelType
.
Detected
,
false
);
});
}
...
...
@@ -352,6 +352,10 @@ interface ITunnelGroup {
}
class
TunnelItem
implements
ITunnelItem
{
static
createFromTunnel
(
tunnel
:
Tunnel
,
type
:
TunnelType
=
TunnelType
.
Forwarded
,
closeable
?:
boolean
)
{
return
new
TunnelItem
(
type
,
tunnel
.
remoteHost
,
tunnel
.
remotePort
,
tunnel
.
localAddress
,
closeable
===
undefined
?
tunnel
.
closeable
:
closeable
,
tunnel
.
name
,
tunnel
.
description
);
}
constructor
(
public
tunnelType
:
TunnelType
,
public
remoteHost
:
string
,
...
...
@@ -681,11 +685,37 @@ namespace ForwardPortAction {
}
}
interface
QuickPickTunnel
extends
IQuickPickItem
{
tunnel
?:
Tunnel
}
function
makeTunnelPicks
(
remoteExplorerService
:
IRemoteExplorerService
):
QuickPickInput
<
QuickPickTunnel
>
[]
{
const
picks
:
QuickPickInput
<
QuickPickTunnel
>
[]
=
[];
Array
.
from
(
remoteExplorerService
.
tunnelModel
.
forwarded
.
values
()).
forEach
(
forwarded
=>
{
if
(
forwarded
.
closeable
)
{
const
item
=
TunnelItem
.
createFromTunnel
(
forwarded
);
picks
.
push
({
label
:
item
.
label
,
description
:
item
.
description
,
tunnel
:
forwarded
});
}
});
if
(
picks
.
length
===
0
)
{
picks
.
push
({
label
:
nls
.
localize
(
'
remote.tunnel.closeNoPorts
'
,
"
No ports currently forwarded. Try running the {0} command
"
,
ForwardPortAction
.
LABEL
)
});
}
return
picks
;
}
namespace
ClosePortAction
{
export
const
ID
=
'
remote.tunnel.close
'
;
export
const
INLINE_ID
=
'
remote.tunnel.closeInline
'
;
export
const
COMMANDPALETTE_ID
=
'
remote.tunnel.closeCommandPalette
'
;
export
const
LABEL
=
nls
.
localize
(
'
remote.tunnel.close
'
,
"
Stop Forwarding Port
"
);
export
function
h
andler
():
ICommandHandler
{
export
function
inlineH
andler
():
ICommandHandler
{
return
async
(
accessor
,
arg
)
=>
{
if
(
arg
instanceof
TunnelItem
)
{
const
remoteExplorerService
=
accessor
.
get
(
IRemoteExplorerService
);
...
...
@@ -693,6 +723,22 @@ namespace ClosePortAction {
}
};
}
export
function
commandPaletteHandler
():
ICommandHandler
{
return
async
(
accessor
)
=>
{
const
quickInputService
=
accessor
.
get
(
IQuickInputService
);
const
remoteExplorerService
=
accessor
.
get
(
IRemoteExplorerService
);
const
commandService
=
accessor
.
get
(
ICommandService
);
const
picks
:
QuickPickInput
<
QuickPickTunnel
>
[]
=
makeTunnelPicks
(
remoteExplorerService
);
const
result
=
await
quickInputService
.
pick
(
picks
,
{
placeHolder
:
nls
.
localize
(
'
remote.tunnel.closePlaceholder
'
,
"
Choose a port to stop forwarding
"
)
});
if
(
result
&&
result
.
tunnel
)
{
await
remoteExplorerService
.
close
({
host
:
result
.
tunnel
.
remoteHost
,
port
:
result
.
tunnel
.
remotePort
});
}
else
if
(
result
)
{
await
commandService
.
executeCommand
(
ForwardPortAction
.
COMMANDPALETTE_ID
);
}
};
}
}
namespace
OpenPortInBrowserAction
{
...
...
@@ -749,11 +795,19 @@ namespace RefreshTunnelViewAction {
CommandsRegistry
.
registerCommand
(
LabelTunnelAction
.
ID
,
LabelTunnelAction
.
handler
());
CommandsRegistry
.
registerCommand
(
ForwardPortAction
.
INLINE_ID
,
ForwardPortAction
.
inlineHandler
());
CommandsRegistry
.
registerCommand
(
ForwardPortAction
.
COMMANDPALETTE_ID
,
ForwardPortAction
.
commandPaletteHandler
());
CommandsRegistry
.
registerCommand
(
ClosePortAction
.
ID
,
ClosePortAction
.
handler
());
CommandsRegistry
.
registerCommand
(
ClosePortAction
.
INLINE_ID
,
ClosePortAction
.
inlineHandler
());
CommandsRegistry
.
registerCommand
(
ClosePortAction
.
COMMANDPALETTE_ID
,
ClosePortAction
.
commandPaletteHandler
());
CommandsRegistry
.
registerCommand
(
OpenPortInBrowserAction
.
ID
,
OpenPortInBrowserAction
.
handler
());
CommandsRegistry
.
registerCommand
(
CopyAddressAction
.
ID
,
CopyAddressAction
.
handler
());
CommandsRegistry
.
registerCommand
(
RefreshTunnelViewAction
.
ID
,
RefreshTunnelViewAction
.
handler
());
MenuRegistry
.
appendMenuItem
(
MenuId
.
CommandPalette
,
({
command
:
{
id
:
ClosePortAction
.
COMMANDPALETTE_ID
,
title
:
ClosePortAction
.
LABEL
},
when
:
forwardedPortsViewEnabled
}));
MenuRegistry
.
appendMenuItem
(
MenuId
.
CommandPalette
,
({
command
:
{
id
:
ForwardPortAction
.
COMMANDPALETTE_ID
,
...
...
@@ -819,7 +873,7 @@ MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
group
:
'
0_manage
'
,
order
:
3
,
command
:
{
id
:
ClosePortAction
.
ID
,
id
:
ClosePortAction
.
I
NLINE_I
D
,
title
:
ClosePortAction
.
LABEL
,
},
when
:
TunnelCloseableContextKey
...
...
@@ -846,7 +900,7 @@ MenuRegistry.appendMenuItem(MenuId.TunnelInline, ({
MenuRegistry
.
appendMenuItem
(
MenuId
.
TunnelInline
,
({
order
:
2
,
command
:
{
id
:
ClosePortAction
.
ID
,
id
:
ClosePortAction
.
I
NLINE_I
D
,
title
:
ClosePortAction
.
LABEL
,
icon
:
{
id
:
'
codicon/x
'
}
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录