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