debian-mirror-gitlab/app/assets/javascripts/ide/components/jobs/stage.vue

90 lines
2.1 KiB
Vue
Raw Normal View History

2018-11-08 19:23:39 +05:30
<script>
2022-03-02 08:16:31 +05:30
import { GlLoadingIcon, GlIcon, GlTooltipDirective, GlBadge } from '@gitlab/ui';
2018-11-08 19:23:39 +05:30
import CiIcon from '../../../vue_shared/components/ci_icon.vue';
import Item from './item.vue';
export default {
directives: {
2021-01-03 14:25:43 +05:30
GlTooltip: GlTooltipDirective,
2018-11-08 19:23:39 +05:30
},
components: {
2020-11-24 15:15:51 +05:30
GlIcon,
2022-03-02 08:16:31 +05:30
GlBadge,
2018-11-08 19:23:39 +05:30
CiIcon,
Item,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2018-11-08 19:23:39 +05:30
},
props: {
stage: {
type: Object,
required: true,
},
},
data() {
return {
showTooltip: false,
};
},
computed: {
collapseIcon() {
return this.stage.isCollapsed ? 'angle-left' : 'angle-down';
},
showLoadingIcon() {
return this.stage.isLoading && !this.stage.jobs.length;
},
jobsCount() {
return this.stage.jobs.length;
},
},
mounted() {
const { stageTitle } = this.$refs;
this.showTooltip = stageTitle.scrollWidth > stageTitle.offsetWidth;
this.$emit('fetch', this.stage);
},
methods: {
toggleCollapsed() {
this.$emit('toggleCollapsed', this.stage.id);
},
clickViewLog(job) {
this.$emit('clickViewLog', job);
},
},
};
</script>
<template>
2020-07-28 23:09:34 +05:30
<div class="ide-stage card gl-mt-3">
2018-11-08 19:23:39 +05:30
<div
2019-12-26 22:10:19 +05:30
ref="cardHeader"
2018-11-08 19:23:39 +05:30
:class="{
2019-02-15 15:39:39 +05:30
'border-bottom-0': stage.isCollapsed,
2018-11-08 19:23:39 +05:30
}"
class="card-header"
@click="toggleCollapsed"
>
2019-02-15 15:39:39 +05:30
<ci-icon :status="stage.status" :size="24" />
2018-11-08 19:23:39 +05:30
<strong
ref="stageTitle"
2021-01-03 14:25:43 +05:30
v-gl-tooltip="showTooltip"
2018-11-08 19:23:39 +05:30
:title="showTooltip ? stage.name : null"
data-container="body"
2020-06-23 00:09:42 +05:30
class="gl-ml-3 text-truncate"
2018-11-08 19:23:39 +05:30
>
{{ stage.name }}
</strong>
2020-06-23 00:09:42 +05:30
<div v-if="!stage.isLoading || stage.jobs.length" class="gl-mr-3 gl-ml-2">
2022-03-02 08:16:31 +05:30
<gl-badge>{{ jobsCount }}</gl-badge>
2018-11-08 19:23:39 +05:30
</div>
2020-11-24 15:15:51 +05:30
<gl-icon :name="collapseIcon" class="ide-stage-collapse-icon" />
2018-11-08 19:23:39 +05:30
</div>
2020-03-13 15:44:24 +05:30
<div v-show="!stage.isCollapsed" ref="jobList" class="card-body p-0">
2021-09-30 23:02:18 +05:30
<gl-loading-icon v-if="showLoadingIcon" size="sm" />
2018-11-08 19:23:39 +05:30
<template v-else>
2019-02-15 15:39:39 +05:30
<item v-for="job in stage.jobs" :key="job.id" :job="job" @clickViewLog="clickViewLog" />
2018-11-08 19:23:39 +05:30
</template>
</div>
</div>
</template>