Commit c5280434 authored by Cristian Bica's avatar Cristian Bica

Allow users to select the Files view as default project view

parent 2e8a3e39
...@@ -507,6 +507,10 @@ pre.light-well { ...@@ -507,6 +507,10 @@ pre.light-well {
} }
} }
.project-show-files {
padding-top: 20px;
}
.inline-form { .inline-form {
display: inline-block; display: inline-block;
} }
......
...@@ -89,7 +89,10 @@ class ProjectsController < ApplicationController ...@@ -89,7 +89,10 @@ class ProjectsController < ApplicationController
if current_user if current_user
@membership = @project.project_member_by_id(current_user.id) @membership = @project.project_member_by_id(current_user.id)
end end
@ref = "master"
@id = "master"
@commit = @project.repository.commit(@ref)
@tree = @project.repository.tree(@commit.id)
render :show render :show
end end
else else
......
...@@ -27,7 +27,8 @@ module PreferencesHelper ...@@ -27,7 +27,8 @@ module PreferencesHelper
def project_view_choices def project_view_choices
[ [
['Readme (default)', :readme], ['Readme (default)', :readme],
['Activity view', :activity] ['Activity view', :activity],
['Files view', :files]
] ]
end end
...@@ -43,4 +44,9 @@ module PreferencesHelper ...@@ -43,4 +44,9 @@ module PreferencesHelper
!current_user || !current_user ||
current_user.project_view == 'readme' current_user.project_view == 'readme'
end end
def current_user_default_project_view
(current_user && current_user.project_view) ||
'readme'
end
end end
...@@ -176,7 +176,7 @@ class User < ActiveRecord::Base ...@@ -176,7 +176,7 @@ class User < ActiveRecord::Base
# User's Project preference # User's Project preference
# Note: When adding an option, it MUST go on the end of the array. # Note: When adding an option, it MUST go on the end of the array.
enum project_view: [:readme, :activity] enum project_view: [:readme, :activity, :files]
alias_attribute :private_token, :authentication_token alias_attribute :private_token, :authentication_token
......
= render 'projects/last_push'
.tree-ref-holder
= render 'shared/ref_switcher', destination: 'tree', path: @path
- if can? current_user, :download_code, @project
.tree-download-holder
= render 'projects/repositories/download_archive', ref: @ref, btn_class: 'btn-group pull-right hidden-xs hidden-sm', split_button: true
#tree-holder.tree-holder.clearfix
= render "projects/tree/tree", tree: @tree
...@@ -64,13 +64,8 @@ ...@@ -64,13 +64,8 @@
Archived project! Repository is read-only Archived project! Repository is read-only
%section %section
- if prefer_readme? %div{class: "project-show-#{current_user_default_project_view}"}
.project-show-readme = render current_user_default_project_view
= render 'projects/readme'
- else
.project-show-activity
= render 'projects/activity'
- if current_user - if current_user
- access = user_max_access_in_project(current_user, @project) - access = user_max_access_in_project(current_user, @project)
......
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
%span.str-truncated %span.str-truncated
= link_to blob_item.name, namespace_project_blob_path(@project.namespace, @project, tree_join(@id || @commit.id, blob_item.name)) = link_to blob_item.name, namespace_project_blob_path(@project.namespace, @project, tree_join(@id || @commit.id, blob_item.name))
%td.tree_time_ago.cgray %td.tree_time_ago.cgray
= render 'spinner' = render 'projects/tree/spinner'
%td.hidden-xs.tree_commit %td.hidden-xs.tree_commit
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
- path = flatten_tree(tree_item) - path = flatten_tree(tree_item)
= link_to path, namespace_project_tree_path(@project.namespace, @project, tree_join(@id || @commit.id, path)) = link_to path, namespace_project_tree_path(@project.namespace, @project, tree_join(@id || @commit.id, path))
%td.tree_time_ago.cgray %td.tree_time_ago.cgray
= render 'spinner' = render 'projects/tree/spinner'
%td.hidden-xs.tree_commit %td.hidden-xs.tree_commit
...@@ -21,6 +21,31 @@ describe ProjectsController do ...@@ -21,6 +21,31 @@ describe ProjectsController do
expect(response.body).to include("content='#{content}'") expect(response.body).to include("content='#{content}'")
end end
end end
context "rendering default project view" do
render_views
it "shold render the activity view", focus: true do
allow(controller).to receive(:current_user).and_return(user)
allow(user).to receive(:project_view).and_return('activity')
get :show, namespace_id: public_project.namespace.path, id: public_project.path
expect(response).to render_template('_activity')
end
it "shold render the readme view", focus: true do
allow(controller).to receive(:current_user).and_return(user)
allow(user).to receive(:project_view).and_return('readme')
get :show, namespace_id: public_project.namespace.path, id: public_project.path
expect(response).to render_template('_readme')
end
it "shold render the files view", focus: true do
allow(controller).to receive(:current_user).and_return(user)
allow(user).to receive(:project_view).and_return('files')
get :show, namespace_id: public_project.namespace.path, id: public_project.path
expect(response).to render_template('_files')
end
end
end end
describe "POST #toggle_star" do describe "POST #toggle_star" 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