Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
凌波微步_大先生
dashboard
提交
c8dcaaca
D
dashboard
项目概览
凌波微步_大先生
/
dashboard
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dashboard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c8dcaaca
编写于
3月 07, 2016
作者:
U
urcan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flickering replicationcontroller list view fixed
上级
fae58c60
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
22 deletion
+28
-22
src/app/frontend/replicationcontrollerlist/replicationcontrollerlist_stateconfig.js
...oncontrollerlist/replicationcontrollerlist_stateconfig.js
+3
-9
src/test/frontend/replicationcontrollerlist/replicationcontrollerlist_stateconfig_test.js
...trollerlist/replicationcontrollerlist_stateconfig_test.js
+25
-13
未找到文件。
src/app/frontend/replicationcontrollerlist/replicationcontrollerlist_stateconfig.js
浏览文件 @
c8dcaaca
...
...
@@ -56,11 +56,10 @@ export default function stateConfig($stateProvider) {
* deleted.
* Transition to: zerostate
* @param {!ui.router.$state} $state
* @param {!angular.$timeout} $timeout
* @param {!backendApi.ReplicationControllerList} replicationControllers
* @ngInject
*/
export
function
redirectIfNeeded
(
$state
,
$timeout
,
replicationControllers
)
{
export
function
redirectIfNeeded
(
$state
,
replicationControllers
)
{
/** @type {boolean} */
let
isEmpty
=
replicationControllers
.
replicationControllers
.
length
===
0
;
// should only display RC list if RCs exist that are not in the kube-system namespace,
...
...
@@ -71,12 +70,8 @@ export function redirectIfNeeded($state, $timeout, replicationControllers) {
});
if
(
isEmpty
||
containsOnlyKubeSystemRCs
)
{
// allow original state change to finish before redirecting to new state to avoid error
$timeout
(()
=>
{
let
stateParams
=
new
StateParams
(
containsOnlyKubeSystemRCs
);
$state
.
go
(
zerostate
,
stateParams
);
});
let
stateParams
=
new
StateParams
(
containsOnlyKubeSystemRCs
);
$state
.
transition
.
then
(()
=>
{
$state
.
go
(
zerostate
,
stateParams
);
});
}
}
...
...
@@ -88,6 +83,5 @@ export function redirectIfNeeded($state, $timeout, replicationControllers) {
function
resolveReplicationControllers
(
$resource
)
{
/** @type {!angular.Resource<!backendApi.ReplicationControllerList>} */
let
resource
=
$resource
(
'
api/v1/replicationcontrollers
'
);
return
resource
.
get
().
$promise
;
}
src/test/frontend/replicationcontrollerlist/replicationcontrollerlist_stateconfig_test.js
浏览文件 @
c8dcaaca
...
...
@@ -14,19 +14,20 @@
import
replicationControllerListModule
from
'
replicationcontrollerlist/replicationcontrollerlist_module
'
;
import
{
redirectIfNeeded
}
from
'
replicationcontrollerlist/replicationcontrollerlist_stateconfig
'
;
describe
(
'
StateConfig for replication controller list
'
,
()
=>
{
/** @type {!ui.router.$state} */
let
state
;
/** @type {!angular.$timeout} */
let
timeout
;
let
deferred
;
let
$rootScope
;
beforeEach
(()
=>
{
angular
.
mock
.
module
(
replicationControllerListModule
.
name
);
angular
.
mock
.
inject
((
$state
,
$timeout
)
=>
{
angular
.
mock
.
inject
((
$state
,
$q
,
_$rootScope_
)
=>
{
state
=
$state
;
timeout
=
$timeout
;
$rootScope
=
_$rootScope_
;
deferred
=
$q
.
defer
();
});
state
.
transition
=
deferred
.
promise
;
});
it
(
'
should redirect to zerostate when RCs exist only in namespace kube-system
'
,
()
=>
{
...
...
@@ -39,9 +40,8 @@ describe('StateConfig for replication controller list', () => {
};
// when
redirectIfNeeded
(
state
,
timeout
,
replicationControllers
);
timeout
.
flush
();
redirectIfNeeded
(
state
,
replicationControllers
);
resolveStateTransitionPromise
();
// then
expect
(
state
.
go
).
toHaveBeenCalled
();
});
...
...
@@ -52,8 +52,8 @@ describe('StateConfig for replication controller list', () => {
let
replicationControllers
=
{
replicationControllers
:
[]};
// when
redirectIfNeeded
(
state
,
timeout
,
replicationControllers
);
timeout
.
flush
();
redirectIfNeeded
(
state
,
replicationControllers
);
resolveStateTransitionPromise
();
// then
expect
(
state
.
go
).
toHaveBeenCalled
();
...
...
@@ -70,7 +70,8 @@ describe('StateConfig for replication controller list', () => {
};
// when
redirectIfNeeded
(
state
,
timeout
,
replicationControllers
);
redirectIfNeeded
(
state
,
replicationControllers
);
resolveStateTransitionPromise
();
// then
expect
(
state
.
go
).
not
.
toHaveBeenCalled
();
...
...
@@ -88,9 +89,20 @@ describe('StateConfig for replication controller list', () => {
};
// when
redirectIfNeeded
(
state
,
timeout
,
replicationControllers
);
redirectIfNeeded
(
state
,
replicationControllers
);
resolveStateTransitionPromise
();
// then
expect
(
state
.
go
).
not
.
toHaveBeenCalled
();
});
/**
* Resolves the mocked state transition promise
*
* @export
*/
function
resolveStateTransitionPromise
()
{
deferred
.
resolve
();
$rootScope
.
$apply
();
}
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录