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

132 lines
4.3 KiB
JavaScript
Raw Normal View History

/* global Vue, Turbolinks, gl */
/* eslint-disable no-param-reassign */
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() {
const pagenum = gl.utils.getParameterByName('p');
const scope = gl.utils.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) {
Turbolinks.visit(`?scope=${apiScope}&p=${pagenum}`);
},
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.path };
},
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_path : '';
},
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'>
<table class="table ci-table">
<thead>
<tr>
<th class="pipeline-status">Status</th>
<th class="pipeline-info">Pipeline</th>
<th class="pipeline-commit">Commit</th>
<th class="pipeline-stages">Stages</th>
<th class="pipeline-date"></th>
<th class="pipeline-actions hidden-xs"></th>
</tr>
</thead>
<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>
2016-12-16 18:12:52 -05:00
<time-ago :pipeline='pipeline' :svgs='svgs'></time-ago>
<pipeline-actions :pipeline='pipeline' :svgs='svgs'></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 = {}));