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 65
</script>

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