From 5a1faf61f6d8bdbdde1842db8cf13521287ed168 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Dec 2015 12:53:31 +0100 Subject: [PATCH] Add artifacts browser This implementation makes it possible to browse artifacts, it depends on artifacts metadata. --- app/controllers/projects/artifacts_controller.rb | 6 ++---- app/views/projects/artifacts/_tree_directory.html.haml | 5 +++++ app/views/projects/artifacts/_tree_file.html.haml | 5 +++++ app/views/projects/artifacts/browse.html.haml | 4 +++- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 app/views/projects/artifacts/_tree_directory.html.haml create mode 100644 app/views/projects/artifacts/_tree_file.html.haml diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index c1f406e3ba5..4524127e8e5 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -15,10 +15,8 @@ class Projects::ArtifactsController < Projects::ApplicationController end def browse - path = params[:path].to_s - @paths = artifacts_metadata.map do |_artifact_file| - Gitlab::StringPath.new(path, artifacts_metadata) - end + current_path = params[:path] ? "./#{params[:path]}/" : './' + @path = Gitlab::StringPath.new(current_path, artifacts_metadata) end private diff --git a/app/views/projects/artifacts/_tree_directory.html.haml b/app/views/projects/artifacts/_tree_directory.html.haml new file mode 100644 index 00000000000..a53001567c3 --- /dev/null +++ b/app/views/projects/artifacts/_tree_directory.html.haml @@ -0,0 +1,5 @@ +%tr{ class: 'tree-item' } + %td.tree-item-file-name + = tree_icon('folder', '755', directory.basename) + %span.str-truncated + = link_to directory.basename, browse_namespace_project_build_artifacts_path(@project.namespace, @project, @build, path: directory.path) diff --git a/app/views/projects/artifacts/_tree_file.html.haml b/app/views/projects/artifacts/_tree_file.html.haml new file mode 100644 index 00000000000..ad42162b50a --- /dev/null +++ b/app/views/projects/artifacts/_tree_file.html.haml @@ -0,0 +1,5 @@ +%tr{ class: 'tree-item' } + %td.tree-item-file-name + = tree_icon('file', '664', file.basename) + %span.str-truncated + = file.basename diff --git a/app/views/projects/artifacts/browse.html.haml b/app/views/projects/artifacts/browse.html.haml index bb669ac8ba1..6dae7a9efa6 100644 --- a/app/views/projects/artifacts/browse.html.haml +++ b/app/views/projects/artifacts/browse.html.haml @@ -1,4 +1,6 @@ - page_title "#{@build.name} (##{@build.id})", 'Build artifacts' - header_title project_title(@project, "Build artifacts", namespace_project_build_path(@project.namespace, @project, @build)) -= @metadata.inspect +%table.table.table-hover + = render partial: 'tree_directory', collection: @path.directories, as: :directory + = render partial: 'tree_file', collection: @path.files, as: :file