note_header.vue 2.6 KB
Newer Older
1
<script>
F
Fatih Acet 已提交
2 3
import { mapActions } from 'vuex';
import timeAgoTooltip from '../../vue_shared/components/time_ago_tooltip.vue';
4

F
Fatih Acet 已提交
5 6 7 8 9 10 11 12
export default {
  components: {
    timeAgoTooltip,
  },
  props: {
    author: {
      type: Object,
      required: true,
F
Filipa Lacerda 已提交
13
    },
F
Fatih Acet 已提交
14 15 16
    createdAt: {
      type: String,
      required: true,
17
    },
F
Fatih Acet 已提交
18 19 20 21
    actionText: {
      type: String,
      required: false,
      default: '',
22
    },
F
Fatih Acet 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    noteId: {
      type: Number,
      required: true,
    },
    includeToggle: {
      type: Boolean,
      required: false,
      default: false,
    },
    expanded: {
      type: Boolean,
      required: false,
      default: true,
    },
  },
  computed: {
    toggleChevronClass() {
      return this.expanded ? 'fa-chevron-up' : 'fa-chevron-down';
    },
    noteTimestampLink() {
      return `#note_${this.noteId}`;
    },
  },
  methods: {
    ...mapActions(['setTargetNoteHash']),
    handleToggle() {
      this.$emit('toggleHandler');
    },
    updateTargetNoteHash() {
      this.setTargetNoteHash(this.noteTimestampLink);
    },
  },
};
56 57 58 59
</script>

<template>
  <div class="note-header-info">
60 61 62 63 64
    <div
      v-if="includeToggle"
      class="discussion-actions">
      <button
        class="note-action-button discussion-toggle-button js-vue-toggle-button"
65 66
        type="button"
        @click="handleToggle">
67 68 69 70 71
        <i
          :class="toggleChevronClass"
          class="fa"
          aria-hidden="true">
        </i>
72
        {{ __('Toggle discussion') }}
73 74
      </button>
    </div>
75
    <a :href="author.path">
76
      <span class="note-header-author-name">{{ author.name }}</span>
77 78 79
      <span
        v-if="author.status_tooltip_html"
        v-html="author.status_tooltip_html"></span>
80
      <span class="note-headline-light">
F
Filipa Lacerda 已提交
81
        @{{ author.username }}
82 83 84 85
      </span>
    </a>
    <span class="note-headline-light">
      <span class="note-headline-meta">
86
        <template v-if="actionText">
F
Filipa Lacerda 已提交
87
          {{ actionText }}
88
        </template>
F
Felipe Artur 已提交
89 90
        <span class="system-note-message">
          <slot></slot>
91
        </span>
J
Jose 已提交
92 93 94
        <span class="system-note-separator">
          &middot;
        </span>
95 96
        <a
          :href="noteTimestampLink"
97 98
          class="note-timestamp system-note-separator"
          @click="updateTargetNoteHash">
99 100
          <time-ago-tooltip
            :time="createdAt"
101
            tooltip-placement="bottom"
F
Filipa Lacerda 已提交
102
          />
103
        </a>
104 105 106
        <i
          class="fa fa-spinner fa-spin editing-spinner"
          aria-label="Comment is being updated"
F
Filipa Lacerda 已提交
107 108
          aria-hidden="true"
        >
109
        </i>
110 111 112 113
      </span>
    </span>
  </div>
</template>