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 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
      <span class="note-headline-light">
F
Filipa Lacerda 已提交
78
        @{{ author.username }}
79 80 81 82
      </span>
    </a>
    <span class="note-headline-light">
      <span class="note-headline-meta">
83
        <template v-if="actionText">
F
Filipa Lacerda 已提交
84
          {{ actionText }}
85
        </template>
F
Felipe Artur 已提交
86 87
        <span class="system-note-message">
          <slot></slot>
88
        </span>
J
Jose 已提交
89 90 91
        <span class="system-note-separator">
          &middot;
        </span>
92 93
        <a
          :href="noteTimestampLink"
94 95
          class="note-timestamp system-note-separator"
          @click="updateTargetNoteHash">
96 97
          <time-ago-tooltip
            :time="createdAt"
98
            tooltip-placement="bottom"
F
Filipa Lacerda 已提交
99
          />
100
        </a>
101 102 103
        <i
          class="fa fa-spinner fa-spin editing-spinner"
          aria-label="Comment is being updated"
F
Filipa Lacerda 已提交
104 105
          aria-hidden="true"
        >
106
        </i>
107 108 109 110
      </span>
    </span>
  </div>
</template>