diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-14 08:30:46 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-14 08:30:46 +0000 |
commit | 5c53dc5a1e7cbae3e7c281cfb0740d44c771958f (patch) | |
tree | 6a0b99b311097ba4525592e1663d63c643790d0e /app | |
parent | 352362adaff3217a8b5d727bc11faf2718423a26 (diff) | |
parent | 5f34759ecb630ef410fe1025cf19e37f1dd4615f (diff) | |
download | gitlab-ce-5c53dc5a1e7cbae3e7c281cfb0740d44c771958f.tar.gz |
Merge branch 'project-default-view' into 'master'
Allow user to specify content he wants to see on project page
Improvement to !938. Since a lot of people complain on fact they don't like to see README.
Especially since we already have a switcher for dashboard - it kind of acceptable to select behaviour.
User can specify which content he/she wants to see:


cc @JobV @jacobvosmaer @marin @sytses
See merge request !970
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/dispatcher.js.coffee | 1 | ||||
-rw-r--r-- | app/assets/javascripts/pager.js.coffee | 2 | ||||
-rw-r--r-- | app/controllers/profiles/preferences_controller.rb | 1 | ||||
-rw-r--r-- | app/helpers/preferences_helper.rb | 12 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/views/profiles/preferences/show.html.haml | 8 | ||||
-rw-r--r-- | app/views/projects/_activity.html.haml | 15 | ||||
-rw-r--r-- | app/views/projects/_readme.html.haml | 24 | ||||
-rw-r--r-- | app/views/projects/activity.html.haml | 13 | ||||
-rw-r--r-- | app/views/projects/show.html.haml | 27 |
10 files changed, 69 insertions, 38 deletions
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index 8ceaef81a07..2ab148bc296 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -63,7 +63,6 @@ class Dispatcher when 'projects:commits:show' shortcut_handler = new ShortcutsNavigation() when 'projects:activity' - new Activities() shortcut_handler = new ShortcutsNavigation() when 'projects:show' shortcut_handler = new ShortcutsNavigation() diff --git a/app/assets/javascripts/pager.js.coffee b/app/assets/javascripts/pager.js.coffee index fe83dc0410e..d639303aed3 100644 --- a/app/assets/javascripts/pager.js.coffee +++ b/app/assets/javascripts/pager.js.coffee @@ -12,7 +12,7 @@ @loading.show() $.ajax type: "GET" - url: location.href + url: $(".content_list").data('href') || location.href data: "limit=" + @limit + "&offset=" + @offset complete: => @loading.hide() diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb index 538b09ca54d..f83b4abd1e2 100644 --- a/app/controllers/profiles/preferences_controller.rb +++ b/app/controllers/profiles/preferences_controller.rb @@ -32,6 +32,7 @@ class Profiles::PreferencesController < Profiles::ApplicationController params.require(:user).permit( :color_scheme_id, :dashboard, + :project_view, :theme_id ) end diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index bceff4fd52e..ea774e28ecf 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -42,6 +42,13 @@ module PreferencesHelper end end + def project_view_choices + [ + ['Readme (default)', :readme], + ['Activity view', :activity] + ] + end + def user_application_theme theme = Gitlab::Themes.by_id(current_user.try(:theme_id)) theme.css_class @@ -50,4 +57,9 @@ module PreferencesHelper def user_color_scheme_class COLOR_SCHEMES[current_user.try(:color_scheme_id)] if defined?(current_user) end + + def prefer_readme? + !current_user || + current_user.project_view == 'readme' + end end diff --git a/app/models/user.rb b/app/models/user.rb index 317257a2500..fb330ff7185 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -177,6 +177,10 @@ class User < ActiveRecord::Base # Note: When adding an option, it MUST go on the end of the array. enum dashboard: [:projects, :stars] + # User's Project preference + # Note: When adding an option, it MUST go on the end of the array. + enum project_view: [:readme, :activity] + alias_attribute :private_token, :authentication_token delegate :path, to: :namespace, allow_nil: true, prefix: true diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml index aa99280fde6..1134317ee06 100644 --- a/app/views/profiles/preferences/show.html.haml +++ b/app/views/profiles/preferences/show.html.haml @@ -38,5 +38,13 @@ = link_to('(?)', help_page_path('profile', 'preferences') + '#default-dashboard', target: '_blank') .col-sm-10 = f.select :dashboard, dashboard_choices, {}, class: 'form-control' + .form-group + = f.label :project_view, class: 'control-label' do + Project view + = link_to('(?)', help_page_path('profile', 'preferences') + '#default-project-view', target: '_blank') + .col-sm-10 + = f.select :project_view, project_view_choices, {}, class: 'form-control' + .help-block + Choose what content you want to see when visit project page .panel-footer = f.submit 'Save', class: 'btn btn-save' diff --git a/app/views/projects/_activity.html.haml b/app/views/projects/_activity.html.haml new file mode 100644 index 00000000000..ee02b7f6a6c --- /dev/null +++ b/app/views/projects/_activity.html.haml @@ -0,0 +1,15 @@ += render 'projects/last_push' +.hidden-xs + - if current_user + %ul.nav.nav-pills.event_filter.pull-right + %li + = link_to namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "Feed", class: 'rss-btn' do + %i.fa.fa-rss + + = render 'shared/event_filter' + %hr +.content_list{:"data-href" => activity_project_path(@project)} += spinner + +:coffeescript + new Activities() diff --git a/app/views/projects/_readme.html.haml b/app/views/projects/_readme.html.haml new file mode 100644 index 00000000000..5038edb95ed --- /dev/null +++ b/app/views/projects/_readme.html.haml @@ -0,0 +1,24 @@ +- if readme = @repository.readme + %article.readme-holder#README + .clearfix + .pull-right + + - if can?(current_user, :push_code, @project) + = link_to namespace_project_edit_blob_path(@project.namespace, @project, tree_join(@repository.root_ref, readme.name)), class: 'light' do + %i.fa.fa-pencil + .wiki + = cache(readme_cache_key) do + = render_readme(readme) +- else + %h3.page-title + This project does not have README yet + - if can?(current_user, :push_code, @project) + %p.slead + A + %code README + file contains information about other files in a repository and is commonly + distributed with computer software, forming part of its documentation. + %br + We recommend you to + = link_to "add README", new_readme_path, class: 'underlined-link' + file to the repository and GitLab will render it here instead of this message. diff --git a/app/views/projects/activity.html.haml b/app/views/projects/activity.html.haml index b486cd4ded4..65674913bb0 100644 --- a/app/views/projects/activity.html.haml +++ b/app/views/projects/activity.html.haml @@ -1,12 +1 @@ -= render 'projects/last_push' -.hidden-xs - - if current_user - %ul.nav.nav-pills.event_filter.pull-right - %li - = link_to namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "Feed", class: 'rss-btn' do - %i.fa.fa-rss - - = render 'shared/event_filter' - %hr -.content_list -= spinner += render 'projects/activity' diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 5c2ac484ceb..98d9053eb1d 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -41,31 +41,10 @@ %hr %section - - if readme = @repository.readme - %article.readme-holder#README - .clearfix - .pull-right - - - if can?(current_user, :push_code, @project) - = link_to namespace_project_edit_blob_path(@project.namespace, @project, tree_join(@repository.root_ref, readme.name)), class: 'light' do - %i.fa.fa-pencil - .wiki - = cache(readme_cache_key) do - = render_readme(readme) + - if prefer_readme? + = render 'projects/readme' - else - %h3.page-title - This project does not have README yet - - if can?(current_user, :push_code, @project) - %p.slead - A - %code README - file contains information about other files in a repository and is commonly - distributed with computer software, forming part of its documentation. - %br - We recommend you to - = link_to "add README", new_readme_path, class: 'underlined-link' - file to the repository and GitLab will render it here instead of this message. - + = render 'projects/activity' - if current_user |