BigW Consortium Gitlab

repo_preview.vue 1.48 KB
Newer Older
1
<script>
2
/* global LineHighlighter */
3
import { mapGetters } from 'vuex';
4 5

export default {
Jacob Schatz committed
6
  computed: {
7 8 9
    ...mapGetters([
      'activeFile',
    ]),
10
    renderErrorTooLarge() {
Phil Hughes committed
11
      return this.activeFile.renderError === 'too_large';
12
    },
Jacob Schatz committed
13
  },
14 15 16 17 18
  methods: {
    highlightFile() {
      $(this.$el).find('.file-content').syntaxHighlight();
    },
  },
19 20 21 22 23 24 25
  mounted() {
    this.highlightFile();
    this.lineHighlighter = new LineHighlighter({
      fileHolderSelector: '.blob-viewer-container',
      scrollFileHolder: true,
    });
  },
26 27 28 29
  updated() {
    this.$nextTick(() => {
      this.highlightFile();
    });
Luke "Jared" Bennett committed
30 31
  },
};
32 33 34
</script>

<template>
Phil Hughes committed
35
<div>
36
  <div
37
    v-if="!activeFile.renderError"
Phil Hughes committed
38 39 40
    v-html="activeFile.html"
    class="multi-file-preview-holder"
  >
41
  </div>
42 43 44 45 46 47 48
  <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>
49
  <div
50
    v-else-if="renderErrorTooLarge"
51 52
    class="vertical-center render-error">
    <p class="text-center">
53
      The source could not be displayed because it is too large. You can <a :href="activeFile.rawPath" download>download</a> it instead.
54 55 56 57 58 59
    </p>
  </div>
  <div
    v-else
    class="vertical-center render-error">
    <p class="text-center">
60
      The source could not be displayed because a rendering error occurred. You can <a :href="activeFile.rawPath" download>download</a> it instead.
61
    </p>
62 63
  </div>
</div>
64
</template>