BigW Consortium Gitlab

Commit bc39218b by Jacob Schatz

Show warning for big files.

parent 7572aaf3
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
</script> </script>
<template> <template>
<button class="btn btn-default" @click.prevent="editClicked" v-cloak v-if="isCommitable" :disabled="binary"> <button class="btn btn-default" @click.prevent="editClicked" v-cloak v-if="isCommitable && !activeFile.render_error" :disabled="binary">
<i :class="buttonIcon"></i> <i :class="buttonIcon"></i>
<span>{{buttonLabel}}</span> <span>{{buttonLabel}}</span>
</button> </button>
......
...@@ -23,5 +23,10 @@ export default { ...@@ -23,5 +23,10 @@ export default {
</script> </script>
<template> <template>
<div v-html="activeFile.html"></div> <div>
<div v-if="!activeFile.render_error" v-html="activeFile.html"></div>
<div v-if="activeFile.render_error" 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.raw_path">download</a> it instead.</p>
</div>
</div>
</template> </template>
...@@ -154,16 +154,19 @@ const RepoHelper = { ...@@ -154,16 +154,19 @@ const RepoHelper = {
RepoHelper.setBinaryDataAsBase64(data); RepoHelper.setBinaryDataAsBase64(data);
Store.setViewToPreview(); Store.setViewToPreview();
} else if (!Store.isPreviewView()) { } else if (!Store.isPreviewView()) {
Service.getRaw(data.raw_path) if(!data.render_error){
Service.getRaw(data.raw_path)
.then((rawResponse) => { .then((rawResponse) => {
Store.blobRaw = rawResponse.data; Store.blobRaw = rawResponse.data;
data.plain = rawResponse.data; data.plain = rawResponse.data;
RepoHelper.setFile(data, file); RepoHelper.setFile(data, file);
}).catch(RepoHelper.loadingError); }).catch(RepoHelper.loadingError);
}
} }
if (Store.isPreviewView()) RepoHelper.setFile(data, file); if (Store.isPreviewView()){
RepoHelper.setFile(data, file);
}
// if the file tree is empty // if the file tree is empty
if (Store.files.length === 0) { if (Store.files.length === 0) {
...@@ -187,6 +190,9 @@ const RepoHelper = { ...@@ -187,6 +190,9 @@ const RepoHelper = {
newFile.url = file.url || location.pathname; newFile.url = file.url || location.pathname;
newFile.url = file.url; newFile.url = file.url;
if(newFile.render_error === 'too_large'){
newFile.tooLarge = true;
}
newFile.newContent = ''; newFile.newContent = '';
Store.addToOpenedFiles(newFile); Store.addToOpenedFiles(newFile);
......
...@@ -128,3 +128,11 @@ of the body element here, we negate cascading side effects but allow momentum sc ...@@ -128,3 +128,11 @@ of the body element here, we negate cascading side effects but allow momentum sc
[v-cloak] { [v-cloak] {
display: none; display: none;
} }
.vertical-center {
min-height: 100%;
min-height: 100vh;
display: flex;
align-items: center;
}
\ No newline at end of file
...@@ -369,6 +369,13 @@ ...@@ -369,6 +369,13 @@
} }
} }
.render-error {
min-height: calc(100vh - 63px);
p {
width: 100%;
}
}
@keyframes blockTextShine { @keyframes blockTextShine {
0% { 0% {
transform: translateX(-468px); transform: translateX(-468px);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment