summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/components/blob_header_filepath.vue
blob: 6c6a22e2b36586c5687c339a3edf835ffd62b496 (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
<script>
import FileIcon from '~/vue_shared/components/file_icon.vue';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import { numberToHumanSize } from '~/lib/utils/number_utils';

export default {
  components: {
    FileIcon,
    ClipboardButton,
  },
  props: {
    blob: {
      type: Object,
      required: true,
    },
  },
  computed: {
    blobSize() {
      return numberToHumanSize(this.blob.size);
    },
    gfmCopyText() {
      return `\`${this.blob.path}\``;
    },
  },
};
</script>
<template>
  <div class="file-header-content d-flex align-items-center lh-100">
    <slot name="filepathPrepend"></slot>

    <file-icon :file-name="blob.path" :size="18" aria-hidden="true" css-classes="mr-2" />
    <strong
      v-if="blob.name"
      class="file-title-name qa-file-title-name mr-1 js-blob-header-filepath"
      >{{ blob.name }}</strong
    >

    <small class="mr-2">{{ blobSize }}</small>

    <clipboard-button
      :text="blob.path"
      :gfm="gfmCopyText"
      :title="__('Copy file path')"
      css-class="btn-clipboard btn-transparent lh-100 position-static"
    />
  </div>
</template>