summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/ide_file_buttons.vue
blob: a6c6f46a14418a5ad9c169c69aab7916a8048c86 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<script>
import { __ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip';
import Icon from '~/vue_shared/components/icon.vue';

export default {
  components: {
    Icon,
  },
  directives: {
    tooltip,
  },
  props: {
    file: {
      type: Object,
      required: true,
    },
  },
  computed: {
    showButtons() {
      return (
        this.file.rawPath || this.file.blamePath || this.file.commitsPath || this.file.permalink
      );
    },
    rawDownloadButtonLabel() {
      return this.file.binary ? __('Download') : __('Raw');
    },
  },
};
</script>

<template>
  <div
    v-if="showButtons"
    class="pull-right ide-btn-group"
  >
    <a
      v-tooltip
      v-if="!file.binary"
      :href="file.blamePath"
      :title="__('Blame')"
      class="btn btn-xs btn-transparent blame"
    >
      <icon
        name="blame"
        :size="16"
      />
    </a>
    <a
      v-tooltip
      :href="file.commitsPath"
      :title="__('History')"
      class="btn btn-xs btn-transparent history"
    >
      <icon
        name="history"
        :size="16"
      />
    </a>
    <a
      v-tooltip
      :href="file.permalink"
      :title="__('Permalink')"
      class="btn btn-xs btn-transparent permalink"
    >
      <icon
        name="link"
        :size="16"
      />
    </a>
    <a
      v-tooltip
      :href="file.rawPath"
      target="_blank"
      class="btn btn-xs btn-transparent prepend-left-10 raw"
      rel="noopener noreferrer"
      :title="rawDownloadButtonLabel">
      <icon
        name="download"
        :size="16"
      />
    </a>
  </div>
</template>