debian-mirror-gitlab/app/assets/javascripts/issue_show/components/title.vue

86 lines
1.8 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlButton, GlTooltipDirective, GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
2018-11-08 19:23:39 +05:30
import animateMixin from '../mixins/animate';
import eventHub from '../event_hub';
2017-09-10 17:25:29 +05:30
2018-11-08 19:23:39 +05:30
export default {
2020-11-24 15:15:51 +05:30
components: {
GlButton,
},
2018-11-08 19:23:39 +05:30
directives: {
2020-11-24 15:15:51 +05:30
GlTooltip: GlTooltipDirective,
SafeHtml,
2018-11-08 19:23:39 +05:30
},
mixins: [animateMixin],
props: {
issuableRef: {
type: [String, Number],
required: true,
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
canUpdate: {
required: false,
type: Boolean,
default: false,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
titleHtml: {
type: String,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
titleText: {
type: String,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
showInlineEditButton: {
type: Boolean,
required: false,
default: false,
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
},
data() {
return {
preAnimation: false,
pulseAnimation: false,
titleEl: document.querySelector('title'),
};
},
watch: {
titleHtml() {
this.setPageTitle();
this.animateChange();
},
},
methods: {
setPageTitle() {
const currentPageTitleScope = this.titleEl.innerText.split('·');
currentPageTitleScope[0] = `${this.titleText} (${this.issuableRef}) `;
this.titleEl.textContent = currentPageTitleScope.join('·');
},
edit() {
eventHub.$emit('open.form');
},
},
};
2017-09-10 17:25:29 +05:30
</script>
<template>
2018-03-17 18:26:18 +05:30
<div class="title-container">
<h2
2020-11-24 15:15:51 +05:30
v-safe-html="titleHtml"
2018-03-17 18:26:18 +05:30
:class="{
'issue-realtime-pre-pulse': preAnimation,
2019-02-15 15:39:39 +05:30
'issue-realtime-trigger-pulse': pulseAnimation,
2018-03-17 18:26:18 +05:30
}"
2019-09-04 21:01:54 +05:30
class="title qa-title"
2019-07-31 22:56:46 +05:30
dir="auto"
2019-02-15 15:39:39 +05:30
></h2>
2020-11-24 15:15:51 +05:30
<gl-button
2018-03-17 18:26:18 +05:30
v-if="showInlineEditButton && canUpdate"
2020-11-24 15:15:51 +05:30
v-gl-tooltip.bottom
icon="pencil"
class="btn-edit js-issuable-edit qa-edit-button"
2018-03-17 18:26:18 +05:30
title="Edit title and description"
@click="edit"
2020-11-24 15:15:51 +05:30
/>
2018-03-17 18:26:18 +05:30
</div>
2017-09-10 17:25:29 +05:30
</template>