All files / app/assets/javascripts/blob/components blob_header_filepath.vue

100% Statements 7/7
100% Branches 3/3
100% Functions 4/4
100% Lines 7/7

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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70        9x                                         34x     34x     34x     34x 15x     19x                                                              
<script>
import { GlBadge } from '@gitlab/ui';
import { numberToHumanSize } from '~/lib/utils/number_utils';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import FileIcon from '~/vue_shared/components/file_icon.vue';
 
export default {
  components: {
    FileIcon,
    ClipboardButton,
    GlBadge,
  },
  props: {
    blob: {
      type: Object,
      required: true,
    },
    showPath: {
      type: Boolean,
      required: false,
      default: true,
    },
  },
  computed: {
    blobSize() {
      return numberToHumanSize(this.blob.size);
    },
    gfmCopyText() {
      return `\`${this.blob.path}\``;
    },
    showLfsBadge() {
      return this.blob.storedExternally && this.blob.externalStorage === 'lfs';
    },
    fileName() {
      if (this.showPath) {
        return this.blob.path;
      }
 
      return this.blob.name;
    },
  },
};
</script>
<template>
  <div class="file-header-content d-flex gl-align-items-center gl-line-height-1">
    <slot name="filepath-prepend"></slot>
 
    <template v-if="fileName">
      <file-icon :file-name="fileName" :size="16" aria-hidden="true" css-classes="gl-mr-3" />
      <strong
        class="file-title-name mr-1 js-blob-header-filepath"
        data-testid="file-title-content"
        >{{ fileName }}</strong
      >
    </template>
 
    <clipboard-button
      :text="blob.path"
      :gfm="gfmCopyText"
      :title="__('Copy file path')"
      category="tertiary"
      css-class="gl-mr-2"
    />
 
    <small class="gl-mr-3">{{ blobSize }}</small>
 
    <gl-badge v-if="showLfsBadge">{{ __('LFS') }}</gl-badge>
  </div>
</template>