Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
288dd155
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
288dd155
编写于
3月 11, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
outdated extensions in status bar
fixes #3540
上级
d6977fe1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
25 deletion
+64
-25
src/vs/workbench/parts/extensions/electron-browser/extensionsWidgets.ts
...ch/parts/extensions/electron-browser/extensionsWidgets.ts
+52
-25
src/vs/workbench/parts/extensions/electron-browser/media/extensions.css
...ch/parts/extensions/electron-browser/media/extensions.css
+12
-0
未找到文件。
src/vs/workbench/parts/extensions/electron-browser/extensionsWidgets.ts
浏览文件 @
288dd155
...
...
@@ -17,21 +17,26 @@ import { IMessageService, CloseAction } from 'vs/platform/message/common/message
import
{
UninstallAction
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionsActions
'
;
import
{
IExtensionsService
,
commandCategory
,
IExtension
,
IExtensionManifest
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/common/quickOpenService
'
;
import
{
getOutdatedExtensions
}
from
'
vs/workbench/parts/extensions/common/extensionsUtil
'
;
interface
IState
{
errors
:
IMessage
[];
installingExtensions
:
IExtensionManifest
[];
installing
:
IExtensionManifest
[];
outdated
:
IExtension
[];
}
const
InitialState
:
IState
=
{
errors
:
[],
installingExtensions
:
[]
installing
:
[],
outdated
:
[]
};
function
extensionEquals
(
one
:
IExtensionManifest
,
other
:
IExtensionManifest
):
boolean
{
return
one
.
publisher
===
other
.
publisher
&&
one
.
name
===
other
.
name
;
}
const
OutdatedPeriod
=
5
*
60
*
1000
;
// every 5 minutes
export
class
ExtensionsStatusbarItem
implements
statusbar
.
IStatusbarItem
{
private
domNode
:
HTMLElement
;
...
...
@@ -50,16 +55,8 @@ export class ExtensionsStatusbarItem implements statusbar.IStatusbarItem {
append
(
this
.
domNode
,
$
(
'
.icon
'
));
this
.
domNode
.
onclick
=
()
=>
this
.
onClick
();
const
promise
=
onUnexpectedPromiseError
(
this
.
extensionService
.
onReady
());
promise
.
done
(()
=>
{
const
status
=
this
.
extensionService
.
getExtensionsStatus
();
const
errors
=
Object
.
keys
(
status
)
.
map
(
k
=>
status
[
k
].
messages
)
.
reduce
((
r
,
m
)
=>
r
.
concat
(
m
),
[])
.
filter
(
m
=>
m
.
type
>
Severity
.
Info
);
this
.
updateState
({
errors
});
});
this
.
checkErrors
();
this
.
checkOutdated
();
const
disposables
=
[];
this
.
extensionsService
.
onInstallExtension
(
this
.
onInstallExtension
,
this
,
disposables
);
...
...
@@ -73,28 +70,36 @@ export class ExtensionsStatusbarItem implements statusbar.IStatusbarItem {
this
.
onStateChange
();
}
private
onStateChange
():
void
{
const
hasErrors
=
this
.
state
.
errors
.
length
>
0
;
const
isInstalling
=
this
.
state
.
installingExtensions
.
length
>
0
;
private
get
hasErrors
()
{
return
this
.
state
.
errors
.
length
>
0
;
}
private
get
isInstalling
()
{
return
this
.
state
.
installing
.
length
>
0
;
}
private
get
hasUpdates
()
{
return
this
.
state
.
outdated
.
length
>
0
;
}
toggleClass
(
this
.
domNode
,
'
has-errors
'
,
hasErrors
);
toggleClass
(
this
.
domNode
,
'
is-installing
'
,
!
hasErrors
&&
isInstalling
);
private
onStateChange
():
void
{
toggleClass
(
this
.
domNode
,
'
has-errors
'
,
this
.
hasErrors
);
toggleClass
(
this
.
domNode
,
'
is-installing
'
,
!
this
.
hasErrors
&&
this
.
isInstalling
);
toggleClass
(
this
.
domNode
,
'
has-updates
'
,
!
this
.
hasErrors
&&
!
this
.
isInstalling
&&
this
.
hasUpdates
);
if
(
hasErrors
)
{
if
(
this
.
hasErrors
)
{
const
singular
=
nls
.
localize
(
'
oneIssue
'
,
"
Extensions (1 issue)
"
);
const
plural
=
nls
.
localize
(
'
multipleIssues
'
,
"
Extensions ({0} issues)
"
,
this
.
state
.
errors
.
length
);
this
.
domNode
.
title
=
this
.
state
.
errors
.
length
>
1
?
plural
:
singular
;
}
else
if
(
isInstalling
)
{
this
.
domNode
.
title
=
nls
.
localize
(
'
extensionsInstalling
'
,
"
Extensions ({0} installing...)
"
,
this
.
state
.
installingExtensions
.
length
);
}
else
if
(
this
.
isInstalling
)
{
this
.
domNode
.
title
=
nls
.
localize
(
'
extensionsInstalling
'
,
"
Extensions ({0} installing...)
"
,
this
.
state
.
installing
.
length
);
}
else
if
(
this
.
hasUpdates
)
{
const
singular
=
nls
.
localize
(
'
oneUpdate
'
,
"
Extensions (1 update available)
"
);
const
plural
=
nls
.
localize
(
'
multipleUpdates
'
,
"
Extensions ({0} updates available)
"
,
this
.
state
.
outdated
.
length
);
this
.
domNode
.
title
=
this
.
state
.
outdated
.
length
>
1
?
plural
:
singular
;
}
else
{
this
.
domNode
.
title
=
nls
.
localize
(
'
extensions
'
,
"
Extensions
"
);
}
}
private
onClick
():
void
{
if
(
this
.
state
.
errors
.
length
>
0
)
{
if
(
this
.
hasErrors
)
{
this
.
showErrors
(
this
.
state
.
errors
);
this
.
updateState
({
errors
:
[]
});
}
else
if
(
this
.
hasUpdates
)
{
this
.
quickOpenService
.
show
(
`ext update `
);
}
else
{
this
.
quickOpenService
.
show
(
`>
${
commandCategory
}
: `
);
}
...
...
@@ -120,13 +125,35 @@ export class ExtensionsStatusbarItem implements statusbar.IStatusbarItem {
}
private
onInstallExtension
(
manifest
:
IExtensionManifest
):
void
{
const
installing
Extensions
=
[...
this
.
state
.
installingExtensions
,
manifest
];
this
.
updateState
({
installing
Extensions
});
const
installing
=
[...
this
.
state
.
installing
,
manifest
];
this
.
updateState
({
installing
});
}
private
onDidInstallExtension
({
extension
}:
{
extension
:
IExtension
;
}):
void
{
const
installing
Extensions
=
this
.
state
.
installingExtensions
const
installing
=
this
.
state
.
installing
.
filter
(
e
=>
!
extensionEquals
(
extension
,
e
));
this
.
updateState
({
installingExtensions
});
this
.
updateState
({
installing
});
}
private
checkErrors
():
void
{
const
promise
=
onUnexpectedPromiseError
(
this
.
extensionService
.
onReady
());
promise
.
done
(()
=>
{
const
status
=
this
.
extensionService
.
getExtensionsStatus
();
const
errors
=
Object
.
keys
(
status
)
.
map
(
k
=>
status
[
k
].
messages
)
.
reduce
((
r
,
m
)
=>
r
.
concat
(
m
),
[])
.
filter
(
m
=>
m
.
type
>
Severity
.
Info
);
this
.
updateState
({
errors
});
});
}
private
checkOutdated
():
void
{
this
.
instantiationService
.
invokeFunction
(
getOutdatedExtensions
)
.
then
(
null
,
_
=>
[])
// ignore errors
.
done
(
outdated
=>
{
this
.
updateState
({
outdated
});
setTimeout
(()
=>
this
.
checkOutdated
,
OutdatedPeriod
);
});
}
}
\ No newline at end of file
src/vs/workbench/parts/extensions/electron-browser/media/extensions.css
浏览文件 @
288dd155
...
...
@@ -147,6 +147,18 @@
height
:
100%
;
}
.monaco-shell
.extensions-statusbar.has-updates
::after
{
content
:
''
;
width
:
6px
;
height
:
6px
;
background-color
:
#39A71E
;
position
:
absolute
;
top
:
2px
;
right
:
3px
;
border-radius
:
10px
;
border
:
1px
solid
white
;
}
.monaco-shell
.extensions-statusbar.has-errors
::after
{
content
:
''
;
width
:
6px
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录