Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
35359edc
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,发现更多精彩内容 >>
未验证
提交
35359edc
编写于
8月 11, 2020
作者:
J
João Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
scm: repositories visibility
上级
9a043397
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
12 deletion
+88
-12
src/vs/workbench/contrib/scm/browser/scmViewPane.ts
src/vs/workbench/contrib/scm/browser/scmViewPane.ts
+33
-11
src/vs/workbench/contrib/scm/browser/scmViewService.ts
src/vs/workbench/contrib/scm/browser/scmViewService.ts
+25
-0
src/vs/workbench/contrib/scm/browser/util.ts
src/vs/workbench/contrib/scm/browser/util.ts
+26
-1
src/vs/workbench/contrib/scm/common/scm.ts
src/vs/workbench/contrib/scm/common/scm.ts
+4
-0
未找到文件。
src/vs/workbench/contrib/scm/browser/scmViewPane.ts
浏览文件 @
35359edc
...
...
@@ -23,7 +23,7 @@ import { MenuItemAction, IMenuService } from 'vs/platform/actions/common/actions
import
{
IAction
,
IActionViewItem
,
ActionRunner
,
Action
,
RadioGroup
,
Separator
,
SubmenuAction
,
IActionViewItemProvider
}
from
'
vs/base/common/actions
'
;
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IThemeService
,
LIGHT
,
registerThemingParticipant
,
IFileIconTheme
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
isSCMResource
,
isSCMResourceGroup
,
connectPrimaryMenuToInlineActionBar
,
isSCMRepository
,
isSCMInput
,
collectContextMenuActions
,
StatusBarAction
,
StatusBarActionViewItem
}
from
'
./util
'
;
import
{
isSCMResource
,
isSCMResourceGroup
,
connectPrimaryMenuToInlineActionBar
,
isSCMRepository
,
isSCMInput
,
collectContextMenuActions
,
StatusBarAction
,
StatusBarActionViewItem
,
getRepositoryVisibilityActions
}
from
'
./util
'
;
import
{
attachBadgeStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
WorkbenchCompressibleObjectTree
,
IOpenEvent
}
from
'
vs/platform/list/browser/listService
'
;
import
{
IConfigurationService
,
ConfigurationTarget
,
IConfigurationChangeEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -750,6 +750,7 @@ class ViewModel {
private
inputRenderer
:
InputRenderer
,
private
_mode
:
ViewModelMode
,
private
_sortKey
:
ViewModelSortKey
,
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
,
@
IEditorService
protected
editorService
:
IEditorService
,
@
IConfigurationService
protected
configurationService
:
IConfigurationService
,
@
ISCMViewService
private
scmViewService
:
ISCMViewService
...
...
@@ -1003,7 +1004,7 @@ class ViewModel {
}
if
(
!
this
.
viewSubMenuAction
)
{
this
.
viewSubMenuAction
=
new
SCMViewSubMenuAction
(
this
);
this
.
viewSubMenuAction
=
this
.
instantiationService
.
createInstance
(
SCMViewSubMenuAction
,
this
);
this
.
disposables
.
add
(
this
.
viewSubMenuAction
);
}
...
...
@@ -1073,25 +1074,43 @@ class ViewModel {
}
}
class
SCMViewSubMenuAction
extends
SubmenuAction
{
class
SCMView
Repositories
SubMenuAction
extends
SubmenuAction
{
readonly
actions
!
:
IAction
[];
get
actions
():
IAction
[]
{
return
getRepositoryVisibilityActions
(
this
.
scmService
,
this
.
scmViewService
);
}
constructor
(
viewModel
:
ViewModel
)
{
constructor
(
@
ISCMService
private
readonly
scmService
:
ISCMService
,
@
ISCMViewService
private
readonly
scmViewService
:
ISCMViewService
,
)
{
super
(
'
scm.repositories
'
,
localize
(
'
repositories
'
,
"
Repositories
"
),
[]);
}
}
class
SCMViewSubMenuAction
extends
SubmenuAction
{
constructor
(
viewModel
:
ViewModel
,
@
IInstantiationService
instantiationService
:
IInstantiationService
)
{
const
listAction
=
new
SCMViewModeListAction
(
viewModel
);
const
treeAction
=
new
SCMViewModeTreeAction
(
viewModel
);
const
sortByNameAction
=
new
SCMSortByNameAction
(
viewModel
);
const
sortByPathAction
=
new
SCMSortByPathAction
(
viewModel
);
const
sortByStatusAction
=
new
SCMSortByStatusAction
(
viewModel
);
const
actions
=
[
instantiationService
.
createInstance
(
SCMViewRepositoriesSubMenuAction
),
new
Separator
(),
...
new
RadioGroup
([
listAction
,
treeAction
]).
actions
,
new
Separator
(),
...
new
RadioGroup
([
sortByNameAction
,
sortByPathAction
,
sortByStatusAction
]).
actions
];
super
(
'
scm.viewsort
'
,
localize
(
'
sortAction
'
,
"
View & Sort
"
),
[
...
new
RadioGroup
([
listAction
,
treeAction
]).
actions
,
new
Separator
(),
...
new
RadioGroup
([
sortByNameAction
,
sortByPathAction
,
sortByStatusAction
]).
actions
]
actions
);
this
.
_register
(
combinedDisposable
(
listAction
,
treeAction
,
sortByNameAction
,
sortByPathAction
,
sortByStatusAction
));
...
...
@@ -1771,7 +1790,10 @@ export class SCMViewPane extends ViewPane {
private
onListContextMenu
(
e
:
ITreeContextMenuEvent
<
TreeElement
|
null
>
):
void
{
if
(
!
e
.
element
)
{
return
;
return
this
.
contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
e
.
anchor
,
getActions
:
()
=>
getRepositoryVisibilityActions
(
this
.
scmService
,
this
.
scmViewService
)
});
}
const
element
=
e
.
element
;
...
...
src/vs/workbench/contrib/scm/browser/scmViewService.ts
浏览文件 @
35359edc
...
...
@@ -111,6 +111,31 @@ export class SCMViewService implements ISCMViewService {
}
}
isVisible
(
repository
:
ISCMRepository
):
boolean
{
return
this
.
_visibleRepositoriesSet
.
has
(
repository
);
}
toggleVisibility
(
repository
:
ISCMRepository
,
visible
?:
boolean
):
void
{
if
(
typeof
visible
===
'
undefined
'
)
{
visible
=
!
this
.
isVisible
(
repository
);
}
else
if
(
this
.
isVisible
(
repository
)
===
visible
)
{
return
;
}
if
(
visible
)
{
this
.
visibleRepositories
=
[...
this
.
visibleRepositories
,
repository
];
}
else
{
const
index
=
this
.
visibleRepositories
.
indexOf
(
repository
);
if
(
index
>
-
1
)
{
this
.
visibleRepositories
=
[
...
this
.
visibleRepositories
.
slice
(
0
,
index
),
...
this
.
visibleRepositories
.
slice
(
index
+
1
)
];
}
}
}
dispose
():
void
{
this
.
disposables
.
dispose
();
this
.
_onDidChangeRepositories
.
dispose
();
...
...
src/vs/workbench/contrib/scm/browser/util.ts
浏览文件 @
35359edc
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ISCMResource
,
ISCMRepository
,
ISCMResourceGroup
,
ISCMInput
}
from
'
vs/workbench/contrib/scm/common/scm
'
;
import
{
ISCMResource
,
ISCMRepository
,
ISCMResourceGroup
,
ISCMInput
,
ISCMService
,
ISCMViewService
}
from
'
vs/workbench/contrib/scm/common/scm
'
;
import
{
IMenu
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IDisposable
,
Disposable
,
combinedDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
...
...
@@ -16,6 +16,8 @@ import { renderCodicons } from 'vs/base/common/codicons';
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
import
{
escape
}
from
'
vs/base/common/strings
'
;
import
{
basename
}
from
'
vs/base/common/resources
'
;
import
{
Iterable
}
from
'
vs/base/common/iterator
'
;
export
function
isSCMRepository
(
element
:
any
):
element
is
ISCMRepository
{
return
!!
(
element
as
ISCMRepository
).
provider
&&
typeof
(
element
as
ISCMRepository
).
setSelected
===
'
function
'
;
...
...
@@ -107,3 +109,26 @@ export class StatusBarActionViewItem extends ActionViewItem {
}
}
}
export
function
getRepositoryVisibilityActions
(
scmService
:
ISCMService
,
scmViewService
:
ISCMViewService
):
IAction
[]
{
const
visible
=
new
Set
<
IAction
>
();
const
actions
=
scmService
.
repositories
.
map
(
repository
=>
{
const
label
=
repository
.
provider
.
rootUri
?
basename
(
repository
.
provider
.
rootUri
)
:
repository
.
provider
.
label
;
const
action
=
new
Action
(
'
scm.repository.toggleVisibility
'
,
label
,
undefined
,
true
,
async
()
=>
{
scmViewService
.
toggleVisibility
(
repository
);
});
if
(
scmViewService
.
isVisible
(
repository
))
{
action
.
checked
=
true
;
visible
.
add
(
action
);
}
return
action
;
});
if
(
visible
.
size
===
1
)
{
Iterable
.
first
(
visible
.
values
())
!
.
enabled
=
false
;
}
return
actions
;
}
src/vs/workbench/contrib/scm/common/scm.ts
浏览文件 @
35359edc
...
...
@@ -148,6 +148,10 @@ export interface ISCMViewService {
readonly
_serviceBrand
:
undefined
;
readonly
menus
:
ISCMMenus
;
visibleRepositories
:
ISCMRepository
[];
readonly
onDidChangeVisibleRepositories
:
Event
<
ISCMViewVisibleRepositoryChangeEvent
>
;
isVisible
(
repository
:
ISCMRepository
):
boolean
;
toggleVisibility
(
repository
:
ISCMRepository
,
visible
?:
boolean
):
void
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录