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';
|
2020-02-11 07:08:52 -05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
ViewerSwitcher,
|
|
|
|
DefaultActions,
|
|
|
|
BlobFilepath,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
blob: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
hideDefaultActions: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
hideViewerSwitcher: {
|
|
|
|
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,
|
|
|
|
},
|
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;
|
|
|
|
},
|
|
|
|
},
|
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">
|
|
|
|
<blob-filepath :blob="blob">
|
2020-11-13 16:09:31 -05:00
|
|
|
<template #filepath-prepend>
|
2020-02-11 07:08:52 -05:00
|
|
|
<slot name="prepend"></slot>
|
|
|
|
</template>
|
|
|
|
</blob-filepath>
|
|
|
|
|
2021-01-25 10:09:00 -05:00
|
|
|
<div class="gl-display-none gl-sm-display-flex">
|
2020-02-12 10:09:37 -05:00
|
|
|
<viewer-switcher v-if="showViewerSwitcher" v-model="viewer" />
|
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"
|
|
|
|
:raw-path="blob.rawPath"
|
|
|
|
:active-viewer="viewer"
|
2020-05-26 08:08:22 -04:00
|
|
|
:has-render-error="hasRenderError"
|
2020-02-12 10:09:37 -05:00
|
|
|
@copy="proxyCopyRequest"
|
|
|
|
/>
|
2020-02-11 07:08:52 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|