Commit 62ad0113 authored by Jacob Schatz's avatar Jacob Schatz

Get single view working.

parent 714dac67
...@@ -15,7 +15,7 @@ export default class RepoBundle { ...@@ -15,7 +15,7 @@ export default class RepoBundle {
Store.tabs = new Tabs(); Store.tabs = new Tabs();
Store.sidebar = new Sidebar(url); Store.sidebar = new Sidebar(url);
Store.editor = new Editor(); Store.editor = new Editor();
Store.toggler = new ViewToggler(); // Store.toggler = new ViewToggler();
Store.binaryViewer = new BinaryViewer(); Store.binaryViewer = new BinaryViewer();
Helper.getContent(); Helper.getContent();
} }
......
...@@ -78,9 +78,7 @@ let RepoHelper = { ...@@ -78,9 +78,7 @@ let RepoHelper = {
}); });
if(file.binary) { if(file.binary) {
Store.blobRaw = file.base64; Store.blobRaw = file.base64;
console.log('binary', file)
} else { } else {
console.log('f', file)
Store.blobRaw = file.plain; Store.blobRaw = file.plain;
} }
if(!file.loading){ if(!file.loading){
...@@ -90,7 +88,6 @@ let RepoHelper = { ...@@ -90,7 +88,6 @@ let RepoHelper = {
}, },
removeFromOpenedFiles(file) { removeFromOpenedFiles(file) {
console.log('file remove', file)
if(file.type === 'tree') return; if(file.type === 'tree') return;
Store.openedFiles = Store.openedFiles.filter((openedFile) => { Store.openedFiles = Store.openedFiles.filter((openedFile) => {
return openedFile.url !== file.url; return openedFile.url !== file.url;
...@@ -122,7 +119,6 @@ let RepoHelper = { ...@@ -122,7 +119,6 @@ let RepoHelper = {
.then((response) => { .then((response) => {
Store.blobRaw = response; Store.blobRaw = response;
file.base64 = response file.base64 = response
console.log('file',file);
}); });
}, },
...@@ -163,7 +159,11 @@ let RepoHelper = { ...@@ -163,7 +159,11 @@ let RepoHelper = {
let data = response.data; let data = response.data;
this.setLoading(false, loadingData); this.setLoading(false, loadingData);
Store.isTree = this.isTree(data); Store.isTree = this.isTree(data);
if(!Store.isTree) { if(!Store.isTree) {
if(!file) {
file = data;
}
// it's a blob // it's a blob
Store.binary = data.binary; Store.binary = data.binary;
if(data.binary) { if(data.binary) {
...@@ -177,13 +177,17 @@ let RepoHelper = { ...@@ -177,13 +177,17 @@ let RepoHelper = {
this.addToOpenedFiles(data); this.addToOpenedFiles(data);
this.setActiveFile(data); this.setActiveFile(data);
} else { } else {
const parentURL = this.blobURLtoParent(Service.url);
Store.blobRaw = data.plain; Store.blobRaw = data.plain;
Store.prevURL = this.blobURLtoParent(parentURL);
data.url = file.url; data.url = file.url;
data.binary = false; data.binary = false;
this.addToOpenedFiles(data); this.addToOpenedFiles(data);
this.setActiveFile(data); this.setActiveFile(data);
}
// if the file tree is empty
if(Store.files.length === 0) {
const parentURL = this.blobURLtoParent(Service.url);
Service.url = parentURL;
this.getContent();
} }
} else { } else {
// it's a tree // it's a tree
...@@ -221,30 +225,38 @@ let RepoHelper = { ...@@ -221,30 +225,38 @@ let RepoHelper = {
}, },
blobToSimpleBlob(blob) {
return {
type: 'blob',
name: blob.name,
url: blob.url,
icon: this.toFA(blob.icon),
lastCommitMessage: blob.last_commit.message,
lastCommitUpdate: blob.last_commit.committed_date,
level: 0
}
},
treeToSimpleTree(tree) {
return {
type: 'tree',
name: tree.name,
url: tree.url,
icon: this.toFA(tree.icon),
level: 0
}
},
dataToListOfFiles(data) { dataToListOfFiles(data) {
let a = []; let a = [];
//push in blobs //push in blobs
data.blobs.forEach((blob) => { data.blobs.forEach((blob) => {
a.push({ a.push(this.blobToSimpleBlob(blob))
type: 'blob',
name: blob.name,
url: blob.url,
icon: this.toFA(blob.icon),
lastCommitMessage: blob.last_commit.message,
lastCommitUpdate: blob.last_commit.committed_date,
level: 0
})
}); });
data.trees.forEach((tree) => { data.trees.forEach((tree) => {
a.push({ a.push(this.treeToSimpleTree(tree));
type: 'tree',
name: tree.name,
url: tree.url,
icon: this.toFA(tree.icon),
level: 0
})
}); });
data.submodules.forEach((submodule) => { data.submodules.forEach((submodule) => {
......
...@@ -65,6 +65,7 @@ header { ...@@ -65,6 +65,7 @@ header {
} }
#ide { #ide {
height: 70vh; height: 70vh;
margin-top: -5px;
} }
} }
......
...@@ -37,12 +37,10 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -37,12 +37,10 @@ class Projects::BlobController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } assign_ref_vars
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last @last_commit = @repository.last_commit_for_path(@commit.id, tree.path) || @commit
@last_commit = @repository.last_commit_for_path(@commit.id, @blob.path) render 'projects/tree/show'
render 'show'
end end
format.json do format.json do
......
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