Commit dca28c94 authored by Jacob Schatz's avatar Jacob Schatz

Get README to render.

parent 62ad0113
...@@ -19,8 +19,8 @@ export default class RepoBinaryViewer { ...@@ -19,8 +19,8 @@ export default class RepoBinaryViewer {
}, },
methods: { methods: {
supportedNonBinaryFileType(fileExt) { supportedNonBinaryFileType() {
switch(fileExt) { switch(this.activeFile.extension) {
case 'md': case 'md':
this.binaryTypes.markdown = true; this.binaryTypes.markdown = true;
return true; return true;
...@@ -33,12 +33,13 @@ export default class RepoBinaryViewer { ...@@ -33,12 +33,13 @@ export default class RepoBinaryViewer {
watch: { watch: {
blobRaw() { blobRaw() {
if(!this.binary) return; let supported = this.supportedNonBinaryFileType();
let supported = supportedNonBinaryFileType();
if(supported) { if(supported) {
this.binaryTypes.markdown = true;
this.binary = true;
return; return;
} }
if(!this.binary) return;
switch(this.binaryMimeType) { switch(this.binaryMimeType) {
case 'image/png': case 'image/png':
this.binaryTypes.png = true; this.binaryTypes.png = true;
......
...@@ -31,6 +31,7 @@ export default class RepoEditor { ...@@ -31,6 +31,7 @@ export default class RepoEditor {
this.vue = new Vue({ this.vue = new Vue({
data: () => Store, data: () => Store,
created () { created () {
this.showHide();
if(this.blobRaw !== ''){ if(this.blobRaw !== ''){
monacoEditor.setModel( monacoEditor.setModel(
monaco.editor.createModel( monaco.editor.createModel(
...@@ -41,29 +42,32 @@ export default class RepoEditor { ...@@ -41,29 +42,32 @@ export default class RepoEditor {
} }
}, },
watch: { methods: {
isTree() { showHide() {
if(!this.openedFiles.length) { if((!this.openedFiles.length) || this.binary) {
self.el.style.display = 'none'; self.el.style.display = 'none';
} else { } else {
self.el.style.display = 'inline-block'; self.el.style.display = 'inline-block';
} }
}
},
watch: {
isTree() {
this.showHide();
}, },
openedFiles() { openedFiles() {
if((!this.openedFiles.length) || this.binary) { this.showHide();
self.el.style.display = 'none'; },
} else {
self.el.style.display = 'inline-block'; binary() {
} this.showHide();
}, },
blobRaw() { blobRaw() {
if(this.binary) { this.showHide();
self.el.style.display = 'none';
} else {
self.el.style.display = 'inline-block';
}
if(!this.isTree) { if(!this.isTree) {
self.monacoEditor.setModel( self.monacoEditor.setModel(
monaco.editor.createModel( monaco.editor.createModel(
......
...@@ -183,6 +183,7 @@ let RepoHelper = { ...@@ -183,6 +183,7 @@ let RepoHelper = {
this.addToOpenedFiles(data); this.addToOpenedFiles(data);
this.setActiveFile(data); this.setActiveFile(data);
} }
// if the file tree is empty // if the file tree is empty
if(Store.files.length === 0) { if(Store.files.length === 0) {
const parentURL = this.blobURLtoParent(Service.url); const parentURL = this.blobURLtoParent(Service.url);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#ide{ data: { url: repo_url } } #ide{ data: { url: repo_url } }
#binary-viewer{ "v-if" => "binary" } #binary-viewer{ "v-if" => "binary" }
%img{"v-if" => "binaryTypes.png", ":src" => "pngBlobWithDataURI"} %img{"v-if" => "binaryTypes.png", ":src" => "pngBlobWithDataURI"}
%div{"v-if" => "binaryTypes.markdown", "v-html" => "activeFile.html"}
- if can_edit_tree? - if can_edit_tree?
= render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: namespace_project_create_blob_path(@project.namespace, @project, @id), method: :post = render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: namespace_project_create_blob_path(@project.namespace, @project, @id), method: :post
= render 'projects/blob/new_dir' = render 'projects/blob/new_dir'
......
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