Commit 3d90560c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'user-preferences-layout-option' of...

Merge branch 'user-preferences-layout-option' of https://github.com/gopeter/gitlabhq into gopeter-user-preferences-layout-option
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parents 3eef0e18 291e1fa9
...@@ -32,6 +32,7 @@ v 8.1.0 (unreleased) ...@@ -32,6 +32,7 @@ v 8.1.0 (unreleased)
- Fix anchors to comments in diffs - Fix anchors to comments in diffs
- Move CI web hooks page to project settings area - Move CI web hooks page to project settings area
- Fix User Identities API. It now allows you to properly create or update user's identities. - Fix User Identities API. It now allows you to properly create or update user's identities.
- Add user preference to change layout width (Peter Göbel)
v 8.0.3 v 8.0.3
- Fix URL shown in Slack notifications - Fix URL shown in Slack notifications
......
...@@ -31,6 +31,7 @@ class Profiles::PreferencesController < Profiles::ApplicationController ...@@ -31,6 +31,7 @@ class Profiles::PreferencesController < Profiles::ApplicationController
def preferences_params def preferences_params
params.require(:user).permit( params.require(:user).permit(
:color_scheme_id, :color_scheme_id,
:layout,
:dashboard, :dashboard,
:project_view, :project_view,
:theme_id :theme_id
......
...@@ -26,7 +26,7 @@ module PageLayoutHelper ...@@ -26,7 +26,7 @@ module PageLayoutHelper
def fluid_layout(enabled = false) def fluid_layout(enabled = false)
if @fluid_layout.nil? if @fluid_layout.nil?
@fluid_layout = enabled @fluid_layout = (current_user && current_user.layout == "fluid") || enabled
else else
@fluid_layout @fluid_layout
end end
......
# Helper methods for per-User preferences # Helper methods for per-User preferences
module PreferencesHelper module PreferencesHelper
def layout_choices
[
['Fixed', :fixed],
['Fluid', :fluid]
]
end
# Maps `dashboard` values to more user-friendly option text # Maps `dashboard` values to more user-friendly option text
DASHBOARD_CHOICES = { DASHBOARD_CHOICES = {
projects: 'Your Projects (default)', projects: 'Your Projects (default)',
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
# public_email :string(255) default(""), not null # public_email :string(255) default(""), not null
# dashboard :integer default(0) # dashboard :integer default(0)
# project_view :integer default(0) # project_view :integer default(0)
# layout :integer default(0)
# #
require 'carrierwave/orm/activerecord' require 'carrierwave/orm/activerecord'
...@@ -172,6 +173,9 @@ class User < ActiveRecord::Base ...@@ -172,6 +173,9 @@ class User < ActiveRecord::Base
after_create :post_create_hook after_create :post_create_hook
after_destroy :post_destroy_hook after_destroy :post_destroy_hook
# User's Layout preference
enum layout: [:fixed, :fluid]
# User's Dashboard preference # User's Dashboard 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 dashboard: [:projects, :stars, :project_activity, :starred_project_activity] enum dashboard: [:projects, :stars, :project_activity, :starred_project_activity]
......
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
.panel-heading .panel-heading
Behavior Behavior
.panel-body .panel-body
.form-group
= f.label :layout, class: 'control-label' do
Layout width
.col-sm-10
= f.select :layout, layout_choices, {}, class: 'form-control'
.help-block
Choose between fixed (max. 1200px) and fluid (100%) application layout
.form-group .form-group
= f.label :dashboard, class: 'control-label' do = f.label :dashboard, class: 'control-label' do
Default Dashboard Default Dashboard
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
$('body').removeClass('<%= Gitlab::Themes.body_classes %>') $('body').removeClass('<%= Gitlab::Themes.body_classes %>')
$('body').addClass('<%= user_application_theme %>') $('body').addClass('<%= user_application_theme %>')
// Toggle container-fluid class
if ('<%= current_user.layout %>' === 'fluid') {
$('.content-wrapper').find('.container-fluid').removeClass('container-limited')
} else {
$('.content-wrapper').find('.container-fluid').addClass('container-limited')
}
// Re-enable the "Save" button // Re-enable the "Save" button
$('input[type=submit]').enable() $('input[type=submit]').enable()
......
class AddLayoutOptionForUsers < ActiveRecord::Migration
def change
add_column :users, :layout, :integer, default: 0
end
end
\ No newline at end of file
...@@ -11,7 +11,7 @@ ...@@ -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: 20151005075649) do ActiveRecord::Schema.define(version: 20151005150751) 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"
...@@ -758,6 +758,7 @@ ActiveRecord::Schema.define(version: 20151005075649) do ...@@ -758,6 +758,7 @@ ActiveRecord::Schema.define(version: 20151005075649) do
t.integer "dashboard", default: 0 t.integer "dashboard", default: 0
t.integer "project_view", default: 0 t.integer "project_view", default: 0
t.integer "consumed_timestep" t.integer "consumed_timestep"
t.integer "layout", 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
......
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