diff --git a/app/assets/javascripts/repo/repo_bundle.js b/app/assets/javascripts/repo/repo_bundle.js index 8ed53203c11..1b4534f138a 100644 --- a/app/assets/javascripts/repo/repo_bundle.js +++ b/app/assets/javascripts/repo/repo_bundle.js @@ -15,7 +15,7 @@ export default class RepoBundle { Store.tabs = new Tabs(); Store.sidebar = new Sidebar(url); Store.editor = new Editor(); - Store.toggler = new ViewToggler(); + // Store.toggler = new ViewToggler(); Store.binaryViewer = new BinaryViewer(); Helper.getContent(); } diff --git a/app/assets/javascripts/repo/repo_helper.js b/app/assets/javascripts/repo/repo_helper.js index f87c2986cd1..910eb19b719 100644 --- a/app/assets/javascripts/repo/repo_helper.js +++ b/app/assets/javascripts/repo/repo_helper.js @@ -78,9 +78,7 @@ let RepoHelper = { }); if(file.binary) { Store.blobRaw = file.base64; - console.log('binary', file) } else { - console.log('f', file) Store.blobRaw = file.plain; } if(!file.loading){ @@ -90,7 +88,6 @@ let RepoHelper = { }, removeFromOpenedFiles(file) { - console.log('file remove', file) if(file.type === 'tree') return; Store.openedFiles = Store.openedFiles.filter((openedFile) => { return openedFile.url !== file.url; @@ -122,7 +119,6 @@ let RepoHelper = { .then((response) => { Store.blobRaw = response; file.base64 = response - console.log('file',file); }); }, @@ -163,7 +159,11 @@ let RepoHelper = { let data = response.data; this.setLoading(false, loadingData); Store.isTree = this.isTree(data); + if(!Store.isTree) { + if(!file) { + file = data; + } // it's a blob Store.binary = data.binary; if(data.binary) { @@ -177,13 +177,17 @@ let RepoHelper = { this.addToOpenedFiles(data); this.setActiveFile(data); } else { - const parentURL = this.blobURLtoParent(Service.url); Store.blobRaw = data.plain; - Store.prevURL = this.blobURLtoParent(parentURL); data.url = file.url; data.binary = false; 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 { // it's a tree @@ -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) { let a = []; //push in blobs data.blobs.forEach((blob) => { - a.push({ - 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 - }) + a.push(this.blobToSimpleBlob(blob)) }); data.trees.forEach((tree) => { - a.push({ - type: 'tree', - name: tree.name, - url: tree.url, - icon: this.toFA(tree.icon), - level: 0 - }) + a.push(this.treeToSimpleTree(tree)); }); data.submodules.forEach((submodule) => { diff --git a/app/assets/stylesheets/pages/repo.scss b/app/assets/stylesheets/pages/repo.scss index 9930eeafd8c..4e15a305b17 100644 --- a/app/assets/stylesheets/pages/repo.scss +++ b/app/assets/stylesheets/pages/repo.scss @@ -65,6 +65,7 @@ header { } #ide { height: 70vh; + margin-top: -5px; } } diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index a82d6fd5a4a..545d69416d2 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -37,12 +37,10 @@ class Projects::BlobController < Projects::ApplicationController respond_to do |format| format.html do - environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } - @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last + assign_ref_vars + @last_commit = @repository.last_commit_for_path(@commit.id, tree.path) || @commit - @last_commit = @repository.last_commit_for_path(@commit.id, @blob.path) - - render 'show' + render 'projects/tree/show' end format.json do