debian-mirror-gitlab/app/assets/javascripts/blob/components/blob_header_filepath.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.6 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
2022-03-02 08:16:31 +05:30
import { GlBadge } from '@gitlab/ui';
2020-03-13 15:44:24 +05:30
import { numberToHumanSize } from '~/lib/utils/number_utils';
2021-03-11 19:13:27 +05:30
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import FileIcon from '~/vue_shared/components/file_icon.vue';
2020-03-13 15:44:24 +05:30
export default {
components: {
FileIcon,
ClipboardButton,
2022-03-02 08:16:31 +05:30
GlBadge,
2020-03-13 15:44:24 +05:30
},
props: {
blob: {
type: Object,
required: true,
},
2022-04-04 11:22:00 +05:30
showPath: {
type: Boolean,
required: false,
default: true,
},
2020-03-13 15:44:24 +05:30
},
computed: {
blobSize() {
return numberToHumanSize(this.blob.size);
},
gfmCopyText() {
return `\`${this.blob.path}\``;
},
2022-03-02 08:16:31 +05:30
showLfsBadge() {
return this.blob.storedExternally && this.blob.externalStorage === 'lfs';
},
2022-04-04 11:22:00 +05:30
fileName() {
if (this.showPath) {
return this.blob.path;
}
return this.blob.name;
},
2020-03-13 15:44:24 +05:30
},
};
</script>
<template>
<div class="file-header-content d-flex align-items-center lh-100">
2021-01-29 00:20:46 +05:30
<slot name="filepath-prepend"></slot>
2020-03-13 15:44:24 +05:30
2022-04-04 11:22:00 +05:30
<template v-if="fileName">
<file-icon :file-name="fileName" :size="16" aria-hidden="true" css-classes="mr-2" />
2020-05-24 23:13:21 +05:30
<strong
class="file-title-name mr-1 js-blob-header-filepath"
2020-06-23 00:09:42 +05:30
data-qa-selector="file_title_content"
2022-04-04 11:22:00 +05:30
>{{ fileName }}</strong
2020-05-24 23:13:21 +05:30
>
</template>
2020-03-13 15:44:24 +05:30
<clipboard-button
:text="blob.path"
:gfm="gfmCopyText"
:title="__('Copy file path')"
2021-01-03 14:25:43 +05:30
category="tertiary"
2020-03-13 15:44:24 +05:30
css-class="btn-clipboard btn-transparent lh-100 position-static"
/>
2022-03-02 08:16:31 +05:30
<small class="mr-2">{{ blobSize }}</small>
<gl-badge v-if="showLfsBadge">{{ __('LFS') }}</gl-badge>
2020-03-13 15:44:24 +05:30
</div>
</template>