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

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

120 lines
2.9 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
2023-03-04 22:38:38 +05:30
import DefaultActions from 'jh_else_ce/blob/components/blob_header_default_actions.vue';
2020-03-13 15:44:24 +05:30
import BlobFilepath from './blob_header_filepath.vue';
2021-03-11 19:13:27 +05:30
import ViewerSwitcher from './blob_header_viewer_switcher.vue';
2020-03-13 15:44:24 +05:30
import { SIMPLE_BLOB_VIEWER } from './constants';
2021-12-11 22:18:48 +05:30
import TableOfContents from './table_contents.vue';
2020-03-13 15:44:24 +05:30
export default {
components: {
ViewerSwitcher,
DefaultActions,
BlobFilepath,
2021-12-11 22:18:48 +05:30
TableOfContents,
2020-03-13 15:44:24 +05:30
},
props: {
blob: {
type: Object,
required: true,
},
hideDefaultActions: {
type: Boolean,
required: false,
default: false,
},
hideViewerSwitcher: {
type: Boolean,
required: false,
default: false,
},
2021-10-27 15:23:28 +05:30
isBinary: {
type: Boolean,
required: false,
default: false,
},
2020-03-13 15:44:24 +05:30
activeViewerType: {
type: String,
required: false,
default: SIMPLE_BLOB_VIEWER,
},
2020-06-23 00:09:42 +05:30
hasRenderError: {
type: Boolean,
required: false,
default: false,
},
2022-04-04 11:22:00 +05:30
showPath: {
type: Boolean,
required: false,
default: true,
},
2022-07-23 23:45:48 +05:30
overrideCopy: {
type: Boolean,
required: false,
default: false,
},
2020-03-13 15:44:24 +05:30
},
data() {
return {
viewer: this.hideViewerSwitcher ? null : this.activeViewerType,
};
},
computed: {
showViewerSwitcher() {
return !this.hideViewerSwitcher && Boolean(this.blob.simpleViewer && this.blob.richViewer);
},
showDefaultActions() {
return !this.hideDefaultActions;
},
2022-04-04 11:22:00 +05:30
isEmpty() {
2023-03-17 16:20:25 +05:30
return this.blob.rawSize === '0';
2022-04-04 11:22:00 +05:30
},
2022-05-07 20:08:51 +05:30
blobSwitcherDocIcon() {
return this.blob.richViewer?.fileType === 'csv' ? 'table' : 'document';
},
2020-03-13 15:44:24 +05:30
},
watch: {
viewer(newVal, oldVal) {
if (!this.hideViewerSwitcher && newVal !== oldVal) {
this.$emit('viewer-changed', newVal);
}
},
},
methods: {
proxyCopyRequest() {
this.$emit('copy');
},
},
};
</script>
<template>
<div class="js-file-title file-title-flex-parent">
2021-12-11 22:18:48 +05:30
<div class="gl-display-flex">
<table-of-contents class="gl-pr-2" />
2022-04-04 11:22:00 +05:30
<blob-filepath :blob="blob" :show-path="showPath">
2021-12-11 22:18:48 +05:30
<template #filepath-prepend>
<slot name="prepend"></slot>
</template>
</blob-filepath>
</div>
2020-03-13 15:44:24 +05:30
2022-07-16 23:28:13 +05:30
<div class="gl-display-flex gl-flex-wrap file-actions">
2022-05-07 20:08:51 +05:30
<viewer-switcher v-if="showViewerSwitcher" v-model="viewer" :doc-icon="blobSwitcherDocIcon" />
2020-03-13 15:44:24 +05:30
<slot name="actions"></slot>
<default-actions
v-if="showDefaultActions"
2022-04-04 11:22:00 +05:30
:raw-path="blob.externalStorageUrl || blob.rawPath"
2020-03-13 15:44:24 +05:30
:active-viewer="viewer"
2020-06-23 00:09:42 +05:30
:has-render-error="hasRenderError"
2021-10-27 15:23:28 +05:30
:is-binary="isBinary"
2022-04-04 11:22:00 +05:30
:environment-name="blob.environmentFormattedExternalUrl"
:environment-path="blob.environmentExternalUrlForRouteMap"
:is-empty="isEmpty"
2022-07-23 23:45:48 +05:30
:override-copy="overrideCopy"
2020-03-13 15:44:24 +05:30
@copy="proxyCopyRequest"
/>
</div>
</div>
</template>