note_header.vue 2.5 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 70 71 72 73 74 75 76 77 78 79
    <div
      v-if="includeToggle"
      class="discussion-actions">
      <button
        @click="handleToggle"
        class="note-action-button discussion-toggle-button js-vue-toggle-button"
        type="button">
        <i
          :class="toggleChevronClass"
          class="fa"
          aria-hidden="true">
        </i>
        Toggle discussion
      </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 93
        </template>
        <span
          v-if="actionTextHtml"
          v-html="actionTextHtml"
94 95
          class="system-note-message">
        </span>
96 97
        <a
          :href="noteTimestampLink"
98 99
          @click="updateTargetNoteHash"
          class="note-timestamp">
100 101
          <time-ago-tooltip
            :time="createdAt"
102
            tooltip-placement="bottom"
F
Filipa Lacerda 已提交
103
          />
104
        </a>
105 106 107
        <i
          class="fa fa-spinner fa-spin editing-spinner"
          aria-label="Comment is being updated"
F
Filipa Lacerda 已提交
108 109
          aria-hidden="true"
        >
110
        </i>
111 112 113 114
      </span>
    </span>
  </div>
</template>