summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-08-03 17:21:45 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-08-03 17:21:45 +0100
commit5c9eacd8f90b7e200f56a86256929166ff3b4acb (patch)
treeee8aac6ea9d7ef58c571dec41503b02c944af9a1 /app/assets/javascripts/repo
parentb6770b3d9af23376f182a96da78cf8c405120d22 (diff)
downloadgitlab-ce-5c9eacd8f90b7e200f56a86256929166ff3b4acb.tar.gz
[ci skip] WIP getRaw on editor mount or getContent when in edit mode
Diffstat (limited to 'app/assets/javascripts/repo')
-rw-r--r--app/assets/javascripts/repo/components/repo_editor.vue40
-rw-r--r--app/assets/javascripts/repo/helpers/repo_helper.js15
2 files changed, 28 insertions, 27 deletions
diff --git a/app/assets/javascripts/repo/components/repo_editor.vue b/app/assets/javascripts/repo/components/repo_editor.vue
index b006a9bc1f6..67dd5eb9975 100644
--- a/app/assets/javascripts/repo/components/repo_editor.vue
+++ b/app/assets/javascripts/repo/components/repo_editor.vue
@@ -1,28 +1,35 @@
<script>
/* global monaco */
import Store from '../stores/repo_store';
+import Service from '../services/repo_service';
import Helper from '../helpers/repo_helper';
const RepoEditor = {
data: () => Store,
mounted() {
- const monacoInstance = this.monaco.editor.create(this.$el, {
- model: null,
- readOnly: true,
- contextmenu: false,
- });
+ Service.getRaw(this.activeFile.raw_path)
+ .then((rawResponse) => {
+ Store.blobRaw = rawResponse.data;
+
+ 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 languageID = Helper.getLanguageIDForFile(this.activeFile, languages);
- this.showHide();
- const newModel = this.monaco.editor.createModel(this.blobRaw, languageID);
+ const languages = this.monaco.languages.getLanguages();
+ const languageID = Helper.getLanguageIDForFile(this.activeFile, languages);
+ this.showHide();
+ const newModel = this.monaco.editor.createModel(this.blobRaw, languageID);
- this.monacoInstance.setModel(newModel);
+ this.monacoInstance.setModel(newModel);
+
+ }).catch(RepoHelper.loadingError);
},
methods: {
@@ -60,14 +67,6 @@ const RepoEditor = {
},
editMode() {
- const readOnly = !this.editMode;
-
- Store.readOnly = readOnly;
-
- this.monacoInstance.updateOptions({
- readOnly,
- });
-
if (this.editMode) {
$('.project-refs-form').addClass('disabled');
$('.fa-long-arrow-right').show();
@@ -116,6 +115,7 @@ const RepoEditor = {
},
blobRaw() {
+ debugger
this.showHide();
if (this.isTree) return;
diff --git a/app/assets/javascripts/repo/helpers/repo_helper.js b/app/assets/javascripts/repo/helpers/repo_helper.js
index af64718be5b..fb1b269d691 100644
--- a/app/assets/javascripts/repo/helpers/repo_helper.js
+++ b/app/assets/javascripts/repo/helpers/repo_helper.js
@@ -168,12 +168,14 @@ const RepoHelper = {
data.binary = true;
Store.currentBlobView = 'preview';
} else {
- Service.getRaw(data.raw_path)
- .then(response => {
- Store.blobRaw = response.data;
- })
- // Store.blobRaw = data.plain;
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;
@@ -198,8 +200,7 @@ const RepoHelper = {
Store.addFilesToDirectory(file, Store.files, newDirectory);
Store.prevURL = Service.blobURLtoParentTree(Service.url);
}
- })
- .catch(RepoHelper.loadingError);
+ }).catch(RepoHelper.loadingError);
},
toFA(icon) {