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
    actionTextHtml: {
      type: String,
      required: false,
      default: '',
27
    },
F
Fatih Acet 已提交
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 56 57 58 59 60
    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);
    },
  },
};
61 62 63 64
</script>

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