repo_file_buttons.vue 1.14 KB
Newer Older
Luke "Jared" Bennett's avatar
Luke "Jared" Bennett committed
1
<script>
2
import { mapGetters } from 'vuex';
Luke "Jared" Bennett's avatar
Luke "Jared" Bennett committed
3

4
export default {
Luke "Jared" Bennett's avatar
Luke "Jared" Bennett committed
5
  computed: {
6 7 8
    ...mapGetters([
      'activeFile',
    ]),
9
    showButtons() {
10 11 12
      return this.activeFile.rawPath ||
        this.activeFile.blamePath ||
        this.activeFile.commitsPath ||
13 14
        this.activeFile.permalink;
    },
15
    rawDownloadButtonLabel() {
16
      return this.activeFile.binary ? 'Download' : 'Raw';
Luke "Jared" Bennett's avatar
Luke "Jared" Bennett committed
17 18 19 20 21 22
    },
  },
};
</script>

<template>
23 24
  <div
    v-if="showButtons"
Phil Hughes's avatar
Phil Hughes committed
25
    class="multi-file-editor-btn-group"
26
  >
Jacob Schatz's avatar
Jacob Schatz committed
27
    <a
28
      :href="activeFile.rawPath"
Jacob Schatz's avatar
Jacob Schatz committed
29
      target="_blank"
Phil Hughes's avatar
Phil Hughes committed
30
      class="btn btn-default btn-sm raw"
Jacob Schatz's avatar
Jacob Schatz committed
31
      rel="noopener noreferrer">
32
      {{ rawDownloadButtonLabel }}
Jacob Schatz's avatar
Jacob Schatz committed
33
    </a>
Luke "Jared" Bennett's avatar
Luke "Jared" Bennett committed
34

Jacob Schatz's avatar
Jacob Schatz committed
35 36 37 38 39
    <div
      class="btn-group"
      role="group"
      aria-label="File actions">
      <a
40
        :href="activeFile.blamePath"
Phil Hughes's avatar
Phil Hughes committed
41
        class="btn btn-default btn-sm blame">
Jacob Schatz's avatar
Jacob Schatz committed
42 43 44
        Blame
      </a>
      <a
45
        :href="activeFile.commitsPath"
Phil Hughes's avatar
Phil Hughes committed
46
        class="btn btn-default btn-sm history">
Jacob Schatz's avatar
Jacob Schatz committed
47 48 49 50
        History
      </a>
      <a
        :href="activeFile.permalink"
Phil Hughes's avatar
Phil Hughes committed
51
        class="btn btn-default btn-sm permalink">
Jacob Schatz's avatar
Jacob Schatz committed
52 53 54 55
        Permalink
      </a>
    </div>
  </div>
Luke "Jared" Bennett's avatar
Luke "Jared" Bennett committed
56
</template>