Commit 5c9eacd8 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

[ci skip] WIP getRaw on editor mount or getContent when in edit mode

parent b6770b3d
<script> <script>
/* global monaco */ /* global monaco */
import Store from '../stores/repo_store'; import Store from '../stores/repo_store';
import Service from '../services/repo_service';
import Helper from '../helpers/repo_helper'; import Helper from '../helpers/repo_helper';
const RepoEditor = { const RepoEditor = {
data: () => Store, data: () => Store,
mounted() { mounted() {
const monacoInstance = this.monaco.editor.create(this.$el, { Service.getRaw(this.activeFile.raw_path)
model: null, .then((rawResponse) => {
readOnly: true, Store.blobRaw = rawResponse.data;
contextmenu: false,
}); const monacoInstance = this.monaco.editor.create(this.$el, {
model: null,
readOnly: true,
contextmenu: false,
});
Store.monacoInstance = monacoInstance; Store.monacoInstance = monacoInstance;
this.addMonacoEvents(); this.addMonacoEvents();
const languages = this.monaco.languages.getLanguages(); const languages = this.monaco.languages.getLanguages();
const languageID = Helper.getLanguageIDForFile(this.activeFile, languages); const languageID = Helper.getLanguageIDForFile(this.activeFile, languages);
this.showHide(); this.showHide();
const newModel = this.monaco.editor.createModel(this.blobRaw, languageID); const newModel = this.monaco.editor.createModel(this.blobRaw, languageID);
this.monacoInstance.setModel(newModel); this.monacoInstance.setModel(newModel);
}).catch(RepoHelper.loadingError);
}, },
methods: { methods: {
...@@ -60,14 +67,6 @@ const RepoEditor = { ...@@ -60,14 +67,6 @@ const RepoEditor = {
}, },
editMode() { editMode() {
const readOnly = !this.editMode;
Store.readOnly = readOnly;
this.monacoInstance.updateOptions({
readOnly,
});
if (this.editMode) { if (this.editMode) {
$('.project-refs-form').addClass('disabled'); $('.project-refs-form').addClass('disabled');
$('.fa-long-arrow-right').show(); $('.fa-long-arrow-right').show();
...@@ -116,6 +115,7 @@ const RepoEditor = { ...@@ -116,6 +115,7 @@ const RepoEditor = {
}, },
blobRaw() { blobRaw() {
debugger
this.showHide(); this.showHide();
if (this.isTree) return; if (this.isTree) return;
......
...@@ -168,12 +168,14 @@ const RepoHelper = { ...@@ -168,12 +168,14 @@ const RepoHelper = {
data.binary = true; data.binary = true;
Store.currentBlobView = 'preview'; Store.currentBlobView = 'preview';
} else { } else {
Service.getRaw(data.raw_path)
.then(response => {
Store.blobRaw = response.data;
})
// Store.blobRaw = data.plain;
data.binary = false; data.binary = false;
if (Store.currentBlobView !== 'preview') {
Service.getRaw(data.raw_path)
.then((rawResponse) => {
Store.blobRaw = rawResponse.data;
}).catch(RepoHelper.loadingError);
}
} }
if (!file.url) file.url = location.pathname; if (!file.url) file.url = location.pathname;
...@@ -198,8 +200,7 @@ const RepoHelper = { ...@@ -198,8 +200,7 @@ const RepoHelper = {
Store.addFilesToDirectory(file, Store.files, newDirectory); Store.addFilesToDirectory(file, Store.files, newDirectory);
Store.prevURL = Service.blobURLtoParentTree(Service.url); Store.prevURL = Service.blobURLtoParentTree(Service.url);
} }
}) }).catch(RepoHelper.loadingError);
.catch(RepoHelper.loadingError);
}, },
toFA(icon) { toFA(icon) {
......
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