summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-10-05 20:14:41 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-10-05 20:14:41 +0200
commit34d79c9c52b94867d0feda5e2beff5299f0640a6 (patch)
treea64b78abf6c6f850b57dfea8f8fd901fa834711b
parent3eef0e18e0d4561c320b4a5d9c17d7ae7aaa3d42 (diff)
parent3d90560c1e6a18cf3002c6413f53ceda5c25b3d1 (diff)
downloadgitlab-ce-34d79c9c52b94867d0feda5e2beff5299f0640a6.tar.gz
Merge branch 'gopeter-user-preferences-layout-option'
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/profiles/preferences_controller.rb1
-rw-r--r--app/helpers/page_layout_helper.rb2
-rw-r--r--app/helpers/preferences_helper.rb7
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/profiles/preferences/show.html.haml7
-rw-r--r--app/views/profiles/preferences/update.js.erb7
-rw-r--r--db/migrate/20151005150751_add_layout_option_for_users.rb5
-rw-r--r--db/schema.rb3
9 files changed, 35 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a63aea7ca28..3144175db89 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,6 +32,7 @@ v 8.1.0 (unreleased)
- Fix anchors to comments in diffs
- 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.
+ - Add user preference to change layout width (Peter Göbel)
v 8.0.3
- Fix URL shown in Slack notifications
diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb
index f83b4abd1e2..a9a06ecc808 100644
--- a/app/controllers/profiles/preferences_controller.rb
+++ b/app/controllers/profiles/preferences_controller.rb
@@ -31,6 +31,7 @@ class Profiles::PreferencesController < Profiles::ApplicationController
def preferences_params
params.require(:user).permit(
:color_scheme_id,
+ :layout,
:dashboard,
:project_view,
:theme_id
diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb
index df37be51ce9..775cf5a3dd4 100644
--- a/app/helpers/page_layout_helper.rb
+++ b/app/helpers/page_layout_helper.rb
@@ -26,7 +26,7 @@ module PageLayoutHelper
def fluid_layout(enabled = false)
if @fluid_layout.nil?
- @fluid_layout = enabled
+ @fluid_layout = (current_user && current_user.layout == "fluid") || enabled
else
@fluid_layout
end
diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb
index 1b1f4162df4..4710171ebaa 100644
--- a/app/helpers/preferences_helper.rb
+++ b/app/helpers/preferences_helper.rb
@@ -1,5 +1,12 @@
# Helper methods for per-User preferences
module PreferencesHelper
+ def layout_choices
+ [
+ ['Fixed', :fixed],
+ ['Fluid', :fluid]
+ ]
+ end
+
# Maps `dashboard` values to more user-friendly option text
DASHBOARD_CHOICES = {
projects: 'Your Projects (default)',
diff --git a/app/models/user.rb b/app/models/user.rb
index c7e3992b6a1..889d2d3b867 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -54,6 +54,7 @@
# public_email :string(255) default(""), not null
# dashboard :integer default(0)
# project_view :integer default(0)
+# layout :integer default(0)
#
require 'carrierwave/orm/activerecord'
@@ -172,6 +173,9 @@ class User < ActiveRecord::Base
after_create :post_create_hook
after_destroy :post_destroy_hook
+ # User's Layout preference
+ enum layout: [:fixed, :fluid]
+
# User's Dashboard preference
# Note: When adding an option, it MUST go on the end of the array.
enum dashboard: [:projects, :stars, :project_activity, :starred_project_activity]
diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml
index 60289bfe7cd..01e285a8dfa 100644
--- a/app/views/profiles/preferences/show.html.haml
+++ b/app/views/profiles/preferences/show.html.haml
@@ -33,6 +33,13 @@
Behavior
.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
= f.label :dashboard, class: 'control-label' do
Default Dashboard
= link_to('(?)', help_page_path('profile', 'preferences') + '#default-dashboard', target: '_blank')
diff --git a/app/views/profiles/preferences/update.js.erb b/app/views/profiles/preferences/update.js.erb
index 6c4b0ce757d..4433cab7782 100644
--- a/app/views/profiles/preferences/update.js.erb
+++ b/app/views/profiles/preferences/update.js.erb
@@ -2,6 +2,13 @@
$('body').removeClass('<%= Gitlab::Themes.body_classes %>')
$('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
$('input[type=submit]').enable()
diff --git a/db/migrate/20151005150751_add_layout_option_for_users.rb b/db/migrate/20151005150751_add_layout_option_for_users.rb
new file mode 100644
index 00000000000..ead9b1f8977
--- /dev/null
+++ b/db/migrate/20151005150751_add_layout_option_for_users.rb
@@ -0,0 +1,5 @@
+class AddLayoutOptionForUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :layout, :integer, default: 0
+ end
+end \ No newline at end of file
diff --git a/db/schema.rb b/db/schema.rb
index 0e8d54fb267..5b114a29011 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# 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
enable_extension "plpgsql"
@@ -758,6 +758,7 @@ ActiveRecord::Schema.define(version: 20151005075649) do
t.integer "dashboard", default: 0
t.integer "project_view", default: 0
t.integer "consumed_timestep"
+ t.integer "layout", default: 0
end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree