Commit 3a2f883f authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'ide' of gitlab.com:gitlab-org/gitlab-ce into ide With conflicts

parents 0b500111 51a936fb
...@@ -72,19 +72,18 @@ import RepoBundle from './repo/repo_bundle'; ...@@ -72,19 +72,18 @@ import RepoBundle from './repo/repo_bundle';
} }
Dispatcher.prototype.initPageScripts = function() { Dispatcher.prototype.initPageScripts = function() {
var page, path, shortcut_handler, fileBlobPermalinkUrlElement, fileBlobPermalinkUrl, os; var page, path, shortcut_handler, fileBlobPermalinkUrlElement, fileBlobPermalinkUrl;
page = $('body').attr('data-page'); page = $('body').attr('data-page');
if (!page) { if (!page) {
return false; return false;
} }
function getScrollBarWidth () { function getScrollBarWidth () {
var $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'), var $outer = $('<div>').css({ visibility: 'hidden', width: 100, overflow: 'scroll' }).appendTo('body'),
widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth(); widthWithScroll = $('<div>').css({ width: '100%' }).appendTo($outer).outerWidth();
$outer.remove(); $outer.remove();
return 100 - widthWithScroll; return 100 - widthWithScroll;
}; }
$('body').attr('data-scroll-width', getScrollBarWidth()); $('body').attr('data-scroll-width', getScrollBarWidth());
...@@ -353,7 +352,7 @@ import RepoBundle from './repo/repo_bundle'; ...@@ -353,7 +352,7 @@ import RepoBundle from './repo/repo_bundle';
shortcut_handler = true; shortcut_handler = true;
break; break;
case 'projects:blob:show': case 'projects:blob:show':
new RepoBundle(); new RepoBundle();
break; break;
case 'projects:blame:show': case 'projects:blame:show':
initBlob(); initBlob();
......
import Vue from 'vue' import Vue from 'vue';
import Store from './repo_store' import Store from './repo_store';
import { loadingError } from './repo_helper';
export default class RepoBinaryViewer { export default class RepoBinaryViewer {
constructor(url) { constructor() {
this.initVue(); this.initVue();
} }
...@@ -15,32 +16,51 @@ export default class RepoBinaryViewer { ...@@ -15,32 +16,51 @@ export default class RepoBinaryViewer {
computed: { computed: {
pngBlobWithDataURI() { pngBlobWithDataURI() {
return `data:image/png;base64,${this.blobRaw}`; return `data:image/png;base64,${this.blobRaw}`;
} },
}, },
methods: { methods: {
<<<<<<< HEAD
isMarkdown() { isMarkdown() {
return this.activeFile.extension === 'md'; return this.activeFile.extension === 'md';
=======
supportedNonBinaryFileType() {
switch (this.activeFile.extension) {
case 'md':
this.binaryTypes.markdown = true;
return true;
default:
return false;
}
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
}, },
}, },
watch: { watch: {
blobRaw() { blobRaw() {
<<<<<<< HEAD
if(this.isMarkdown()) { if(this.isMarkdown()) {
=======
const supported = this.supportedNonBinaryFileType();
if (supported) {
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
this.binaryTypes.markdown = true; this.binaryTypes.markdown = true;
this.activeFile.raw = false; this.activeFile.raw = false;
// counts as binaryish so we use the binary viewer in this case. // counts as binaryish so we use the binary viewer in this case.
this.binary = true; this.binary = true;
return; return;
} }
if(!this.binary) 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;
break; break;
} default:
} loadingError();
} break;
}
},
},
}); });
} }
} }
\ No newline at end of file
<<<<<<< HEAD
import Tabs from './repo_tabs' import Tabs from './repo_tabs'
import Sidebar from './repo_sidebar' import Sidebar from './repo_sidebar'
import Editor from './repo_editor' import Editor from './repo_editor'
...@@ -8,6 +9,16 @@ import CommitSection from './repo_commit_section' ...@@ -8,6 +9,16 @@ import CommitSection from './repo_commit_section'
import Service from './repo_service' import Service from './repo_service'
import Store from './repo_store' import Store from './repo_store'
import Helper from './repo_helper' import Helper from './repo_helper'
=======
import Tabs from './repo_tabs';
import Sidebar from './repo_sidebar';
import Editor from './repo_editor';
import FileButtons from './repo_file_buttons';
import BinaryViewer from './repo_binary_viewer';
import Service from './repo_service';
import Store from './repo_store';
import Helper from './repo_helper';
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
export default class RepoBundle { export default class RepoBundle {
constructor() { constructor() {
......
/* global monaco */ /* global monaco */
import Vue from 'vue'; import Vue from 'vue';
import Store from './repo_store' import Store from './repo_store';
import Helper from './repo_helper' import Helper from './repo_helper';
export default class RepoEditor { export default class RepoEditor {
constructor() { constructor() {
...@@ -10,12 +10,19 @@ export default class RepoEditor { ...@@ -10,12 +10,19 @@ export default class RepoEditor {
} }
addMonacoEvents() { addMonacoEvents() {
<<<<<<< HEAD
this.monacoEditor.onMouseUp(this.onMonacoEditorMouseUp.bind(this)); this.monacoEditor.onMouseUp(this.onMonacoEditorMouseUp.bind(this));
this.monacoEditor.onKeyUp(this.onMonacoEditorKeysPressed.bind(this)); this.monacoEditor.onKeyUp(this.onMonacoEditorKeysPressed.bind(this));
=======
this.vue.$watch('activeFile.lineNumber', () => {
console.log('cahnged');
});
this.monacoEditor.onMouseUp(RepoEditor.onMonacoEditorMouseUp);
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
} }
onMonacoEditorMouseUp(e) { static onMonacoEditorMouseUp(e) {
if(e.target.element.className === 'line-numbers') { if (e.target.element.className === 'line-numbers') {
location.hash = `L${e.target.position.lineNumber}`; location.hash = `L${e.target.position.lineNumber}`;
Store.activeLine = e.target.position.lineNumber; Store.activeLine = e.target.position.lineNumber;
} }
...@@ -34,7 +41,7 @@ export default class RepoEditor { ...@@ -34,7 +41,7 @@ export default class RepoEditor {
model: null, model: null,
readOnly: true, readOnly: true,
contextmenu: false, contextmenu: false,
} },
); );
Helper.monacoInstance = monaco; Helper.monacoInstance = monaco;
...@@ -49,33 +56,37 @@ export default class RepoEditor { ...@@ -49,33 +56,37 @@ export default class RepoEditor {
const monacoEditor = this.monacoEditor; const monacoEditor = this.monacoEditor;
this.vue = new Vue({ this.vue = new Vue({
data: () => Store, data: () => Store,
created () { created() {
this.showHide(); this.showHide();
if(this.blobRaw !== ''){ if (this.blobRaw !== '') {
monacoEditor.setModel( monacoEditor.setModel(
monaco.editor.createModel( monaco.editor.createModel(
this.blobRaw, this.blobRaw,
'plain' 'plain',
) ),
); );
} }
}, },
methods: { methods: {
showHide() { showHide() {
<<<<<<< HEAD
if(!this.openedFiles.length || (this.binary && !this.activeFile.raw)) { if(!this.openedFiles.length || (this.binary && !this.activeFile.raw)) {
=======
if ((!this.openedFiles.length) || this.binary) {
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
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: { watch: {
activeLine() { activeLine() {
self.monacoEditor.setPosition({ self.monacoEditor.setPosition({
lineNumber: this.activeLine, lineNumber: this.activeLine,
column: 1 column: 1,
}); });
}, },
...@@ -114,20 +125,24 @@ export default class RepoEditor { ...@@ -114,20 +125,24 @@ export default class RepoEditor {
blobRaw() { blobRaw() {
this.showHide(); this.showHide();
<<<<<<< HEAD
if(!this.isTree) { if(!this.isTree) {
// kill the current model; // kill the current model;
self.monacoEditor.setModel(null); self.monacoEditor.setModel(null);
// then create the new one // then create the new one
=======
if (!this.isTree) {
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
self.monacoEditor.setModel( self.monacoEditor.setModel(
monaco.editor.createModel( monaco.editor.createModel(
this.blobRaw, this.blobRaw,
this.activeFile.mime_type this.activeFile.mime_type,
) ),
); );
console.log(monaco.editor.getModels()); console.log(monaco.editor.getModels());
} }
} },
} },
}); });
} }
} }
\ No newline at end of file
let RepoFile = { const RepoFile = {
template: ` template: `
<tr v-if='!loading.tree || hasFiles' :class='{"active": activeFile.url === file.url}'> <tr v-if='!loading.tree || hasFiles' :class='{"active": activeFile.url === file.url}'>
<td> <td>
...@@ -20,13 +20,13 @@ let RepoFile = { ...@@ -20,13 +20,13 @@ let RepoFile = {
isMini: Boolean, isMini: Boolean,
loading: Object, loading: Object,
hasFiles: Boolean, hasFiles: Boolean,
activeFile: Object activeFile: Object,
}, },
methods: { methods: {
linkClicked(file) { linkClicked(file) {
this.$emit('linkclicked', file); this.$emit('linkclicked', file);
} },
} },
}; };
export default RepoFile; export default RepoFile;
<<<<<<< HEAD
import Vue from 'vue' import Vue from 'vue'
import Store from './repo_store' import Store from './repo_store'
import Helper from './repo_helper' import Helper from './repo_helper'
import RepoMiniMixin from './repo_mini_mixin' import RepoMiniMixin from './repo_mini_mixin'
=======
import Vue from 'vue';
import Store from './repo_store';
import Helper from './repo_helper';
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
export default class RepoSidebar { export default class RepoSidebar {
constructor(url) { constructor(url) {
...@@ -9,7 +15,7 @@ export default class RepoSidebar { ...@@ -9,7 +15,7 @@ export default class RepoSidebar {
this.initVue(); this.initVue();
this.el = document.getElementById('repo-file-buttons'); this.el = document.getElementById('repo-file-buttons');
} }
initVue() { initVue() {
this.vue = new Vue({ this.vue = new Vue({
el: '#repo-file-buttons', el: '#repo-file-buttons',
...@@ -31,16 +37,21 @@ export default class RepoSidebar { ...@@ -31,16 +37,21 @@ export default class RepoSidebar {
</div> </div>
`, `,
computed: { computed: {
<<<<<<< HEAD
editableBorder() { editableBorder() {
return this.editMode ? '1px solid #1F78D1' :'1px solid #f0f0f0'; return this.editMode ? '1px solid #1F78D1' :'1px solid #f0f0f0';
=======
previewLabel() {
return this.activeFile.raw ? 'Preview' : 'Raw';
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
}, },
canPreview() { canPreview() {
return this.activeFile.extension === 'md'; return this.activeFile.extension === 'md';
}, },
rawFileURL() { rawFileURL() {
return Helper.getRawURLFromBlobURL(this.activeFile.url); return Helper.getRawURLFromBlobURL(this.activeFile.url);
}, },
...@@ -50,14 +61,20 @@ export default class RepoSidebar { ...@@ -50,14 +61,20 @@ export default class RepoSidebar {
historyFileUrl() { historyFileUrl() {
return Helper.getHistoryURLFromBlobURL(this.activeFile.url); return Helper.getHistoryURLFromBlobURL(this.activeFile.url);
} },
}, },
methods: { methods: {
<<<<<<< HEAD
rawPreviewToggle() { rawPreviewToggle() {
Helper.setCurrentFileRawOrPreview(); Helper.setCurrentFileRawOrPreview();
} }
=======
setRawPreviewMode() {
},
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
}, },
}); });
} }
} }
\ No newline at end of file
let RepoFileOptions = { const RepoFileOptions = {
template: ` template: `
<tr v-if='isMini' class='repo-file-options'> <tr v-if='isMini' class='repo-file-options'>
<td> <td>
...@@ -21,8 +21,8 @@ let RepoFileOptions = { ...@@ -21,8 +21,8 @@ let RepoFileOptions = {
props: { props: {
name: 'repo-file-options', name: 'repo-file-options',
isMini: Boolean, isMini: Boolean,
projectName: String projectName: String,
} },
} };
export default RepoFileOptions; export default RepoFileOptions;
\ No newline at end of file
This diff is collapsed.
let RepoLoadingFile = { const RepoLoadingFile = {
template: ` template: `
<tr v-if='loading.tree && !hasFiles'> <tr v-if='loading.tree && !hasFiles'>
<td> <td>
...@@ -18,17 +18,17 @@ let RepoLoadingFile = { ...@@ -18,17 +18,17 @@ let RepoLoadingFile = {
</td> </td>
</tr> </tr>
`, `,
methods: { methods: {
lineOfCode(n) { lineOfCode(n) {
return `line-of-code-${n}`; return `line-of-code-${n}`;
} },
}, },
props: { props: {
loading: Object, loading: Object,
hasFiles: Boolean, hasFiles: Boolean,
isMini: Boolean isMini: Boolean,
} },
}; };
export default RepoLoadingFile; export default RepoLoadingFile;
\ No newline at end of file
import Store from './repo_store' import Store from './repo_store';
let RepoMiniMixin = { const RepoMiniMixin = {
computed: { computed: {
isMini() { isMini() {
return !!Store.openedFiles.length; return !!Store.openedFiles.length;
} },
}, },
}; };
export default RepoMiniMixin; export default RepoMiniMixin;
\ No newline at end of file
let RepoPreviousDirectory = { const RepoPreviousDirectory = {
template: ` template: `
<tr> <tr>
<td colspan='3'> <td colspan='3'>
...@@ -8,13 +8,13 @@ let RepoPreviousDirectory = { ...@@ -8,13 +8,13 @@ let RepoPreviousDirectory = {
`, `,
props: { props: {
name: 'repo-previous-directory', name: 'repo-previous-directory',
prevUrl: String prevUrl: String,
}, },
methods: { methods: {
linkClicked(file) { linkClicked(file) {
this.$emit('linkclicked', file); this.$emit('linkclicked', file);
} },
} },
}; };
export default RepoPreviousDirectory; export default RepoPreviousDirectory;
\ No newline at end of file
import axios from 'axios'; import axios from 'axios';
let RepoService = { const RepoService = {
url: '', url: '',
params: { params: {
params: { params: {
format: 'json' format: 'json',
} },
}, },
setUrl(url) { setUrl(url) {
...@@ -14,16 +14,16 @@ let RepoService = { ...@@ -14,16 +14,16 @@ let RepoService = {
paramsWithRich(url) { paramsWithRich(url) {
// copy the obj so we don't modify perm. // copy the obj so we don't modify perm.
let params = JSON.parse(JSON.stringify(this.params)); const params = JSON.parse(JSON.stringify(this.params));
if(url.substr(url.length-2) === 'md') { if (url.substr(url.length - 2) === 'md') {
params.params.viewer = 'rich'; params.params.viewer = 'rich';
} }
return params; return params;
}, },
getContent(url) { getContent(url) {
if(url){ if (url) {
return axios.get(url, this.paramsWithRich(url, params)); return axios.get(url, this.paramsWithRich(url, this.params));
} }
return axios.get(this.url, this.paramsWithRich(this.url, this.params)); return axios.get(this.url, this.paramsWithRich(this.url, this.params));
}, },
...@@ -31,10 +31,10 @@ let RepoService = { ...@@ -31,10 +31,10 @@ let RepoService = {
getBase64Content(url) { getBase64Content(url) {
return axios return axios
.get(url, { .get(url, {
responseType: 'arraybuffer' responseType: 'arraybuffer',
}) })
.then(response => new Buffer(response.data, 'binary').toString('base64')) .then(response => new Buffer(response.data, 'binary').toString('base64'));
} },
}; };
export default RepoService; export default RepoService;
\ No newline at end of file
import Service from './repo_service' import Vue from 'vue';
import Helper from './repo_helper' import Service from './repo_service';
import Vue from 'vue' import Helper from './repo_helper';
import Store from './repo_store' import Store from './repo_store';
import RepoPreviousDirectory from './repo_prev_directory' import RepoPreviousDirectory from './repo_prev_directory';
import RepoFileOptions from './repo_file_options' import RepoFileOptions from './repo_file_options';
import RepoFile from './repo_file' import RepoFile from './repo_file';
import RepoLoadingFile from './repo_loading_file' import RepoLoadingFile from './repo_loading_file';
import RepoMiniMixin from './repo_mini_mixin' import RepoMiniMixin from './repo_mini_mixin';
export default class RepoSidebar { export default class RepoSidebar {
constructor(url) { constructor(url) {
...@@ -35,32 +35,38 @@ export default class RepoSidebar { ...@@ -35,32 +35,38 @@ export default class RepoSidebar {
methods: { methods: {
addPopEventListener() { addPopEventListener() {
window.addEventListener('popstate', () => { window.addEventListener('popstate', () => {
if(location.href.indexOf('#') > -1) return; if (location.href.indexOf('#') > -1) return;
this.linkClicked({ this.linkClicked({
url: location.href url: location.href,
}); });
}); });
}, },
linkClicked(file) { linkClicked(file) {
let url = ''; let url = '';
if(typeof file === 'object') { if (typeof file === 'object') {
if(file.type === 'tree' && file.opened) { if (file.type === 'tree' && file.opened) {
Helper.removeChildFilesOfTree(file); Helper.removeChildFilesOfTree(file);
<<<<<<< HEAD
return; return;
} else { } else {
url = file.url; url = file.url;
Service.url = url; Service.url = url;
Helper.getContent(file); Helper.getContent(file);
=======
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
} }
} else if(typeof file === 'string') { url = file.url;
Service.url = url;
Helper.getContent(file);
} else if (typeof file === 'string') {
// go back // go back
url = file; url = file;
Service.url = url; Service.url = url;
Helper.getContent(); Helper.getContent();
} }
} },
}, },
}); });
} }
} }
\ No newline at end of file
let RepoStore = { const RepoStore = {
service: '', service: '',
editor: '', editor: '',
sidebar: '', sidebar: '',
...@@ -22,9 +22,12 @@ let RepoStore = { ...@@ -22,9 +22,12 @@ let RepoStore = {
plain: '', plain: '',
size: 0, size: 0,
url: '', url: '',
<<<<<<< HEAD
raw: false, raw: false,
newContent: '', newContent: '',
changed: false changed: false
=======
>>>>>>> 51a936fb3d2cdbd133a3b0eed463b47c1c92fe7d
}, },
activeFileIndex: 0, activeFileIndex: 0,
activeLine: 0, activeLine: 0,
...@@ -32,15 +35,15 @@ let RepoStore = { ...@@ -32,15 +35,15 @@ let RepoStore = {
files: [], files: [],
binary: false, binary: false,
binaryMimeType: '', binaryMimeType: '',
//scroll bar space for windows // scroll bar space for windows
scrollWidth: 0, scrollWidth: 0,
binaryTypes: { binaryTypes: {
png: false, png: false,
markdown: false markdown: false,
}, },
loading: { loading: {
tree: false, tree: false,
blob: false blob: false,
} },
}; };
export default RepoStore; export default RepoStore;
import RepoHelper from './repo_helper' import RepoHelper from './repo_helper';
let RepoTab = { const RepoTab = {
template: ` template: `
<li> <li>
<a href='#' @click.prevent='xClicked(tab)' v-if='!tab.loading'> <a href='#' @click.prevent='xClicked(tab)' v-if='!tab.loading'>
...@@ -34,7 +34,7 @@ let RepoTab = { ...@@ -34,7 +34,7 @@ let RepoTab = {
xClicked(file) { xClicked(file) {
if(file.changed) return; if(file.changed) return;
RepoHelper.removeFromOpenedFiles(file); RepoHelper.removeFromOpenedFiles(file);
} },
} },
}; };
export default RepoTab; export default RepoTab;
\ No newline at end of file
import Vue from 'vue'; import Vue from 'vue';
import Store from './repo_store' import Store from './repo_store';
import RepoTab from './repo_tab' import RepoTab from './repo_tab';
import RepoMiniMixin from './repo_mini_mixin' import RepoMiniMixin from './repo_mini_mixin';
export default class RepoTabs { export default class RepoTabs {
constructor() { constructor() {
this.styleTabsForWindows(); RepoTabs.styleTabsForWindows();
this.initVue(); this.initVue();
} }
...@@ -20,8 +20,8 @@ export default class RepoTabs { ...@@ -20,8 +20,8 @@ export default class RepoTabs {
}); });
} }
styleTabsForWindows() { static styleTabsForWindows() {
const scrollWidth = Number(document.body.dataset.scrollWidth); const scrollWidth = Number(document.body.dataset.scrollWidth);
Store.scrollWidth = scrollWidth; Store.scrollWidth = scrollWidth;
} }
} }
\ No newline at end of file
import Vue from 'vue';
import Store from './repo_store';
export default class RepoViewToggler {
constructor() {
this.initVue();
}
initVue() {
this.vue = new Vue({
el: '#view-toggler',
data: () => Store,
});
}
}
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