Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
c5280434
Commit
c5280434
authored
Oct 01, 2015
by
Cristian Bica
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to select the Files view as default project view
parent
2e8a3e39
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
96 additions
and
52 deletions
+96
-52
app/assets/stylesheets/pages/projects.scss
app/assets/stylesheets/pages/projects.scss
+44
-40
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+4
-1
app/helpers/preferences_helper.rb
app/helpers/preferences_helper.rb
+7
-1
app/models/user.rb
app/models/user.rb
+1
-1
app/views/projects/_files.html.haml
app/views/projects/_files.html.haml
+11
-0
app/views/projects/show.html.haml
app/views/projects/show.html.haml
+2
-7
app/views/projects/tree/_blob_item.html.haml
app/views/projects/tree/_blob_item.html.haml
+1
-1
app/views/projects/tree/_tree_item.html.haml
app/views/projects/tree/_tree_item.html.haml
+1
-1
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+25
-0
No files found.
app/assets/stylesheets/pages/projects.scss
View file @
c5280434
...
...
@@ -507,6 +507,10 @@ pre.light-well {
}
}
.project-show-files
{
padding-top
:
20px
;
}
.inline-form
{
display
:
inline-block
;
}
...
...
app/controllers/projects_controller.rb
View file @
c5280434
...
...
@@ -89,7 +89,10 @@ class ProjectsController < ApplicationController
if
current_user
@membership
=
@project
.
project_member_by_id
(
current_user
.
id
)
end
@ref
=
"master"
@id
=
"master"
@commit
=
@project
.
repository
.
commit
(
@ref
)
@tree
=
@project
.
repository
.
tree
(
@commit
.
id
)
render
:show
end
else
...
...
app/helpers/preferences_helper.rb
View file @
c5280434
...
...
@@ -27,7 +27,8 @@ module PreferencesHelper
def
project_view_choices
[
[
'Readme (default)'
,
:readme
],
[
'Activity view'
,
:activity
]
[
'Activity view'
,
:activity
],
[
'Files view'
,
:files
]
]
end
...
...
@@ -43,4 +44,9 @@ module PreferencesHelper
!
current_user
||
current_user
.
project_view
==
'readme'
end
def
current_user_default_project_view
(
current_user
&&
current_user
.
project_view
)
||
'readme'
end
end
app/models/user.rb
View file @
c5280434
...
...
@@ -176,7 +176,7 @@ class User < ActiveRecord::Base
# User's Project preference
# 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
...
...
app/views/projects/_files.html.haml
0 → 100644
View file @
c5280434
=
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
app/views/projects/show.html.haml
View file @
c5280434
...
...
@@ -64,13 +64,8 @@
Archived project! Repository is read-only
%section
-
if
prefer_readme?
.project-show-readme
=
render
'projects/readme'
-
else
.project-show-activity
=
render
'projects/activity'
%div
{
class:
"project-show-#{current_user_default_project_view}"
}
=
render
current_user_default_project_view
-
if
current_user
-
access
=
user_max_access_in_project
(
current_user
,
@project
)
...
...
app/views/projects/tree/_blob_item.html.haml
View file @
c5280434
...
...
@@ -4,5 +4,5 @@
%span
.str-truncated
=
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
=
render
'spinner'
=
render
'
projects/tree/
spinner'
%td
.hidden-xs.tree_commit
app/views/projects/tree/_tree_item.html.haml
View file @
c5280434
...
...
@@ -5,5 +5,5 @@
-
path
=
flatten_tree
(
tree_item
)
=
link_to
path
,
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
tree_join
(
@id
||
@commit
.
id
,
path
))
%td
.tree_time_ago.cgray
=
render
'spinner'
=
render
'
projects/tree/
spinner'
%td
.hidden-xs.tree_commit
spec/controllers/projects_controller_spec.rb
View file @
c5280434
...
...
@@ -21,6 +21,31 @@ describe ProjectsController do
expect
(
response
.
body
).
to
include
(
"content='
#{
content
}
'"
)
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
describe
"POST #toggle_star"
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment