debian-mirror-gitlab/app/assets/javascripts/pipelines/components/pipelines_table.vue

134 lines
3 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2018-11-08 19:23:39 +05:30
import Modal from '~/vue_shared/components/gl_modal.vue';
import { s__, sprintf } from '~/locale';
import PipelinesTableRowComponent from './pipelines_table_row.vue';
import eventHub from '../event_hub';
2017-09-10 17:25:29 +05:30
2018-11-08 19:23:39 +05:30
/**
* Pipelines Table Component.
*
* Given an array of objects, renders a table.
*/
export default {
components: {
PipelinesTableRowComponent,
Modal,
},
props: {
pipelines: {
type: Array,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
updateGraphDropdown: {
type: Boolean,
required: false,
default: false,
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
autoDevopsHelpPath: {
type: String,
required: true,
2018-03-27 19:54:05 +05:30
},
2018-11-08 19:23:39 +05:30
viewType: {
type: String,
required: true,
2018-03-27 19:54:05 +05:30
},
2018-11-08 19:23:39 +05:30
},
data() {
return {
2018-12-13 13:39:08 +05:30
pipelineId: 0,
2018-11-08 19:23:39 +05:30
endpoint: '',
cancelingPipeline: null,
};
},
computed: {
modalTitle() {
return sprintf(
s__('Pipeline|Stop pipeline #%{pipelineId}?'),
{
pipelineId: `${this.pipelineId}`,
},
false,
);
2018-03-27 19:54:05 +05:30
},
2018-11-08 19:23:39 +05:30
modalText() {
return sprintf(
s__('Pipeline|Youre about to stop pipeline %{pipelineId}.'),
{
pipelineId: `<strong>#${this.pipelineId}</strong>`,
},
false,
);
2018-03-27 19:54:05 +05:30
},
2018-11-08 19:23:39 +05:30
},
created() {
eventHub.$on('openConfirmationModal', this.setModalData);
},
beforeDestroy() {
eventHub.$off('openConfirmationModal', this.setModalData);
},
methods: {
setModalData(data) {
this.pipelineId = data.pipelineId;
this.endpoint = data.endpoint;
2018-03-27 19:54:05 +05:30
},
2018-11-08 19:23:39 +05:30
onSubmit() {
eventHub.$emit('postAction', this.endpoint);
this.cancelingPipeline = this.pipelineId;
},
},
};
2017-09-10 17:25:29 +05:30
</script>
<template>
<div class="ci-table">
<div
class="gl-responsive-table-row table-row-header"
2018-03-17 18:26:18 +05:30
role="row"
>
2017-09-10 17:25:29 +05:30
<div
class="table-section section-10 js-pipeline-status pipeline-status"
2018-03-17 18:26:18 +05:30
role="rowheader"
>
2018-12-13 13:39:08 +05:30
{{ s__('Pipeline|Status') }}
2017-09-10 17:25:29 +05:30
</div>
<div
class="table-section section-15 js-pipeline-info pipeline-info"
2018-03-17 18:26:18 +05:30
role="rowheader"
>
2018-12-13 13:39:08 +05:30
{{ s__('Pipeline|Pipeline') }}
2017-09-10 17:25:29 +05:30
</div>
<div
2018-03-17 18:26:18 +05:30
class="table-section section-20 js-pipeline-commit pipeline-commit"
role="rowheader"
>
2018-12-13 13:39:08 +05:30
{{ s__('Pipeline|Commit') }}
2017-09-10 17:25:29 +05:30
</div>
<div
2018-03-17 18:26:18 +05:30
class="table-section section-20 js-pipeline-stages pipeline-stages"
role="rowheader"
>
2018-12-13 13:39:08 +05:30
{{ s__('Pipeline|Stages') }}
2017-09-10 17:25:29 +05:30
</div>
</div>
<pipelines-table-row-component
v-for="model in pipelines"
:key="model.id"
:pipeline="model"
:update-graph-dropdown="updateGraphDropdown"
2018-03-17 18:26:18 +05:30
:auto-devops-help-path="autoDevopsHelpPath"
:view-type="viewType"
2018-11-08 19:23:39 +05:30
:canceling-pipeline="cancelingPipeline"
2017-09-10 17:25:29 +05:30
/>
2018-11-08 19:23:39 +05:30
<modal
2018-03-27 19:54:05 +05:30
id="confirmation-modal"
2018-11-08 19:23:39 +05:30
:header-title-text="modalTitle"
:footer-primary-button-text="s__('Pipeline|Stop pipeline')"
footer-primary-button-variant="danger"
2018-03-27 19:54:05 +05:30
@submit="onSubmit"
>
2018-11-08 19:23:39 +05:30
<span v-html="modalText"></span>
</modal>
2017-09-10 17:25:29 +05:30
</div>
</template>