2017-09-10 17:25:29 +05:30
|
|
|
<script>
|
2019-01-03 12:48:30 +05:30
|
|
|
import { GlLoadingIcon } from '@gitlab-org/gitlab-ui';
|
2018-11-08 19:23:39 +05:30
|
|
|
import ciHeader from '../../vue_shared/components/header_ci_component.vue';
|
|
|
|
import eventHub from '../event_hub';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
export default {
|
|
|
|
name: 'PipelineHeaderSection',
|
|
|
|
components: {
|
|
|
|
ciHeader,
|
2018-12-13 13:39:08 +05:30
|
|
|
GlLoadingIcon,
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
pipeline: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
isLoading: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
actions: this.getActions(),
|
|
|
|
};
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
computed: {
|
|
|
|
status() {
|
|
|
|
return this.pipeline.details && this.pipeline.details.status;
|
|
|
|
},
|
|
|
|
shouldRenderContent() {
|
|
|
|
return !this.isLoading && Object.keys(this.pipeline).length;
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
watch: {
|
|
|
|
pipeline() {
|
|
|
|
this.actions = this.getActions();
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
methods: {
|
|
|
|
postAction(action) {
|
|
|
|
const index = this.actions.indexOf(action);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
this.$set(this.actions[index], 'isLoading', true);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
eventHub.$emit('headerPostAction', action);
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
getActions() {
|
|
|
|
const actions = [];
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
if (this.pipeline.retry_path) {
|
|
|
|
actions.push({
|
|
|
|
label: 'Retry',
|
|
|
|
path: this.pipeline.retry_path,
|
|
|
|
cssClass: 'js-retry-button btn btn-inverted-secondary',
|
|
|
|
type: 'button',
|
|
|
|
isLoading: false,
|
|
|
|
});
|
|
|
|
}
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
if (this.pipeline.cancel_path) {
|
|
|
|
actions.push({
|
|
|
|
label: 'Cancel running',
|
|
|
|
path: this.pipeline.cancel_path,
|
|
|
|
cssClass: 'js-btn-cancel-pipeline btn btn-danger',
|
|
|
|
type: 'button',
|
|
|
|
isLoading: false,
|
|
|
|
});
|
|
|
|
}
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
return actions;
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
};
|
2017-09-10 17:25:29 +05:30
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div class="pipeline-header-container">
|
|
|
|
<ci-header
|
|
|
|
v-if="shouldRenderContent"
|
|
|
|
:status="status"
|
|
|
|
:item-id="pipeline.id"
|
|
|
|
:time="pipeline.created_at"
|
|
|
|
:user="pipeline.user"
|
|
|
|
:actions="actions"
|
2018-11-08 19:23:39 +05:30
|
|
|
item-name="Pipeline"
|
2017-09-10 17:25:29 +05:30
|
|
|
@actionClicked="postAction"
|
2018-03-17 18:26:18 +05:30
|
|
|
/>
|
2019-01-03 12:48:30 +05:30
|
|
|
<gl-loading-icon
|
|
|
|
v-if="isLoading"
|
|
|
|
:size="2"
|
|
|
|
class="prepend-top-default append-bottom-default"
|
|
|
|
/>
|
2017-09-10 17:25:29 +05:30
|
|
|
</div>
|
|
|
|
</template>
|