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