BigW Consortium Gitlab

Commit 8a9375e9 by Jacob Schatz

Merge 'ide' gitlab-ce into ide and fixes conflicts.

parents 54fa71d2 31480210
...@@ -16,15 +16,20 @@ export default class RepoFileButtons { ...@@ -16,15 +16,20 @@ export default class RepoFileButtons {
template: ` template: `
<div id='repo-file-buttons' v-if='isMini' :style='{"border-bottom": editableBorder}'> <div id='repo-file-buttons' v-if='isMini' :style='{"border-bottom": editableBorder}'>
<a :href='rawFileURL' target='_blank' class='btn btn-default'>Raw</a> <a :href='rawFileURL' target='_blank' class='btn btn-default'>Raw</a>
<div class="btn-group" role="group" aria-label="File actions"> <div class="btn-group" role="group" aria-label="File actions">
<a :href='blameFileUrl' class='btn btn-default'>Blame</a> <a :href='blameFileUrl' class='btn btn-default'>Blame</a>
<a :href='historyFileUrl' class='btn btn-default'>History</a> <a :href='historyFileUrl' class='btn btn-default'>History</a>
<a href='#' class='btn btn-default'>Permalink</a> <a href='#' class='btn btn-default'>Permalink</a>
<a href='#' class='btn btn-default'>Lock</a> <a href='#' class='btn btn-default'>Lock</a>
</div> </div>
<a href='#' v-if='canPreview' @click.prevent='rawPreviewToggle' class='btn btn-default'> <a href='#' v-if='canPreview' @click.prevent='rawPreviewToggle' class='btn btn-default'>
{{activeFileLabel}} {{activeFileLabel}}
</a> </a>
<button type="button" class="btn btn-default" data-target="#modal-upload-blob" data-toggle="modal">Replace</button>
<a href='#' class='btn btn-danger'>Delete</a> <a href='#' class='btn btn-danger'>Delete</a>
</div> </div>
`, `,
......
...@@ -17,7 +17,7 @@ const RepoHelper = { ...@@ -17,7 +17,7 @@ const RepoHelper = {
getLanguageIDForFile(file, langs) { getLanguageIDForFile(file, langs) {
const ext = file.name.split('.').pop(); const ext = file.name.split('.').pop();
const foundLang = this.findLanguage(ext, langs); const foundLang = RepoHelper.findLanguage(ext, langs);
return foundLang ? foundLang.id : 'plaintext'; return foundLang ? foundLang.id : 'plaintext';
}, },
...@@ -53,7 +53,7 @@ const RepoHelper = { ...@@ -53,7 +53,7 @@ const RepoHelper = {
Store.blobRaw = response; Store.blobRaw = response;
file.base64 = response; // eslint-disable-line no-param-reassign file.base64 = response; // eslint-disable-line no-param-reassign
}) })
.catch(this.loadingError); .catch(RepoHelper.loadingError);
}, },
toggleFakeTab(loading, file) { toggleFakeTab(loading, file) {
...@@ -64,7 +64,7 @@ const RepoHelper = { ...@@ -64,7 +64,7 @@ const RepoHelper = {
setLoading(loading, file) { setLoading(loading, file) {
if (Service.url.indexOf('blob') > -1) { if (Service.url.indexOf('blob') > -1) {
Store.loading.blob = loading; Store.loading.blob = loading;
return this.toggleFakeTab(loading, file); return RepoHelper.toggleFakeTab(loading, file);
} }
if (Service.url.indexOf('tree') > -1) Store.loading.tree = loading; if (Service.url.indexOf('tree') > -1) Store.loading.tree = loading;
...@@ -79,15 +79,16 @@ const RepoHelper = { ...@@ -79,15 +79,16 @@ const RepoHelper = {
if (!indexOfFile) return newList; if (!indexOfFile) return newList;
return this.mergeNewListToOldList(newList, currentList, inDirectory, indexOfFile); return RepoHelper.mergeNewListToOldList(newList, currentList, inDirectory, indexOfFile);
}, },
mergeNewListToOldList(newList, oldList, inDirectory, indexOfFile) { mergeNewListToOldList(newList, oldList, inDirectory, indexOfFile) {
newList.forEach((newFile) => { newList.forEach((newFile) => {
const fileIndex = indexOfFile + 1;
const file = newFile; const file = newFile;
file.level = inDirectory.level + 1; file.level = inDirectory.level + 1;
oldList.splice(indexOfFile, 0, file); oldList.splice(fileIndex, 0, file);
}); });
return oldList; return oldList;
...@@ -95,21 +96,21 @@ const RepoHelper = { ...@@ -95,21 +96,21 @@ const RepoHelper = {
getContent(treeOrFile) { getContent(treeOrFile) {
let file = treeOrFile; let file = treeOrFile;
const loadingData = this.setLoading(true); const loadingData = RepoHelper.setLoading(true);
Service.getContent() Service.getContent()
.then((response) => { .then((response) => {
const data = response.data; const data = response.data;
this.setLoading(false, loadingData); RepoHelper.setLoading(false, loadingData);
Store.isTree = this.isTree(data); Store.isTree = RepoHelper.isTree(data);
if (!Store.isTree) { if (!Store.isTree) {
if (!file) file = data; if (!file) file = data;
Store.binary = data.binary; Store.binary = data.binary;
if (data.binary) { if (data.binary) {
Store.binaryMimeType = data.mime_type; Store.binaryMimeType = data.mime_type;
const rawUrl = this.getRawURLFromBlobURL(file.url); const rawUrl = RepoHelper.getRawURLFromBlobURL(file.url);
this.setBinaryDataAsBase64(rawUrl, data); RepoHelper.setBinaryDataAsBase64(rawUrl, data);
data.binary = true; data.binary = true;
} else { } else {
Store.blobRaw = data.plain; Store.blobRaw = data.plain;
...@@ -128,19 +129,19 @@ const RepoHelper = { ...@@ -128,19 +129,19 @@ const RepoHelper = {
if (Store.files.length === 0) { if (Store.files.length === 0) {
const parentURL = Service.blobURLtoParentTree(Service.url); const parentURL = Service.blobURLtoParentTree(Service.url);
Service.url = parentURL; Service.url = parentURL;
this.getContent(); RepoHelper.getContent();
} }
} else { } else {
// it's a tree // it's a tree
file = this.setDirectoryOpen(file); file = RepoHelper.setDirectoryOpen(file);
const newDirectory = this.dataToListOfFiles(data); const newDirectory = RepoHelper.dataToListOfFiles(data);
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(() => { .catch(() => {
this.setLoading(false, loadingData); RepoHelper.setLoading(false, loadingData);
this.loadingError(); RepoHelper.loadingError();
}); });
}, },
...@@ -149,7 +150,7 @@ const RepoHelper = { ...@@ -149,7 +150,7 @@ const RepoHelper = {
}, },
serializeBlob(blob) { serializeBlob(blob) {
const simpleBlob = this.serializeRepoEntity('blob', blob); const simpleBlob = RepoHelper.serializeRepoEntity('blob', blob);
simpleBlob.lastCommitMessage = blob.last_commit.message; simpleBlob.lastCommitMessage = blob.last_commit.message;
simpleBlob.lastCommitUpdate = blob.last_commit.committed_date; simpleBlob.lastCommitUpdate = blob.last_commit.committed_date;
...@@ -157,11 +158,11 @@ const RepoHelper = { ...@@ -157,11 +158,11 @@ const RepoHelper = {
}, },
serializeTree(tree) { serializeTree(tree) {
return this.serializeRepoEntity('tree', tree); return RepoHelper.serializeRepoEntity('tree', tree);
}, },
serializeSubmodule(submodule) { serializeSubmodule(submodule) {
return this.serializeRepoEntity('submodule', submodule); return RepoHelper.serializeRepoEntity('submodule', submodule);
}, },
serializeRepoEntity(type, entity) { serializeRepoEntity(type, entity) {
...@@ -171,7 +172,7 @@ const RepoHelper = { ...@@ -171,7 +172,7 @@ const RepoHelper = {
type, type,
name, name,
url, url,
icon: this.toFA(icon), icon: RepoHelper.toFA(icon),
level: 0, level: 0,
}; };
}, },
...@@ -181,38 +182,38 @@ const RepoHelper = { ...@@ -181,38 +182,38 @@ const RepoHelper = {
// push in blobs // push in blobs
data.blobs.forEach((blob) => { data.blobs.forEach((blob) => {
a.push(this.serializeBlob(blob)); a.push(RepoHelper.serializeBlob(blob));
}); });
data.trees.forEach((tree) => { data.trees.forEach((tree) => {
a.push(this.serializeTree(tree)); a.push(RepoHelper.serializeTree(tree));
}); });
data.submodules.forEach((submodule) => { data.submodules.forEach((submodule) => {
a.push(this.serializeSubmodule(submodule)); a.push(RepoHelper.serializeSubmodule(submodule));
}); });
return a; return a;
}, },
genKey() { genKey() {
return this.Time.now().toFixed(3); return RepoHelper.Time.now().toFixed(3);
}, },
getStateKey() { getStateKey() {
return this.key; return RepoHelper.key;
}, },
setStateKey(key) { setStateKey(key) {
this.key = key; RepoHelper.key = key;
}, },
toURL(url) { toURL(url) {
const history = window.history; const history = window.history;
this.key = this.genKey(); RepoHelper.key = RepoHelper.genKey();
history.pushState({ key: this.key }, '', url); history.pushState({ key: RepoHelper.key }, '', url);
}, },
loadingError() { loadingError() {
......
...@@ -40,15 +40,17 @@ export default class RepoSidebar { ...@@ -40,15 +40,17 @@ export default class RepoSidebar {
}); });
}, },
linkClicked(file) { linkClicked(clickedFile) {
let url = ''; let url = '';
let file = clickedFile;
if (typeof file === 'object') { if (typeof file === 'object') {
if (file.type === 'tree' && file.opened) { if (file.type === 'tree' && file.opened) {
file = Store.removeChildFilesOfTree(file); file = Store.removeChildFilesOfTree(file);
} else {
url = file.url;
Service.url = url;
Helper.getContent(file);
} }
url = file.url;
Service.url = url;
Helper.getContent(file);
} else if (typeof file === 'string') { } else if (typeof file === 'string') {
// go back // go back
url = file; url = file;
......
...@@ -50,55 +50,56 @@ const RepoStore = { ...@@ -50,55 +50,56 @@ const RepoStore = {
// mutations // mutations
addFilesToDirectory(inDirectory, currentList, newList) { addFilesToDirectory(inDirectory, currentList, newList) {
this.files = RepoHelper.getNewMergedList(inDirectory, currentList, newList); RepoStore.files = RepoHelper.getNewMergedList(inDirectory, currentList, newList);
}, },
toggleRawPreview() { toggleRawPreview() {
this.activeFile.raw = !this.activeFile.raw; RepoStore.activeFile.raw = !RepoStore.activeFile.raw;
this.activeFileLabel = this.activeFile.raw ? 'Display rendered file' : 'Display source'; RepoStore.activeFileLabel = RepoStore.activeFile.raw ? 'Display rendered file' : 'Display source';
}, },
setActiveFiles(file) { setActiveFiles(file) {
if (this.isActiveFile(file)) return; if (RepoStore.isActiveFile(file)) return;
this.openedFiles = this.openedFiles.map((openedFile, i) => this.setFileToActive(openedFile, i)); RepoStore.openedFiles = RepoStore.openedFiles
.map((openedFile, i) => RepoStore.w(openedFile, i));
this.setActiveToRaw(); RepoStore.setActiveToRaw();
if (file.binary) { if (file.binary) {
this.blobRaw = file.base64; RepoStore.blobRaw = file.base64;
} else { } else {
this.blobRaw = file.plain; RepoStore.blobRaw = file.plain;
} }
if (!file.loading) RepoHelper.toURL(file.url); if (!file.loading) RepoHelper.toURL(file.url);
this.binary = file.binary; RepoStore.binary = file.binary;
}, },
setFileToActive(file, i) { w(file, i) {
const activeFile = file; const activeFile = file;
activeFile.active = activeFile.url === activeFile.url; activeFile.active = activeFile.url === activeFile.url;
if (activeFile.active) this.setActiveFile(activeFile, i); if (activeFile.active) RepoStore.setActiveFile(activeFile, i);
return activeFile; return activeFile;
}, },
setActiveFile(activeFile, i) { setActiveFile(activeFile, i) {
this.activeFile = activeFile; RepoStore.activeFile = activeFile;
this.activeFileIndex = i; RepoStore.activeFileIndex = i;
}, },
setActiveToRaw() { setActiveToRaw() {
this.activeFile.raw = false; RepoStore.activeFile.raw = false;
// can't get vue to listen to raw for some reason so this for now. // can't get vue to listen to raw for some reason so RepoStore for now.
this.activeFileLabel = 'Display source'; RepoStore.activeFileLabel = 'Display source';
}, },
removeChildFilesOfTree(tree) { removeChildFilesOfTree(tree) {
let foundTree = false; let foundTree = false;
let treetoClose = tree; const treetoClose = tree;
this.files = this.files.filter((file) => { RepoStore.files = RepoStore.files.filter((file) => {
if (file.url === treetoClose.url) foundTree = true; if (file.url === treetoClose.url) foundTree = true;
if (foundTree) return file.level <= treetoClose.level; if (foundTree) return file.level <= treetoClose.level;
...@@ -113,7 +114,7 @@ const RepoStore = { ...@@ -113,7 +114,7 @@ const RepoStore = {
removeFromOpenedFiles(file) { removeFromOpenedFiles(file) {
if (file.type === 'tree') return; if (file.type === 'tree') return;
this.openedFiles = this.openedFiles.filter(openedFile => openedFile.url !== file.url); RepoStore.openedFiles = RepoStore.openedFiles.filter(openedFile => openedFile.url !== file.url);
}, },
addPlaceholderFile() { addPlaceholderFile() {
...@@ -128,7 +129,7 @@ const RepoStore = { ...@@ -128,7 +129,7 @@ const RepoStore = {
url: randomURL, url: randomURL,
}; };
this.openedFiles.push(newFakeFile); RepoStore.openedFiles.push(newFakeFile);
return newFakeFile; return newFakeFile;
}, },
...@@ -136,27 +137,27 @@ const RepoStore = { ...@@ -136,27 +137,27 @@ const RepoStore = {
addToOpenedFiles(file) { addToOpenedFiles(file) {
const openFile = file; const openFile = file;
const openedFilesAlreadyExists = this.openedFiles const openedFilesAlreadyExists = RepoStore.openedFiles
.some(openedFile => openedFile.url === openFile.url); .some(openedFile => openedFile.url === openFile.url);
if (openedFilesAlreadyExists) return; if (openedFilesAlreadyExists) return;
openFile.changed = false; openFile.changed = false;
this.openedFiles.push(openFile); RepoStore.openedFiles.push(openFile);
}, },
setActiveFileContents(contents) { setActiveFileContents(contents) {
if (!this.editMode) return; if (!RepoStore.editMode) return;
this.activeFile.newContent = contents; RepoStore.activeFile.newContent = contents;
this.activeFile.changed = this.activeFile.plain !== this.activeFile.newContent; RepoStore.activeFile.changed = RepoStore.activeFile.plain !== RepoStore.activeFile.newContent;
this.openedFiles[this.activeFileIndex].changed = this.activeFile.changed; RepoStore.openedFiles[RepoStore.activeFileIndex].changed = RepoStore.activeFile.changed;
}, },
// getters // getters
isActiveFile(file) { isActiveFile(file) {
return file && file.url === this.activeFile.url; return file && file.url === RepoStore.activeFile.url;
}, },
}; };
export default RepoStore; export default RepoStore;
...@@ -20,7 +20,7 @@ const RepoTab = { ...@@ -20,7 +20,7 @@ const RepoTab = {
}, },
methods: { methods: {
tabClicked: RepoStore.setActiveFiles.bind(RepoStore), tabClicked: RepoStore.setActiveFiles,
xClicked(file) { xClicked(file) {
if (file.changed) return; if (file.changed) return;
......
...@@ -212,10 +212,11 @@ var config = { ...@@ -212,10 +212,11 @@ var config = {
from: path.join(ROOT_PATH, `node_modules/monaco-editor/${IS_PRODUCTION ? 'min' : 'dev'}/vs`), from: path.join(ROOT_PATH, `node_modules/monaco-editor/${IS_PRODUCTION ? 'min' : 'dev'}/vs`),
to: 'monaco-editor/vs', to: 'monaco-editor/vs',
transform: function(content, path) { transform: function(content, path) {
if (/\.js$/.test(path) && !/workerMain/.test(path)) { if (/\.js$/.test(path) && !/worker/i.test(path)) {
return ( return (
'(function(){\n' + '(function(){\n' +
'var define = this.define, require = this.require;\n' + 'var define = this.define, require = this.require;\n' +
'window.define = define; window.require = require;\n' +
content + content +
'\n}.call(window.__monaco_context__ || (window.__monaco_context__ = {})));' '\n}.call(window.__monaco_context__ || (window.__monaco_context__ = {})));'
); );
......
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