Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ab0bba9e
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,发现更多精彩内容 >>
提交
ab0bba9e
编写于
12月 10, 2015
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
drop react dependency from git status bar contribution
上级
4507346b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
87 addition
and
105 deletion
+87
-105
src/vs/workbench/browser/parts/statusbar/media/statusbarPart.css
...workbench/browser/parts/statusbar/media/statusbarPart.css
+6
-4
src/vs/workbench/parts/git/browser/gitWidgets.ts
src/vs/workbench/parts/git/browser/gitWidgets.ts
+81
-101
未找到文件。
src/vs/workbench/browser/parts/statusbar/media/statusbarPart.css
浏览文件 @
ab0bba9e
...
...
@@ -35,17 +35,19 @@
margin-left
:
5px
;
}
.monaco-workbench
>
.part.statusbar
>
.statusbar-item
a
{
.monaco-workbench
>
.part.statusbar
>
.statusbar-item
a
:not
([
disabled
])
{
cursor
:
pointer
;
display
:
inline-block
;
height
:
100%
;
}
.monaco-workbench
>
.part.statusbar
>
.statusbar-entry
>
span
{
cursor
:
default
;
height
:
100%
;
}
.monaco-workbench
>
.part.statusbar
>
.statusbar-entry
>
span
,
.monaco-workbench
>
.part.statusbar
>
.statusbar-entry
>
a
{
.monaco-workbench
>
.part.statusbar
>
.statusbar-entry
>
a
:not
([
disabled
])
{
padding
:
0
5px
0
5px
;
white-space
:
pre
;
/* gives some degree of styling */
}
...
...
@@ -55,13 +57,13 @@
font-size
:
14px
;
}
.monaco-workbench
>
.part.statusbar
>
.statusbar-item
a
:hover
{
.monaco-workbench
>
.part.statusbar
>
.statusbar-item
a
:hover
:not
([
disabled
])
{
background-color
:
rgba
(
255
,
255
,
255
,
0.12
);
text-decoration
:
none
;
color
:
inherit
;
}
.monaco-workbench
>
.part.statusbar
>
.statusbar-item
a
:active
{
.monaco-workbench
>
.part.statusbar
>
.statusbar-item
a
:active
:not
([
disabled
])
{
background-color
:
rgba
(
255
,
255
,
255
,
0.18
);
}
...
...
src/vs/workbench/parts/git/browser/gitWidgets.ts
浏览文件 @
ab0bba9e
...
...
@@ -2,137 +2,117 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
react
=
require
(
'
lib/react
'
);
import
objects
=
require
(
'
vs/base/common/objects
'
);
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
import
git
=
require
(
'
vs/workbench/parts/git/common/git
'
);
import
statusbar
=
require
(
'
vs/workbench/browser/parts/statusbar/statusbar
'
);
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/browser/quickOpenService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
IGitService
=
git
.
IGitService
;
interface
GitStatusbarWidgetProps
{
instantiationService
:
IInstantiationService
;
gitService
:
IGitService
;
quickOpenService
:
IQuickOpenService
;
}
interface
GitStatusbarWidgetState
{
serviceState
:
git
.
ServiceState
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
emmet
as
$
,
append
}
from
'
vs/base/browser/dom
'
;
import
{
IDisposable
,
combinedDispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IGitService
,
ServiceState
,
IBranch
,
ServiceOperations
}
from
'
vs/workbench/parts/git/common/git
'
;
import
{
IStatusbarItem
}
from
'
vs/workbench/browser/parts/statusbar/statusbar
'
;
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/browser/quickOpenService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
interface
IState
{
serviceState
:
ServiceState
;
isBusy
:
boolean
;
HEAD
:
git
.
IBranch
;
HEAD
:
IBranch
;
ps1
:
string
;
}
class
GitStatusbarWidgetSpec
extends
react
.
BaseComponent
<
GitStatusbarWidgetProps
,
GitStatusbarWidgetState
>
{
export
class
GitStatusbarItem
implements
IStatusbarItem
{
private
serviceListeners
:
lifecycle
.
IDisposable
[];
private
instantiationService
:
IInstantiationService
;
private
gitService
:
IGitService
;
private
quickOpenService
:
IQuickOpenService
;
private
state
:
IState
;
private
element
:
HTMLElement
;
private
toDispose
:
IDisposable
[];
public
componentDidMount
():
void
{
this
.
serviceListeners
=
[
this
.
props
.
gitService
.
addBulkListener2
(()
=>
this
.
onGitServiceChange
())
];
}
constructor
(
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IGitService
gitService
:
IGitService
,
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
)
{
this
.
instantiationService
=
instantiationService
;
this
.
gitService
=
gitService
;
this
.
quickOpenService
=
quickOpenService
;
this
.
toDispose
=
[];
public
getInitialState
():
GitStatusbarWidgetState
{
return
{
serviceState
:
git
.
ServiceState
.
NotInitialized
,
this
.
state
=
{
serviceState
:
ServiceState
.
NotInitialized
,
isBusy
:
false
,
HEAD
:
null
,
ps1
:
''
};
}
public
render
():
react
.
ReactHTMLElement
{
if
(
this
.
state
.
serviceState
!==
git
.
ServiceState
.
OK
)
{
return
react
.
createElement
(
'
span
'
,
{
className
:
'
git-statusbar-item disabled
'
,
title
:
nls
.
localize
(
'
gitNotEnabled
'
,
"
Git is not enabled in this workspace.
"
),
},
'
\
u00a0
'
);
public
render
(
container
:
HTMLElement
):
IDisposable
{
this
.
element
=
append
(
container
,
$
(
'
a
'
));
this
.
setState
(
this
.
state
);
this
.
toDispose
.
push
(
this
.
gitService
.
addBulkListener2
(()
=>
this
.
onGitServiceChange
()));
return
combinedDispose
(...
this
.
toDispose
);
}
private
onGitServiceChange
():
void
{
const
model
=
this
.
gitService
.
getModel
();
this
.
setState
({
serviceState
:
this
.
gitService
.
getState
(),
isBusy
:
this
.
gitService
.
getRunningOperations
().
some
(
op
=>
op
.
id
===
ServiceOperations
.
CHECKOUT
||
op
.
id
===
ServiceOperations
.
BRANCH
),
HEAD
:
model
.
getHEAD
(),
ps1
:
model
.
getPS1
()
});
}
var
HEAD
=
this
.
state
.
HEAD
;
var
className
=
'
git-statusbar-item
'
;
var
label
:
string
;
var
onClick
:
(
e
:
react
.
SyntheticEvent
)
=>
void
=
null
;
private
setState
(
state
:
IState
):
void
{
this
.
state
=
state
;
let
disabled
=
false
;
let
className
=
'
git-statusbar-item
'
;
let
textContent
:
string
;
let
title
=
''
;
let
onclick
:
()
=>
void
=
null
;
if
(
this
.
state
.
isBusy
)
{
if
(
state
.
serviceState
!==
ServiceState
.
OK
)
{
disabled
=
true
;
className
+=
'
disabled
'
;
title
=
nls
.
localize
(
'
gitNotEnabled
'
,
"
Git is not enabled in this workspace.
"
);
textContent
=
'
\
u00a0
'
;
}
else
{
const
HEAD
=
state
.
HEAD
;
if
(
state
.
isBusy
)
{
className
+=
'
busy
'
;
}
else
{
onClick
=
this
.
onClick
;
onclick
=
()
=>
this
.
onClick
()
;
}
if
(
!
HEAD
)
{
label
=
this
.
state
.
ps1
;
textContent
=
state
.
ps1
;
}
else
if
(
!
HEAD
.
name
)
{
label
=
this
.
state
.
ps1
;
textContent
=
state
.
ps1
;
className
+=
'
headless
'
;
}
else
if
(
!
HEAD
.
commit
||
!
HEAD
.
upstream
||
(
!
HEAD
.
ahead
&&
!
HEAD
.
behind
))
{
label
=
this
.
state
.
ps1
;
textContent
=
state
.
ps1
;
}
else
{
label
=
strings
.
format
(
'
{0} {1}↓ {2}↑
'
,
this
.
state
.
ps1
,
HEAD
.
behind
,
HEAD
.
ahead
);
}
return
react
.
createElement
(
'
a
'
,
{
className
:
className
,
onClick
:
onClick
},
label
);
textContent
=
strings
.
format
(
'
{0} {1}↓ {2}↑
'
,
state
.
ps1
,
HEAD
.
behind
,
HEAD
.
ahead
);
}
private
onGitServiceChange
():
void
{
var
service
=
this
.
props
.
gitService
;
var
model
=
service
.
getModel
();
this
.
updateState
({
serviceState
:
service
.
getState
(),
isBusy
:
service
.
getRunningOperations
().
some
(
op
=>
op
.
id
===
git
.
ServiceOperations
.
CHECKOUT
||
op
.
id
===
git
.
ServiceOperations
.
BRANCH
),
HEAD
:
model
.
getHEAD
(),
ps1
:
model
.
getPS1
()
});
}
private
updateState
(
update
:
any
,
callback
?:
()
=>
void
):
void
{
this
.
setState
(
objects
.
mixin
(
update
,
this
.
state
,
false
),
callback
);
}
this
.
element
.
className
=
className
;
this
.
element
.
title
=
title
;
this
.
element
.
textContent
=
textContent
;
this
.
element
.
onclick
=
onclick
;
private
onClick
(
e
:
react
.
SyntheticEvent
):
void
{
this
.
props
.
quickOpenService
.
show
(
'
git checkout
'
);
if
(
disabled
)
{
this
.
element
.
setAttribute
(
'
disabled
'
,
'
disabled
'
);
}
else
{
this
.
element
.
removeAttribute
(
'
disabled
'
);
}
}
var
GitStatusbarWidget
=
react
.
createFactoryForTS
<
GitStatusbarWidgetProps
>
(
GitStatusbarWidgetSpec
.
prototype
);
export
class
GitStatusbarItem
implements
statusbar
.
IStatusbarItem
{
private
instantiationService
:
IInstantiationService
;
private
gitService
:
IGitService
;
private
quickOpenService
:
IQuickOpenService
;
constructor
(
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IGitService
gitService
:
IGitService
,
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
)
{
this
.
instantiationService
=
instantiationService
;
this
.
gitService
=
gitService
;
this
.
quickOpenService
=
quickOpenService
;
}
public
render
(
container
:
HTMLElement
):
lifecycle
.
IDisposable
{
react
.
render
(
GitStatusbarWidget
({
instantiationService
:
this
.
instantiationService
,
gitService
:
this
.
gitService
,
quickOpenService
:
this
.
quickOpenService
}),
container
);
return
lifecycle
.
toDisposable
(()
=>
react
.
unmountComponentAtNode
(
container
));
private
onClick
():
void
{
this
.
quickOpenService
.
show
(
'
git checkout
'
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录