All files / app/assets/javascripts/vue_shared/components/content_viewer/viewers download_viewer.vue

0% Statements 0/2
0% Branches 0/2
0% Functions 0/2
0% Lines 0/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                                     
<script>
import { GlIcon } from '@gitlab/ui';
import { numberToHumanSize } from '~/lib/utils/number_utils';
 
export default {
  components: {
    GlIcon,
  },
  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>
      <a :href="path" class="btn btn-default" rel="nofollow" :download="fileName" target="_blank">
        <gl-icon :size="16" name="download" class="float-left gl-mr-3" />
        {{ __('Download') }}
      </a>
    </div>
  </div>
</template>