Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b9f9e6fa
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b9f9e6fa
编写于
3月 07, 2018
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removes UJS from reset cache button
Uses loading button for better UX
上级
2b8e9add
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
73 addition
and
26 deletion
+73
-26
app/assets/javascripts/pipelines/components/nav_controls.vue
app/assets/javascripts/pipelines/components/nav_controls.vue
+21
-6
app/assets/javascripts/pipelines/components/pipelines.vue
app/assets/javascripts/pipelines/components/pipelines.vue
+21
-0
app/assets/javascripts/pipelines/mixins/pipelines.js
app/assets/javascripts/pipelines/mixins/pipelines.js
+2
-4
spec/features/projects/pipelines/pipelines_spec.rb
spec/features/projects/pipelines/pipelines_spec.rb
+5
-3
spec/javascripts/pipelines/nav_controls_spec.js
spec/javascripts/pipelines/nav_controls_spec.js
+24
-13
未找到文件。
app/assets/javascripts/pipelines/components/nav_controls.vue
浏览文件 @
b9f9e6fa
<
script
>
import
LoadingButton
from
'
../../vue_shared/components/loading_button.vue
'
;
export
default
{
name
:
'
PipelineNavControls
'
,
components
:
{
LoadingButton
,
},
props
:
{
newPipelinePath
:
{
type
:
String
,
...
...
@@ -19,6 +24,17 @@
required
:
false
,
default
:
null
,
},
isResetCacheButtonLoading
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
methods
:
{
onClickResetCache
()
{
this
.
$emit
(
'
resetRunnersCache
'
,
this
.
resetCachePath
);
},
},
};
</
script
>
...
...
@@ -32,14 +48,13 @@
{{
s__
(
'
Pipelines|Run Pipeline
'
)
}}
</a>
<
a
<
loading-button
v-if=
"resetCachePath"
data-method=
"post
"
:
href=
"resetCachePath
"
@
click=
"onClickResetCache
"
:
loading=
"isResetCacheButtonLoading
"
class=
"btn btn-default js-clear-cache"
>
{{
s__
(
'
Pipelines|Clear Runner Caches
'
)
}}
</a>
:label=
"s__('Pipelines|Clear Runner Caches')"
/>
<a
v-if=
"ciLintPath"
...
...
app/assets/javascripts/pipelines/components/pipelines.vue
浏览文件 @
b9f9e6fa
<
script
>
import
_
from
'
underscore
'
;
import
{
__
,
sprintf
,
s__
}
from
'
../../locale
'
;
import
createFlash
from
'
../../flash
'
;
import
PipelinesService
from
'
../services/pipelines_service
'
;
import
pipelinesMixin
from
'
../mixins/pipelines
'
;
import
TablePagination
from
'
../../vue_shared/components/table_pagination.vue
'
;
...
...
@@ -92,6 +93,7 @@
scope
:
getParameterByName
(
'
scope
'
)
||
'
all
'
,
page
:
getParameterByName
(
'
page
'
)
||
'
1
'
,
requestData
:
{},
isResetCacheButtonLoading
:
false
,
};
},
stateMap
:
{
...
...
@@ -265,6 +267,23 @@
this
.
poll
.
restart
({
data
:
this
.
requestData
});
});
},
handleResetRunnersCache
(
endpoint
)
{
this
.
isResetCacheButtonLoading
=
true
;
this
.
service
.
postAction
(
endpoint
)
.
then
(()
=>
{
this
.
isResetCacheButtonLoading
=
false
;
createFlash
(
s__
(
'
Pipelines|Project cache successfully reset.
'
),
'
notice
'
,
);
})
.
catch
(()
=>
{
this
.
isResetCacheButtonLoading
=
false
;
createFlash
(
s__
(
'
Pipelines|Something went wrong while cleaning runners cache.
'
));
});
},
},
};
</
script
>
...
...
@@ -301,6 +320,8 @@
:new-pipeline-path=
"newPipelinePath"
:reset-cache-path=
"resetCachePath"
:ci-lint-path=
"ciLintPath"
@
resetRunnersCache=
"handleResetRunnersCache"
:is-reset-cache-button-loading=
"isResetCacheButtonLoading"
/>
</div>
...
...
app/assets/javascripts/pipelines/mixins/pipelines.js
浏览文件 @
b9f9e6fa
...
...
@@ -51,12 +51,10 @@ export default {
}
});
eventHub
.
$on
(
'
refreshPipelines
'
,
this
.
fetchPipelines
);
eventHub
.
$on
(
'
postAction
'
,
this
.
postAction
);
},
beforeDestroy
()
{
eventHub
.
$off
(
'
refreshPipelines
'
);
eventHub
.
$on
(
'
postAction
'
,
this
.
postAction
);
eventHub
.
$off
(
'
postAction
'
,
this
.
postAction
);
},
destroyed
()
{
this
.
poll
.
stop
();
...
...
@@ -92,7 +90,7 @@ export default {
},
postAction
(
endpoint
)
{
this
.
service
.
postAction
(
endpoint
)
.
then
(()
=>
eventHub
.
$emit
(
'
refreshPipelines
'
))
.
then
(()
=>
this
.
fetchPipelines
(
))
.
catch
(()
=>
Flash
(
__
(
'
An error occurred while making the request.
'
)));
},
},
...
...
spec/features/projects/pipelines/pipelines_spec.rb
浏览文件 @
b9f9e6fa
...
...
@@ -557,7 +557,7 @@ describe 'Pipelines', :js do
end
it
'has a clear caches button'
do
expect
(
page
).
to
have_
link
'Clear Runner Caches'
expect
(
page
).
to
have_
button
'Clear Runner Caches'
end
describe
'user clicks the button'
do
...
...
@@ -567,14 +567,16 @@ describe 'Pipelines', :js do
end
it
'increments jobs_cache_index'
do
click_link
'Clear Runner Caches'
click_button
'Clear Runner Caches'
wait_for_requests
expect
(
page
.
find
(
'.flash-notice'
)).
to
have_content
'Project cache successfully reset.'
end
end
context
'when project does not have jobs_cache_index'
do
it
'sets jobs_cache_index to 1'
do
click_link
'Clear Runner Caches'
click_button
'Clear Runner Caches'
wait_for_requests
expect
(
page
.
find
(
'.flash-notice'
)).
to
have_content
'Project cache successfully reset.'
end
end
...
...
spec/javascripts/pipelines/nav_controls_spec.js
浏览文件 @
b9f9e6fa
...
...
@@ -39,19 +39,6 @@ describe('Pipelines Nav Controls', () => {
expect
(
component
.
$el
.
querySelector
(
'
.js-run-pipeline
'
)).
toEqual
(
null
);
});
it
(
'
should render link for resetting runner caches
'
,
()
=>
{
const
mockData
=
{
newPipelinePath
:
'
foo
'
,
ciLintPath
:
'
foo
'
,
resetCachePath
:
'
foo
'
,
};
component
=
mountComponent
(
NavControlsComponent
,
mockData
);
expect
(
component
.
$el
.
querySelector
(
'
.js-clear-cache
'
).
textContent
.
trim
()).
toContain
(
'
Clear Runner Caches
'
);
expect
(
component
.
$el
.
querySelector
(
'
.js-clear-cache
'
).
getAttribute
(
'
href
'
)).
toEqual
(
mockData
.
resetCachePath
);
});
it
(
'
should render link for CI lint
'
,
()
=>
{
const
mockData
=
{
newPipelinePath
:
'
foo
'
,
...
...
@@ -65,4 +52,28 @@ describe('Pipelines Nav Controls', () => {
expect
(
component
.
$el
.
querySelector
(
'
.js-ci-lint
'
).
textContent
.
trim
()).
toContain
(
'
CI Lint
'
);
expect
(
component
.
$el
.
querySelector
(
'
.js-ci-lint
'
).
getAttribute
(
'
href
'
)).
toEqual
(
mockData
.
ciLintPath
);
});
describe
(
'
Reset Runners Cache
'
,
()
=>
{
beforeEach
(()
=>
{
const
mockData
=
{
newPipelinePath
:
'
foo
'
,
ciLintPath
:
'
foo
'
,
resetCachePath
:
'
foo
'
,
};
component
=
mountComponent
(
NavControlsComponent
,
mockData
);
});
it
(
'
should render button for resetting runner caches
'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-clear-cache
'
).
textContent
.
trim
()).
toContain
(
'
Clear Runner Caches
'
);
});
it
(
'
should emit postAction event when reset runner cache button is clicked
'
,
()
=>
{
spyOn
(
component
,
'
$on
'
);
component
.
$el
.
querySelector
(
'
.js-clear-cache
'
).
click
();
expect
(
component
.
$on
).
toHaveBeenCalledWith
(
'
postAction
'
,
'
foo
'
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录