summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo/components/repo_file_buttons.vue
blob: dd948ee84fbf54f57adcfbfbbe45dae1eb748eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
56
<script>
import { mapGetters } from 'vuex';

export default {
  computed: {
    ...mapGetters([
      'activeFile',
    ]),
    showButtons() {
      return this.activeFile.rawPath ||
        this.activeFile.blamePath ||
        this.activeFile.commitsPath ||
        this.activeFile.permalink;
    },
    rawDownloadButtonLabel() {
      return this.activeFile.binary ? 'Download' : 'Raw';
    },
  },
};
</script>

<template>
  <div
    v-if="showButtons"
    class="repo-file-buttons"
  >
    <a
      :href="activeFile.rawPath"
      target="_blank"
      class="btn btn-default raw"
      rel="noopener noreferrer">
      {{ rawDownloadButtonLabel }}
    </a>

    <div
      class="btn-group"
      role="group"
      aria-label="File actions">
      <a
        :href="activeFile.blamePath"
        class="btn btn-default blame">
        Blame
      </a>
      <a
        :href="activeFile.commitsPath"
        class="btn btn-default history">
        History
      </a>
      <a
        :href="activeFile.permalink"
        class="btn btn-default permalink">
        Permalink
      </a>
    </div>
  </div>
</template>