BigW Consortium Gitlab

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

parents 31afd42e 71d08bfb
......@@ -23,13 +23,14 @@ function initRepo() {
Store.checkIsCommitable();
Store.projectId = repo.dataset.projectId;
Store.tempPrivateToken = repo.dataset.tempToken;
Store.projectUrl = repo.dataset.projectUrl;
this.vm = new Vue({
el: repo,
data: () => Store,
template: `
<div class="tree-content-holder">
<repo-sidebar/><div class="panel-right" :class="{'edit-mode': readOnly}">
<repo-sidebar/><div class="panel-right" :class="{'edit-mode': editMode}">
<repo-tabs/>
<repo-file-buttons/>
<repo-editor/>
......
......@@ -13,12 +13,10 @@ const RepoBinaryViewer = {
methods: {
errored() {
console.log('errored');
Store.binaryLoaded = false;
},
loaded() {
console.log('loaded');
Store.binaryLoaded = true;
},
......@@ -39,7 +37,6 @@ const RepoBinaryViewer = {
if (!this.binary) return;
switch (this.binaryMimeType) {
case 'image/png':
console.log('png bitch')
this.binaryTypes.png = true;
break;
default:
......
......@@ -65,6 +65,7 @@ const RepoEditor = {
},
editMode() {
console.log('edit mode changed')
const readOnly = !this.editMode;
Store.readOnly = readOnly;
......
......@@ -4,6 +4,24 @@ import Store from './repo_store';
import '../flash';
const RepoHelper = {
getDefaultActiveFile() {
return {
active: true,
binary: false,
extension: '',
html: '',
mime_type: '',
name: 'loading...',
plain: '',
size: 0,
url: '',
raw: false,
newContent: '',
changed: false,
loading: false,
}
},
key: '',
isTree(data) {
......@@ -100,8 +118,24 @@ const RepoHelper = {
return 0;
},
isRoot(url) {
// the url we are requesting -> split by the project URL. Grab the right side.
const isRoot = !!url.split(Store.projectUrl)[1]
// remove the first "/"
.slice(1)
// split this by "/"
.split('/')
// remove the first two items of the array... usually /tree/master.
.slice(2)
// we want to know the length of the array.
// If greater than 0 not root.
.length;
return isRoot;
},
getContent(treeOrFile, cb) {
let file = treeOrFile;
console.log('file',file)
// const loadingData = RepoHelper.setLoading(true);
return Service.getContent()
.then((response) => {
......@@ -115,7 +149,8 @@ const RepoHelper = {
if (data.binary) {
Store.binaryMimeType = data.mime_type;
const rawUrl = RepoHelper.getRawURLFromBlobURL(file.url);
// file might be undefined
const rawUrl = RepoHelper.getRawURLFromBlobURL(file.url || Service.url);
RepoHelper.setBinaryDataAsBase64(rawUrl, data);
data.binary = true;
} else {
......@@ -139,13 +174,14 @@ const RepoHelper = {
}
} else {
// it's a tree
if(!file) Store.isRoot = RepoHelper.isRoot(Service.url);
file = RepoHelper.setDirectoryOpen(file);
const newDirectory = RepoHelper.dataToListOfFiles(data);
Store.addFilesToDirectory(file, Store.files, newDirectory);
Store.prevURL = Service.blobURLtoParentTree(Service.url);
}
})
.catch(() => {
.catch((e) => {
// RepoHelper.setLoading(false, loadingData);
RepoHelper.loadingError();
});
......
......@@ -82,6 +82,7 @@ export default RepoSidebar;
:is-mini="isMini"
:project-name="projectName"/>
<repo-previous-directory
v-if="isRoot"
:prev-url="prevURL"
@linkclicked="linkClicked(prevURL)"/>
<repo-loading-file
......
......@@ -11,9 +11,11 @@ const RepoStore = {
editButton: '',
editMode: false,
isTree: false,
isRoot: false,
prevURL: '',
projectId: '',
projectName: '',
projectUrl: '',
trees: [],
blobs: [],
submodules: [],
......@@ -27,21 +29,7 @@ const RepoStore = {
tempPrivateToken: '',
submitCommitsLoading: false,
binaryLoaded:false,
activeFile: {
active: true,
binary: false,
extension: '',
html: '',
mime_type: '',
name: 'loading...',
plain: '',
size: 0,
url: '',
raw: false,
newContent: '',
changed: false,
loading: false,
},
activeFile: RepoHelper.getDefaultActiveFile(),
activeFileIndex: 0,
activeLine: 0,
activeFileLabel: 'Raw',
......@@ -64,7 +52,6 @@ const RepoStore = {
readOnly: true,
// mutations
checkIsCommitable() {
RepoStore.service.checkCurrentBranchIsCommitable()
.then((data) => {
......@@ -87,7 +74,6 @@ const RepoStore = {
setActiveFiles(file) {
if (RepoStore.isActiveFile(file)) return;
RepoStore.openedFiles = RepoStore.openedFiles
.map((openedFile, i) => RepoStore.setFileActivity(file, openedFile, i));
......@@ -149,8 +135,29 @@ const RepoStore = {
removeFromOpenedFiles(file) {
if (file.type === 'tree') return;
let foundIndex;
RepoStore.openedFiles = RepoStore.openedFiles.filter((openedFile, i) => {
if(openedFile.url === file.url) foundIndex = i;
return openedFile.url !== file.url;
});
RepoStore.openedFiles = RepoStore.openedFiles.filter(openedFile => openedFile.url !== file.url);
// now activate the right tab based on what you closed.
if(RepoStore.openedFiles.length === 0) {
console.log('open 0')
RepoStore.activeFile = {};
return;
}
if(RepoStore.openedFiles.length === 1 || foundIndex === 0) {
RepoStore.setActiveFiles(RepoStore.openedFiles[0]);
return;
}
if(foundIndex) {
if(foundIndex > 0) {
RepoStore.setActiveFiles(RepoStore.openedFiles[foundIndex - 1]);
}
}
},
addPlaceholderFile() {
......
......@@ -100,6 +100,7 @@
&.close {
width: auto;
font-size: 15px;
opacity: 1;
}
}
......@@ -110,6 +111,10 @@
margin-left: 15px;
color: $gray-darkest;
}
i.fa.fa-circle {
color: $brand-success;
}
}
}
......
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