gitlab-org--gitlab-foss/app/assets/javascripts/repo/components/repo_preview.vue

65 lines
1.5 KiB
Vue
Raw Normal View History

<script>
/* global LineHighlighter */
import { mapGetters } from 'vuex';
export default {
2017-08-03 16:31:49 -04:00
computed: {
...mapGetters([
'activeFile',
]),
renderErrorTooLarge() {
return this.activeFile.renderError === 'too_large';
},
2017-08-03 16:31:49 -04:00
},
methods: {
highlightFile() {
$(this.$el).find('.file-content').syntaxHighlight();
},
},
mounted() {
this.highlightFile();
this.lineHighlighter = new LineHighlighter({
fileHolderSelector: '.blob-viewer-container',
scrollFileHolder: true,
});
},
updated() {
this.$nextTick(() => {
this.highlightFile();
});
2017-08-04 08:13:32 -04:00
},
};
</script>
<template>
2017-11-23 12:16:01 -05:00
<div>
<div
v-if="!activeFile.renderError"
2017-11-23 12:16:01 -05:00
v-html="activeFile.html"
class="multi-file-preview-holder"
>
</div>
<div
v-else-if="activeFile.tempFile"
class="vertical-center render-error">
<p class="text-center">
The source could not be displayed for this temporary file.
</p>
</div>
<div
v-else-if="renderErrorTooLarge"
class="vertical-center render-error">
<p class="text-center">
The source could not be displayed because it is too large. You can <a :href="activeFile.rawPath" download>download</a> it instead.
</p>
</div>
<div
v-else
class="vertical-center render-error">
<p class="text-center">
The source could not be displayed because a rendering error occurred. You can <a :href="activeFile.rawPath" download>download</a> it instead.
</p>
2017-08-07 17:56:07 -04:00
</div>
</div>
</template>