Allow user to specify content he wants to see on project page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
4f0455c96b
commit
5f34759ecb
13 changed files with 82 additions and 39 deletions
|
@ -63,7 +63,6 @@ class Dispatcher
|
||||||
when 'projects:commits:show'
|
when 'projects:commits:show'
|
||||||
shortcut_handler = new ShortcutsNavigation()
|
shortcut_handler = new ShortcutsNavigation()
|
||||||
when 'projects:activity'
|
when 'projects:activity'
|
||||||
new Activities()
|
|
||||||
shortcut_handler = new ShortcutsNavigation()
|
shortcut_handler = new ShortcutsNavigation()
|
||||||
when 'projects:show'
|
when 'projects:show'
|
||||||
shortcut_handler = new ShortcutsNavigation()
|
shortcut_handler = new ShortcutsNavigation()
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
@loading.show()
|
@loading.show()
|
||||||
$.ajax
|
$.ajax
|
||||||
type: "GET"
|
type: "GET"
|
||||||
url: location.href
|
url: $(".content_list").data('href') || location.href
|
||||||
data: "limit=" + @limit + "&offset=" + @offset
|
data: "limit=" + @limit + "&offset=" + @offset
|
||||||
complete: =>
|
complete: =>
|
||||||
@loading.hide()
|
@loading.hide()
|
||||||
|
|
|
@ -32,6 +32,7 @@ class Profiles::PreferencesController < Profiles::ApplicationController
|
||||||
params.require(:user).permit(
|
params.require(:user).permit(
|
||||||
:color_scheme_id,
|
:color_scheme_id,
|
||||||
:dashboard,
|
:dashboard,
|
||||||
|
:project_view,
|
||||||
:theme_id
|
:theme_id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,6 +42,13 @@ module PreferencesHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def project_view_choices
|
||||||
|
[
|
||||||
|
['Readme (default)', :readme],
|
||||||
|
['Activity view', :activity]
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
def user_application_theme
|
def user_application_theme
|
||||||
theme = Gitlab::Themes.by_id(current_user.try(:theme_id))
|
theme = Gitlab::Themes.by_id(current_user.try(:theme_id))
|
||||||
theme.css_class
|
theme.css_class
|
||||||
|
@ -50,4 +57,9 @@ module PreferencesHelper
|
||||||
def user_color_scheme_class
|
def user_color_scheme_class
|
||||||
COLOR_SCHEMES[current_user.try(:color_scheme_id)] if defined?(current_user)
|
COLOR_SCHEMES[current_user.try(:color_scheme_id)] if defined?(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prefer_readme?
|
||||||
|
!current_user ||
|
||||||
|
current_user.project_view == 'readme'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -177,6 +177,10 @@ class User < ActiveRecord::Base
|
||||||
# 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 dashboard: [:projects, :stars]
|
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
|
alias_attribute :private_token, :authentication_token
|
||||||
|
|
||||||
delegate :path, to: :namespace, allow_nil: true, prefix: true
|
delegate :path, to: :namespace, allow_nil: true, prefix: true
|
||||||
|
|
|
@ -38,5 +38,13 @@
|
||||||
= link_to('(?)', help_page_path('profile', 'preferences') + '#default-dashboard', target: '_blank')
|
= link_to('(?)', help_page_path('profile', 'preferences') + '#default-dashboard', target: '_blank')
|
||||||
.col-sm-10
|
.col-sm-10
|
||||||
= f.select :dashboard, dashboard_choices, {}, class: 'form-control'
|
= 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
|
.panel-footer
|
||||||
= f.submit 'Save', class: 'btn btn-save'
|
= f.submit 'Save', class: 'btn btn-save'
|
||||||
|
|
15
app/views/projects/_activity.html.haml
Normal file
15
app/views/projects/_activity.html.haml
Normal file
|
@ -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()
|
24
app/views/projects/_readme.html.haml
Normal file
24
app/views/projects/_readme.html.haml
Normal file
|
@ -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.
|
|
@ -1,12 +1 @@
|
||||||
= render 'projects/last_push'
|
= render 'projects/activity'
|
||||||
.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
|
|
||||||
|
|
|
@ -41,31 +41,10 @@
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
%section
|
%section
|
||||||
- if readme = @repository.readme
|
- if prefer_readme?
|
||||||
%article.readme-holder#README
|
= render 'projects/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
|
- else
|
||||||
%h3.page-title
|
= render 'projects/activity'
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- if current_user
|
- if current_user
|
||||||
|
|
5
db/migrate/20150713160110_add_project_view_to_users.rb
Normal file
5
db/migrate/20150713160110_add_project_view_to_users.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddProjectViewToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :project_view, :integer, default: 0
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150620233230) do
|
ActiveRecord::Schema.define(version: 20150713160110) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -517,6 +517,7 @@ ActiveRecord::Schema.define(version: 20150620233230) do
|
||||||
t.text "otp_backup_codes"
|
t.text "otp_backup_codes"
|
||||||
t.string "public_email", default: "", null: false
|
t.string "public_email", default: "", null: false
|
||||||
t.integer "dashboard", default: 0
|
t.integer "dashboard", default: 0
|
||||||
|
t.integer "project_view", default: 0
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
|
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
|
||||||
|
|
|
@ -30,3 +30,9 @@ will be. Setting it to **Starred Projects** will make that Dashboard view the
|
||||||
default when signing in or clicking the application logo in the upper left.
|
default when signing in or clicking the application logo in the upper left.
|
||||||
|
|
||||||
The default is **Your Projects**.
|
The default is **Your Projects**.
|
||||||
|
|
||||||
|
### Default Project view
|
||||||
|
|
||||||
|
It allows user to choose what content he or she want to see on project page.
|
||||||
|
|
||||||
|
The default is **Readme**.
|
||||||
|
|
Loading…
Reference in a new issue