Commit e58d30a0 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

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

parents 31afd42e 71d08bfb
...@@ -23,13 +23,14 @@ function initRepo() { ...@@ -23,13 +23,14 @@ function initRepo() {
Store.checkIsCommitable(); Store.checkIsCommitable();
Store.projectId = repo.dataset.projectId; Store.projectId = repo.dataset.projectId;
Store.tempPrivateToken = repo.dataset.tempToken; Store.tempPrivateToken = repo.dataset.tempToken;
Store.projectUrl = repo.dataset.projectUrl;
this.vm = new Vue({ this.vm = new Vue({
el: repo, el: repo,
data: () => Store, data: () => Store,
template: ` template: `
<div class="tree-content-holder"> <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-tabs/>
<repo-file-buttons/> <repo-file-buttons/>
<repo-editor/> <repo-editor/>
......
...@@ -13,12 +13,10 @@ const RepoBinaryViewer = { ...@@ -13,12 +13,10 @@ const RepoBinaryViewer = {
methods: { methods: {
errored() { errored() {
console.log('errored');
Store.binaryLoaded = false; Store.binaryLoaded = false;
}, },
loaded() { loaded() {
console.log('loaded');
Store.binaryLoaded = true; Store.binaryLoaded = true;
}, },
...@@ -39,7 +37,6 @@ const RepoBinaryViewer = { ...@@ -39,7 +37,6 @@ const RepoBinaryViewer = {
if (!this.binary) return; if (!this.binary) return;
switch (this.binaryMimeType) { switch (this.binaryMimeType) {
case 'image/png': case 'image/png':
console.log('png bitch')
this.binaryTypes.png = true; this.binaryTypes.png = true;
break; break;
default: default:
......
...@@ -65,6 +65,7 @@ const RepoEditor = { ...@@ -65,6 +65,7 @@ const RepoEditor = {
}, },
editMode() { editMode() {
console.log('edit mode changed')
const readOnly = !this.editMode; const readOnly = !this.editMode;
Store.readOnly = readOnly; Store.readOnly = readOnly;
......
...@@ -4,6 +4,24 @@ import Store from './repo_store'; ...@@ -4,6 +4,24 @@ import Store from './repo_store';
import '../flash'; import '../flash';
const RepoHelper = { 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: '', key: '',
isTree(data) { isTree(data) {
...@@ -100,8 +118,24 @@ const RepoHelper = { ...@@ -100,8 +118,24 @@ const RepoHelper = {
return 0; 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) { getContent(treeOrFile, cb) {
let file = treeOrFile; let file = treeOrFile;
console.log('file',file)
// const loadingData = RepoHelper.setLoading(true); // const loadingData = RepoHelper.setLoading(true);
return Service.getContent() return Service.getContent()
.then((response) => { .then((response) => {
...@@ -115,7 +149,8 @@ const RepoHelper = { ...@@ -115,7 +149,8 @@ const RepoHelper = {
if (data.binary) { if (data.binary) {
Store.binaryMimeType = data.mime_type; 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); RepoHelper.setBinaryDataAsBase64(rawUrl, data);
data.binary = true; data.binary = true;
} else { } else {
...@@ -139,13 +174,14 @@ const RepoHelper = { ...@@ -139,13 +174,14 @@ const RepoHelper = {
} }
} else { } else {
// it's a tree // it's a tree
if(!file) Store.isRoot = RepoHelper.isRoot(Service.url);
file = RepoHelper.setDirectoryOpen(file); file = RepoHelper.setDirectoryOpen(file);
const newDirectory = RepoHelper.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((e) => {
// RepoHelper.setLoading(false, loadingData); // RepoHelper.setLoading(false, loadingData);
RepoHelper.loadingError(); RepoHelper.loadingError();
}); });
......
...@@ -82,6 +82,7 @@ export default RepoSidebar; ...@@ -82,6 +82,7 @@ export default RepoSidebar;
:is-mini="isMini" :is-mini="isMini"
:project-name="projectName"/> :project-name="projectName"/>
<repo-previous-directory <repo-previous-directory
v-if="isRoot"
:prev-url="prevURL" :prev-url="prevURL"
@linkclicked="linkClicked(prevURL)"/> @linkclicked="linkClicked(prevURL)"/>
<repo-loading-file <repo-loading-file
......
...@@ -11,9 +11,11 @@ const RepoStore = { ...@@ -11,9 +11,11 @@ const RepoStore = {
editButton: '', editButton: '',
editMode: false, editMode: false,
isTree: false, isTree: false,
isRoot: false,
prevURL: '', prevURL: '',
projectId: '', projectId: '',
projectName: '', projectName: '',
projectUrl: '',
trees: [], trees: [],
blobs: [], blobs: [],
submodules: [], submodules: [],
...@@ -27,21 +29,7 @@ const RepoStore = { ...@@ -27,21 +29,7 @@ const RepoStore = {
tempPrivateToken: '', tempPrivateToken: '',
submitCommitsLoading: false, submitCommitsLoading: false,
binaryLoaded:false, binaryLoaded:false,
activeFile: { activeFile: RepoHelper.getDefaultActiveFile(),
active: true,
binary: false,
extension: '',
html: '',
mime_type: '',
name: 'loading...',
plain: '',
size: 0,
url: '',
raw: false,
newContent: '',
changed: false,
loading: false,
},
activeFileIndex: 0, activeFileIndex: 0,
activeLine: 0, activeLine: 0,
activeFileLabel: 'Raw', activeFileLabel: 'Raw',
...@@ -64,7 +52,6 @@ const RepoStore = { ...@@ -64,7 +52,6 @@ const RepoStore = {
readOnly: true, readOnly: true,
// mutations // mutations
checkIsCommitable() { checkIsCommitable() {
RepoStore.service.checkCurrentBranchIsCommitable() RepoStore.service.checkCurrentBranchIsCommitable()
.then((data) => { .then((data) => {
...@@ -87,7 +74,6 @@ const RepoStore = { ...@@ -87,7 +74,6 @@ const RepoStore = {
setActiveFiles(file) { setActiveFiles(file) {
if (RepoStore.isActiveFile(file)) return; if (RepoStore.isActiveFile(file)) return;
RepoStore.openedFiles = RepoStore.openedFiles RepoStore.openedFiles = RepoStore.openedFiles
.map((openedFile, i) => RepoStore.setFileActivity(file, openedFile, i)); .map((openedFile, i) => RepoStore.setFileActivity(file, openedFile, i));
...@@ -149,8 +135,29 @@ const RepoStore = { ...@@ -149,8 +135,29 @@ const RepoStore = {
removeFromOpenedFiles(file) { removeFromOpenedFiles(file) {
if (file.type === 'tree') return; 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() { addPlaceholderFile() {
......
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
&.close { &.close {
width: auto; width: auto;
font-size: 15px; font-size: 15px;
opacity: 1;
} }
} }
...@@ -110,6 +111,10 @@ ...@@ -110,6 +111,10 @@
margin-left: 15px; margin-left: 15px;
color: $gray-darkest; 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