summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/content_viewer/viewers/download_viewer.vue
blob: 97bdd9915c5c8cd4aec4c5ec3cd4b70a07970028 (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
<script>
import { GlLink } from '@gitlab/ui';
import Icon from '../../icon.vue';
import { numberToHumanSize } from '../../../../lib/utils/number_utils';

export default {
  components: {
    GlLink,
    Icon,
  },
  props: {
    path: {
      type: String,
      required: true,
    },
    fileSize: {
      type: Number,
      required: false,
      default: 0,
    },
  },
  computed: {
    fileSizeReadable() {
      return numberToHumanSize(this.fileSize);
    },
    fileName() {
      return this.path.split('/').pop();
    },
  },
};
</script>

<template>
  <div class="file-container">
    <div class="file-content">
      <p class="prepend-top-10 file-info">
        {{ fileName }}
        <template v-if="fileSize > 0">
          ({{ fileSizeReadable }})
        </template>
      </p>
      <gl-link
        :href="path"
        class="btn btn-default"
        rel="nofollow"
        download
        target="_blank">
        <icon
          :size="16"
          name="download"
          css-classes="float-left append-right-8"
        />
        {{ __('Download') }}
      </gl-link>
    </div>
  </div>
</template>