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

150 lines
3.5 KiB
Vue
Raw Normal View History

2018-11-20 20:47:30 +05:30
<script>
2018-12-05 23:21:45 +05:30
import { polyfillSticky } from '~/lib/utils/sticky';
2018-11-20 20:47:30 +05:30
import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
import { numberToHumanSize } from '~/lib/utils/number_utils';
2018-12-05 23:21:45 +05:30
import { sprintf } from '~/locale';
2018-11-20 20:47:30 +05:30
export default {
components: {
Icon,
},
directives: {
tooltip,
},
props: {
2018-12-05 23:21:45 +05:30
erasePath: {
type: String,
required: false,
default: null,
2018-11-20 20:47:30 +05:30
},
size: {
type: Number,
required: true,
},
2018-12-05 23:21:45 +05:30
rawPath: {
2018-11-20 20:47:30 +05:30
type: String,
required: false,
default: null,
},
2018-12-05 23:21:45 +05:30
isScrollTopDisabled: {
type: Boolean,
required: true,
},
isScrollBottomDisabled: {
type: Boolean,
required: true,
},
isScrollingDown: {
2018-11-20 20:47:30 +05:30
type: Boolean,
required: true,
},
2018-12-05 23:21:45 +05:30
isTraceSizeVisible: {
2018-11-20 20:47:30 +05:30
type: Boolean,
required: true,
},
},
computed: {
jobLogSize() {
2018-12-05 23:21:45 +05:30
return sprintf('Showing last %{size} of log -', {
2018-11-20 20:47:30 +05:30
size: numberToHumanSize(this.size),
});
},
},
2018-12-05 23:21:45 +05:30
mounted() {
polyfillSticky(this.$el);
},
2018-11-20 20:47:30 +05:30
methods: {
handleScrollToTop() {
this.$emit('scrollJobLogTop');
},
handleScrollToBottom() {
this.$emit('scrollJobLogBottom');
},
},
2018-12-05 23:21:45 +05:30
2018-11-20 20:47:30 +05:30
};
</script>
<template>
2018-12-05 23:21:45 +05:30
<div class="top-bar affix js-top-bar">
2018-11-20 20:47:30 +05:30
<!-- truncate information -->
<div class="js-truncated-info truncated-info d-none d-sm-block float-left">
2018-12-05 23:21:45 +05:30
<template v-if="isTraceSizeVisible">
{{ jobLogSize }}
2018-11-20 20:47:30 +05:30
2018-12-05 23:21:45 +05:30
<a
v-if="rawPath"
:href="rawPath"
class="js-raw-link raw-link"
>
{{ s__("Job|Complete Raw") }}
</a>
</template>
2018-11-20 20:47:30 +05:30
</div>
<!-- eo truncate information -->
<div class="controllers float-right">
<!-- links -->
<a
2018-12-05 23:21:45 +05:30
v-if="rawPath"
2018-11-20 20:47:30 +05:30
v-tooltip
:title="s__('Job|Show complete raw')"
2018-12-05 23:21:45 +05:30
:href="rawPath"
2018-11-20 20:47:30 +05:30
class="js-raw-link-controller controllers-buttons"
data-container="body"
>
<icon name="doc-text" />
</a>
2018-12-05 23:21:45 +05:30
<a
v-if="erasePath"
2018-11-20 20:47:30 +05:30
v-tooltip
:title="s__('Job|Erase job log')"
2018-12-05 23:21:45 +05:30
:href="erasePath"
data-confirm="__('Are you sure you want to erase this build?')"
2018-11-20 20:47:30 +05:30
class="js-erase-link controllers-buttons"
data-container="body"
2018-12-05 23:21:45 +05:30
data-method="post"
2018-11-20 20:47:30 +05:30
>
<icon name="remove" />
2018-12-05 23:21:45 +05:30
</a>
2018-11-20 20:47:30 +05:30
<!-- eo links -->
<!-- scroll buttons -->
<div
v-tooltip
:title="s__('Job|Scroll to top')"
class="controllers-buttons"
data-container="body"
>
<button
2018-12-05 23:21:45 +05:30
:disabled="isScrollTopDisabled"
2018-11-20 20:47:30 +05:30
type="button"
class="js-scroll-top btn-scroll btn-transparent btn-blank"
@click="handleScrollToTop"
>
<icon name="scroll_up"/>
</button>
</div>
<div
v-tooltip
:title="s__('Job|Scroll to bottom')"
class="controllers-buttons"
data-container="body"
>
<button
2018-12-05 23:21:45 +05:30
:disabled="isScrollBottomDisabled"
2018-11-20 20:47:30 +05:30
type="button"
class="js-scroll-bottom btn-scroll btn-transparent btn-blank"
2018-12-05 23:21:45 +05:30
:class="{ animate: isScrollingDown }"
2018-11-20 20:47:30 +05:30
@click="handleScrollToBottom"
>
<icon name="scroll_down"/>
</button>
</div>
<!-- eo scroll buttons -->
</div>
</div>
</template>