Welcome to mirror list, hosted at ThFree Co, Russian Federation.

download_viewer.vue « viewers « content_viewer « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3bf629d4acbe0b9c83ce886e724502470f2de8fc (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
<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,
    },
    filePath: {
      type: String,
      required: false,
      default: '',
    },
    fileSize: {
      type: Number,
      required: false,
      default: 0,
    },
  },
  computed: {
    fileSizeReadable() {
      return numberToHumanSize(this.fileSize);
    },
    fileName() {
      // path could be a base64 uri too, so check if filePath was passed additionally
      return (this.filePath || this.path).split('/').pop();
    },
  },
};
</script>

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