Commit e17f0e9e authored by Matija Čupić's avatar Matija Čupić

Add reset cache button to pipelines view

parent 1eb207f3
...@@ -17,6 +17,11 @@ export default { ...@@ -17,6 +17,11 @@ export default {
required: true, required: true,
}, },
resetCachePath: {
type: String,
required: true,
},
ciLintPath: { ciLintPath: {
type: String, type: String,
required: true, required: true,
...@@ -45,6 +50,11 @@ export default { ...@@ -45,6 +50,11 @@ export default {
Get started with Pipelines Get started with Pipelines
</a> </a>
<a :href="resetCachePath"
class="btn btn-default">
Clear runner caches
</a>
<a <a
:href="ciLintPath" :href="ciLintPath"
class="btn btn-default"> class="btn btn-default">
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
canCreatePipeline: pipelinesData.canCreatePipeline, canCreatePipeline: pipelinesData.canCreatePipeline,
hasCi: pipelinesData.hasCi, hasCi: pipelinesData.hasCi,
ciLintPath: pipelinesData.ciLintPath, ciLintPath: pipelinesData.ciLintPath,
resetCachePath: pipelinesData.resetCachePath,
state: this.store.state, state: this.store.state,
scope: getParameterByName('scope') || 'all', scope: getParameterByName('scope') || 'all',
page: getParameterByName('page') || '1', page: getParameterByName('page') || '1',
...@@ -220,6 +221,7 @@ ...@@ -220,6 +221,7 @@
:new-pipeline-path="newPipelinePath" :new-pipeline-path="newPipelinePath"
:has-ci-enabled="hasCiEnabled" :has-ci-enabled="hasCiEnabled"
:help-page-path="helpPagePath" :help-page-path="helpPagePath"
:resetCachePath="resetCachePath"
:ci-lint-path="ciLintPath" :ci-lint-path="ciLintPath"
:can-create-pipeline="canCreatePipelineParsed " :can-create-pipeline="canCreatePipelineParsed "
/> />
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
"new-pipeline-path" => new_project_pipeline_path(@project), "new-pipeline-path" => new_project_pipeline_path(@project),
"can-create-pipeline" => can?(current_user, :create_pipeline, @project).to_s, "can-create-pipeline" => can?(current_user, :create_pipeline, @project).to_s,
"has-ci" => @repository.gitlab_ci_yml, "has-ci" => @repository.gitlab_ci_yml,
"ci-lint-path" => ci_lint_path } } "ci-lint-path" => ci_lint_path,
"reset-cache-path" => reset_cache_project_path(@project) } }
= page_specific_javascript_bundle_tag('common_vue') = page_specific_javascript_bundle_tag('common_vue')
= page_specific_javascript_bundle_tag('pipelines') = page_specific_javascript_bundle_tag('pipelines')
...@@ -7,4 +7,6 @@ ...@@ -7,4 +7,6 @@
"new-pipeline-path" => 'foo', "new-pipeline-path" => 'foo',
"can-create-pipeline" => 'true', "can-create-pipeline" => 'true',
"has-ci" => 'foo', "has-ci" => 'foo',
"ci-lint-path" => 'foo' } } "ci-lint-path" => 'foo',
"reset-cache-path" => 'foo' } }
...@@ -14,6 +14,7 @@ describe('Pipelines Nav Controls', () => { ...@@ -14,6 +14,7 @@ describe('Pipelines Nav Controls', () => {
hasCiEnabled: true, hasCiEnabled: true,
helpPagePath: 'foo', helpPagePath: 'foo',
ciLintPath: 'foo', ciLintPath: 'foo',
resetCachePath: 'foo',
canCreatePipeline: true, canCreatePipeline: true,
}; };
...@@ -31,6 +32,7 @@ describe('Pipelines Nav Controls', () => { ...@@ -31,6 +32,7 @@ describe('Pipelines Nav Controls', () => {
hasCiEnabled: true, hasCiEnabled: true,
helpPagePath: 'foo', helpPagePath: 'foo',
ciLintPath: 'foo', ciLintPath: 'foo',
resetCachePath: 'foo',
canCreatePipeline: false, canCreatePipeline: false,
}; };
...@@ -41,12 +43,31 @@ describe('Pipelines Nav Controls', () => { ...@@ -41,12 +43,31 @@ describe('Pipelines Nav Controls', () => {
expect(component.$el.querySelector('.btn-create')).toEqual(null); expect(component.$el.querySelector('.btn-create')).toEqual(null);
}); });
it('should render link for resetting runner caches', () => {
const mockData = {
newPipelinePath: 'foo',
hasCiEnabled: true,
helpPagePath: 'foo',
ciLintPath: 'foo',
resetCachePath: 'foo',
canCreatePipeline: false,
};
const component = new NavControlsComponent({
propsData: mockData,
}).$mount();
expect(component.$el.querySelectorAll('.btn-default')[0].textContent).toContain('Reset runner caches');
expect(component.$el.querySelectorAll('.btn-default')[0].getAttribute('href')).toEqual(mockData.resetCachePath);
});
it('should render link for CI lint', () => { it('should render link for CI lint', () => {
const mockData = { const mockData = {
newPipelinePath: 'foo', newPipelinePath: 'foo',
hasCiEnabled: true, hasCiEnabled: true,
helpPagePath: 'foo', helpPagePath: 'foo',
ciLintPath: 'foo', ciLintPath: 'foo',
resetCachePath: 'foo',
canCreatePipeline: true, canCreatePipeline: true,
}; };
...@@ -54,8 +75,8 @@ describe('Pipelines Nav Controls', () => { ...@@ -54,8 +75,8 @@ describe('Pipelines Nav Controls', () => {
propsData: mockData, propsData: mockData,
}).$mount(); }).$mount();
expect(component.$el.querySelector('.btn-default').textContent).toContain('CI Lint'); expect(component.$el.querySelectorAll('.btn-default')[1].textContent).toContain('CI Lint');
expect(component.$el.querySelector('.btn-default').getAttribute('href')).toEqual(mockData.ciLintPath); expect(component.$el.querySelectorAll('.btn-default')[1].getAttribute('href')).toEqual(mockData.ciLintPath);
}); });
it('should render link to help page when CI is not enabled', () => { it('should render link to help page when CI is not enabled', () => {
...@@ -64,6 +85,7 @@ describe('Pipelines Nav Controls', () => { ...@@ -64,6 +85,7 @@ describe('Pipelines Nav Controls', () => {
hasCiEnabled: false, hasCiEnabled: false,
helpPagePath: 'foo', helpPagePath: 'foo',
ciLintPath: 'foo', ciLintPath: 'foo',
resetCachePath: 'foo',
canCreatePipeline: true, canCreatePipeline: true,
}; };
...@@ -81,6 +103,7 @@ describe('Pipelines Nav Controls', () => { ...@@ -81,6 +103,7 @@ describe('Pipelines Nav Controls', () => {
hasCiEnabled: true, hasCiEnabled: true,
helpPagePath: 'foo', helpPagePath: 'foo',
ciLintPath: 'foo', ciLintPath: 'foo',
resetCachePath: 'foo',
canCreatePipeline: true, canCreatePipeline: true,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment