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

133 lines
3.2 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2020-10-24 23:57:45 +05:30
import { GlLoadingIcon, GlModal, GlModalDirective, GlButton } from '@gitlab/ui';
2020-03-13 15:44:24 +05:30
import ciHeader from '~/vue_shared/components/header_ci_component.vue';
2018-11-08 19:23:39 +05:30
import eventHub from '../event_hub';
2019-09-30 21:07:59 +05:30
import { __ } from '~/locale';
2017-09-10 17:25:29 +05:30
2020-03-13 15:44:24 +05:30
const DELETE_MODAL_ID = 'pipeline-delete-modal';
2018-11-08 19:23:39 +05:30
export default {
name: 'PipelineHeaderSection',
components: {
ciHeader,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2020-03-13 15:44:24 +05:30
GlModal,
2020-10-24 23:57:45 +05:30
GlButton,
2020-03-13 15:44:24 +05:30
},
directives: {
GlModal: GlModalDirective,
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 {
2020-03-13 15:44:24 +05:30
isCanceling: false,
isRetrying: false,
isDeleting: false,
2018-11-08 19:23:39 +05:30
};
},
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
},
2020-03-13 15:44:24 +05:30
deleteModalConfirmationText() {
return __(
'Are you sure you want to delete this pipeline? Doing so will expire all pipeline caches and delete all related objects, such as builds, logs, artifacts, and triggers. This action cannot be undone.',
);
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: {
2020-03-13 15:44:24 +05:30
cancelPipeline() {
this.isCanceling = true;
eventHub.$emit('headerPostAction', this.pipeline.cancel_path);
2018-11-08 19:23:39 +05:30
},
2020-03-13 15:44:24 +05:30
retryPipeline() {
this.isRetrying = true;
eventHub.$emit('headerPostAction', this.pipeline.retry_path);
},
deletePipeline() {
this.isDeleting = true;
eventHub.$emit('headerDeleteAction', this.pipeline.delete_path);
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
},
2020-03-13 15:44:24 +05:30
DELETE_MODAL_ID,
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"
2018-11-08 19:23:39 +05:30
item-name="Pipeline"
2020-03-13 15:44:24 +05:30
>
2020-10-24 23:57:45 +05:30
<gl-button
2020-03-13 15:44:24 +05:30
v-if="pipeline.retry_path"
:loading="isRetrying"
:disabled="isRetrying"
2020-10-24 23:57:45 +05:30
data-testid="retryButton"
category="secondary"
variant="info"
2020-03-13 15:44:24 +05:30
@click="retryPipeline()"
2020-10-24 23:57:45 +05:30
>
{{ __('Retry') }}
</gl-button>
2020-03-13 15:44:24 +05:30
2020-10-24 23:57:45 +05:30
<gl-button
2020-03-13 15:44:24 +05:30
v-if="pipeline.cancel_path"
:loading="isCanceling"
:disabled="isCanceling"
2020-10-24 23:57:45 +05:30
data-testid="cancelPipeline"
class="gl-ml-3"
category="primary"
variant="danger"
2020-03-13 15:44:24 +05:30
@click="cancelPipeline()"
2020-10-24 23:57:45 +05:30
>
{{ __('Cancel running') }}
</gl-button>
2020-03-13 15:44:24 +05:30
2020-10-24 23:57:45 +05:30
<gl-button
2020-03-13 15:44:24 +05:30
v-if="pipeline.delete_path"
v-gl-modal="$options.DELETE_MODAL_ID"
:loading="isDeleting"
:disabled="isDeleting"
2020-10-24 23:57:45 +05:30
data-testid="deletePipeline"
class="gl-ml-3"
category="secondary"
variant="danger"
>
{{ __('Delete') }}
</gl-button>
2020-03-13 15:44:24 +05:30
</ci-header>
2020-07-28 23:09:34 +05:30
<gl-loading-icon v-if="isLoading" size="lg" class="gl-mt-3 gl-mb-3" />
2020-03-13 15:44:24 +05:30
<gl-modal
:modal-id="$options.DELETE_MODAL_ID"
:title="__('Delete pipeline')"
:ok-title="__('Delete pipeline')"
ok-variant="danger"
@ok="deletePipeline()"
>
<p>
{{ deleteModalConfirmationText }}
</p>
</gl-modal>
2017-09-10 17:25:29 +05:30
</div>
</template>