BigW Consortium Gitlab

Commit 20f74fe7 by Regis

make Vue render with null commit object - handle scope and page in different tabs

parent 813be933
...@@ -66,6 +66,8 @@ ...@@ -66,6 +66,8 @@
}, },
methods: { methods: {
changepage(e) { changepage(e) {
const scope = getParameterByName('scope');
if (scope) this.apiScope = scope;
const text = e.target.innerText; const text = e.target.innerText;
const { totalPages, nextPage, previousPage } = this.pageInfo; const { totalPages, nextPage, previousPage } = this.pageInfo;
if (text === SPREAD) return; if (text === SPREAD) return;
...@@ -74,14 +76,21 @@ ...@@ -74,14 +76,21 @@
if (text === NEXT) this.pagenum = nextPage; if (text === NEXT) this.pagenum = nextPage;
if (text === PREV) this.pagenum = previousPage; if (text === PREV) this.pagenum = previousPage;
if (text === FIRST) this.pagenum = 1; if (text === FIRST) this.pagenum = 1;
window.history.pushState({}, null, `?scope=${this.apiScope}&p=${this.pagenum}`);
window.history.pushState({}, null, `?p=${this.pagenum}`);
clearInterval(this.timeLoopInterval); clearInterval(this.timeLoopInterval);
this.pageRequest = true; this.pageRequest = true;
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope); this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
}, },
author(pipeline) { author(pipeline) {
const { commit } = pipeline; const { commit } = pipeline;
if (!commit) {
return ({
avatar_url: '',
web_url: '',
username: '',
});
}
const author = commit.author; const author = commit.author;
if (author) return author; if (author) return author;
...@@ -105,6 +114,21 @@ ...@@ -105,6 +114,21 @@
addTimeInterval(id, start) { addTimeInterval(id, start) {
this.allTimeIntervals.push({ id, start }); this.allTimeIntervals.push({ id, start });
}, },
commitTitle(pipeline) {
const { commit } = pipeline;
if (commit) return commit.title;
return '';
},
commitSha(pipeline) {
const { commit } = pipeline;
if (commit) return commit.short_id;
return '';
},
commitUrl(pipeline) {
const { commit } = pipeline;
if (commit) return commit.commit_url;
return '';
},
}, },
template: ` template: `
<div> <div>
...@@ -122,10 +146,10 @@ ...@@ -122,10 +146,10 @@
<commit <commit
:author='author(pipeline)' :author='author(pipeline)'
:tag="pipeline.ref['tag?']" :tag="pipeline.ref['tag?']"
:title='pipeline.commit.title' :title='commitTitle(pipeline)'
:commit_ref='ref(pipeline)' :commit_ref='ref(pipeline)'
:short_sha='pipeline.commit.short_id' :short_sha='commitSha(pipeline)'
:commit_url='pipeline.commit.commit_url' :commit_url='commitUrl(pipeline)'
> >
</commit> </commit>
</td> </td>
...@@ -143,7 +167,7 @@ ...@@ -143,7 +167,7 @@
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
</div> </div>
<gl-pagination <gl-pagination
v-if='pageInfo.total > 30' v-if='pageInfo.total > pageInfo.perPage'
:pagenum='pagenum' :pagenum='pagenum'
:changepage='changepage' :changepage='changepage'
:count='count.all' :count='count.all'
......
...@@ -25,22 +25,7 @@ describe "Pipelines", feature: true, js: true do ...@@ -25,22 +25,7 @@ describe "Pipelines", feature: true, js: true do
) )
end end
[:pipelines].each do |scope| [:all, :running, :branches].each do |scope|
context "displaying #{scope}" do
let(:project) { create(:project) }
before do
visit namespace_project_pipelines_path(project.namespace, project)
end
it do
wait_for_vue_resource
expect(page).to have_content(pipeline.short_sha)
end
end
end
[:running, :branches].each do |scope|
context "displaying #{scope}" do context "displaying #{scope}" do
let(:project) { create(:project) } let(:project) { create(:project) }
...@@ -51,7 +36,10 @@ describe "Pipelines", feature: true, js: true do ...@@ -51,7 +36,10 @@ describe "Pipelines", feature: true, js: true do
) )
end end
it { expect(page).to have_content(pipeline.short_sha) } it do
wait_for_vue_resource
expect(page).to have_content(pipeline.short_sha)
end
end end
end end
......
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