gitlab-org--gitlab-foss/app/assets/javascripts/vue_pipelines_index/pipelines.js.es6

126 lines
4.1 KiB
JavaScript
Raw Normal View History

2016-10-26 14:43:58 -04:00
/* global Vue, gl */
/* eslint-disable no-param-reassign, no-bitwise*/
2016-10-26 14:43:58 -04:00
((gl) => {
2016-11-18 17:26:49 -05:00
gl.VuePipelines = Vue.extend({
components: {
2016-11-11 00:21:09 -05:00
runningPipeline: gl.VueRunningPipeline,
pipelineActions: gl.VuePipelineActions,
stages: gl.VueStages,
2016-11-22 14:36:45 -05:00
commit: gl.CommitComponent,
2016-11-11 00:21:09 -05:00
pipelineUrl: gl.VuePipelineUrl,
pipelineHead: gl.VuePipelineHead,
glPagination: gl.VueGlPagination,
statusScope: gl.VueStatusScope,
timeAgo: gl.VueTimeAgo,
},
2016-10-29 15:50:08 -04:00
data() {
return {
pipelines: [],
timeLoopInterval: '',
intervalId: '',
apiScope: 'all',
2016-12-07 15:35:26 -05:00
pageInfo: {},
2016-12-07 17:20:30 -05:00
pagenum: 1,
count: { all: 0, running_or_pending: 0 },
2016-11-11 00:21:09 -05:00
pageRequest: false,
2016-10-29 15:50:08 -04:00
};
},
2016-12-12 14:11:28 -05:00
props: ['scope', 'store', 'svgs'],
created() {
2016-12-08 19:41:59 -05:00
const pagenum = gl.getParameterByName('p');
const scope = gl.getParameterByName('scope');
if (pagenum) this.pagenum = pagenum;
if (scope) this.apiScope = scope;
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
},
methods: {
change(pagenum, apiScope) {
window.history.pushState({}, null, `?scope=${apiScope}&p=${pagenum}`);
clearInterval(this.timeLoopInterval);
2016-11-11 00:21:09 -05:00
this.pageRequest = true;
this.store.fetchDataLoop.call(this, Vue, pagenum, this.scope, apiScope);
},
2016-11-22 14:36:45 -05:00
author(pipeline) {
if (!pipeline.commit) return ({ avatar_url: '', web_url: '', username: '' });
if (pipeline.commit.author) return pipeline.commit.author;
return ({
avatar_url: pipeline.commit.author_gravatar_url,
web_url: `mailto:${pipeline.commit.author_email}`,
username: pipeline.commit.author_name,
});
2016-11-22 14:36:45 -05:00
},
ref(pipeline) {
const { ref } = pipeline;
return ({ name: ref.name, tag: ref['tag?'], ref_url: ref.url });
},
commitTitle(pipeline) {
return pipeline.commit ? pipeline.commit.title : '';
},
commitSha(pipeline) {
return pipeline.commit ? pipeline.commit.short_id : '';
},
commitUrl(pipeline) {
return pipeline.commit ? pipeline.commit.commit_url : '';
},
2016-12-13 11:54:18 -05:00
match(string) {
return string.replace(/_([a-z])/g, (m, w) => w.toUpperCase());
},
},
template: `
<div>
2016-12-01 17:02:26 -05:00
<div class="pipelines realtime-loading" v-if='pipelines.length < 1'>
2016-11-11 00:21:09 -05:00
<i class="fa fa-spinner fa-spin"></i>
</div>
<div class="table-holder" v-if='pipelines.length > 0'>
<table class="table ci-table">
<pipeline-head></pipeline-head>
<tbody>
<tr class="commit" v-for='pipeline in pipelines'>
2016-12-13 11:54:18 -05:00
<status-scope
:pipeline='pipeline'
:match='match'
:svgs='svgs'
>
</status-scope>
<pipeline-url :pipeline='pipeline'></pipeline-url>
<td>
<commit
2016-12-12 14:11:28 -05:00
:commit-icon-svg='svgs.commitIconSvg'
:author='author(pipeline)'
:tag="pipeline.ref['tag?']"
:title='commitTitle(pipeline)'
2016-12-12 14:11:28 -05:00
:commit-ref='ref(pipeline)'
:short-sha='commitSha(pipeline)'
:commit-url='commitUrl(pipeline)'
>
</commit>
</td>
2016-12-13 11:54:18 -05:00
<stages
:pipeline='pipeline'
:svgs='svgs'
:match='match'
>
</stages>
<time-ago :pipeline='pipeline'></time-ago>
<pipeline-actions :pipeline='pipeline'></pipeline-actions>
</tr>
</tbody>
</table>
</div>
2016-12-01 17:02:26 -05:00
<div class="pipelines realtime-loading" v-if='pageRequest'>
2016-11-11 00:21:09 -05:00
<i class="fa fa-spinner fa-spin"></i>
</div>
<gl-pagination
v-if='pageInfo.total > pageInfo.perPage'
:pagenum='pagenum'
:change='change'
:count='count.all'
2016-12-07 15:35:26 -05:00
:pageInfo='pageInfo'
>
</gl-pagination>
2016-11-01 20:16:51 -04:00
</div>
`,
2016-10-26 14:43:58 -04:00
});
})(window.gl || (window.gl = {}));