diff --git a/app/assets/stylesheets/content/_index.sass b/app/assets/stylesheets/content/_index.sass index 2d7b08d2ca..5f756741a0 100644 --- a/app/assets/stylesheets/content/_index.sass +++ b/app/assets/stylesheets/content/_index.sass @@ -73,4 +73,5 @@ @import content/version @import content/menus/_project_autocompletion +@import content/menus/_menu_blocks @import content/editor/index diff --git a/app/assets/stylesheets/content/menus/_menu_blocks.sass b/app/assets/stylesheets/content/menus/_menu_blocks.sass new file mode 100644 index 0000000000..09df8733d1 --- /dev/null +++ b/app/assets/stylesheets/content/menus/_menu_blocks.sass @@ -0,0 +1,24 @@ +.menu-blocks--container + display: grid + grid-template: repeat(auto-fit, 200px) / repeat(auto-fit, 200px) + grid-auto-rows: 200px + grid-column-gap: 30px + grid-row-gap: 30px + + .menu-block + border-radius: 3px + display: grid + grid-template: 110px 1fr / 1fr + grid-row-gap: 5px + justify-items: center + background: #cccccc30 + + &:hover + outline: 1px solid grey + text-decoration: none + + .menu-block--icon + font-size: 50px + align-self: end + &:before + padding-left: 10px diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index f3aa89289e..9b92d89656 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -34,9 +34,11 @@ class AdminController < ApplicationController menu_item :plugins, only: [:plugins] menu_item :info, only: [:info] + menu_item :admin_overview, only: [:index] def index - redirect_to controller: 'users', action: 'index' + @menu_nodes = Redmine::MenuManager.items(:admin_menu).children + @menu_nodes.shift end def projects diff --git a/app/controllers/authentication_controller.rb b/app/controllers/authentication_controller.rb index 051a693312..b6c0697b40 100644 --- a/app/controllers/authentication_controller.rb +++ b/app/controllers/authentication_controller.rb @@ -30,6 +30,8 @@ class AuthenticationController < ApplicationController before_action :disable_api before_action :require_login + layout 'admin' + menu_item :authentication_settings accept_key_auth :index @@ -38,4 +40,27 @@ class AuthenticationController < ApplicationController format.html end end + + def edit + if params[:settings] + Settings::UpdateService + .new(user: current_user) + .call(settings: permitted_params.settings.to_h) + + flash[:notice] = l(:notice_successful_update) + redirect_to action: 'authentication_settings' + end + end + + def authentication_settings + render 'authentication_settings' + end + + def default_breadcrumb + t(:label_authentication) + end + + def show_local_breadcrumb + true + end end diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 0830c73f4d..1ade188aea 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -29,10 +29,20 @@ class SettingsController < ApplicationController layout 'admin' - menu_item :settings before_action :require_admin + current_menu_item [:index, :edit] do + :settings + end + + current_menu_item :plugin do |controller| + plugin = Redmine::Plugin.find(controller.params[:id]) + plugin.settings[:menu_item] || :settings + rescue Redmine::PluginNotFound + :settings + end + def index edit render action: 'edit' @@ -41,17 +51,9 @@ class SettingsController < ApplicationController def edit @notifiables = Redmine::Notifiable.all if request.post? && params[:settings] - permitted_params.settings.to_h.each do |name, value| - if value.is_a?(Array) - # remove blank values in array settings - value.delete_if(&:blank?) - elsif value.is_a?(Hash) - value.delete_if { |_, v| v.blank? } - else - value = value.strip - end - Setting[name] = value - end + Settings::UpdateService + .new(user: current_user) + .call(settings: permitted_params.settings.to_h) flash[:notice] = l(:notice_successful_update) redirect_to action: 'edit', tab: params[:tab] diff --git a/app/controllers/users_settings_controller.rb b/app/controllers/users_settings_controller.rb new file mode 100644 index 0000000000..66ce0bb203 --- /dev/null +++ b/app/controllers/users_settings_controller.rb @@ -0,0 +1,57 @@ +#-- encoding: UTF-8 + +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ + +class UsersSettingsController < ::ApplicationController + layout 'admin' + menu_item :user_settings + + def index + render 'users/users_settings' + end + + def edit + if params[:settings] + Settings::UpdateService + .new(user: current_user) + .call(settings: permitted_params.settings.to_h) + + flash[:notice] = l(:notice_successful_update) + redirect_to action: 'index' + end + end + + def default_breadcrumb + t(:label_user_settings) + end + + def show_local_breadcrumb + true + end +end diff --git a/app/controllers/work_packages/settings_controller.rb b/app/controllers/work_packages/settings_controller.rb new file mode 100644 index 0000000000..ae5f746f8d --- /dev/null +++ b/app/controllers/work_packages/settings_controller.rb @@ -0,0 +1,57 @@ +#-- encoding: UTF-8 + +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ + +class WorkPackages::SettingsController < ::ApplicationController + layout 'admin' + menu_item :work_packages_setting + + def index + render 'work_packages/settings/work_package_tracking' + end + + def edit + if params[:settings] + Settings::UpdateService + .new(user: current_user) + .call(settings: permitted_params.settings.to_h) + + flash[:notice] = l(:notice_successful_update) + redirect_to action: 'index' + end + end + + def default_breadcrumb + t(:label_work_package_tracking) + end + + def show_local_breadcrumb + true + end +end diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index cb41ed6159..85ffe8d83c 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -36,10 +36,7 @@ module SettingsHelper [ { name: 'general', partial: 'settings/general', label: :label_general }, { name: 'display', partial: 'settings/display', label: :label_display }, - { name: 'authentication', partial: 'settings/authentication', label: :label_authentication }, - { name: 'users', partial: 'settings/users', label: :label_user_plural }, { name: 'projects', partial: 'settings/projects', label: :label_project_plural }, - { name: 'work_packages', partial: 'settings/work_packages', label: :label_work_package_tracking }, { name: 'notifications', partial: 'settings/notifications', label: Proc.new { User.human_attribute_name(:mail_notification) } }, { name: 'mail_handler', partial: 'settings/mail_handler', label: :label_incoming_emails }, { name: 'repositories', partial: 'settings/repositories', label: :label_repository_plural } diff --git a/app/services/settings/update_service.rb b/app/services/settings/update_service.rb new file mode 100644 index 0000000000..04c5ae3cf8 --- /dev/null +++ b/app/services/settings/update_service.rb @@ -0,0 +1,51 @@ +#-- encoding: UTF-8 + +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2019 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See doc/COPYRIGHT.rdoc for more details. +#++ + +class Settings::UpdateService < ::BaseServices::Update + attr_accessor :user + + def initialize(user) + self.user = user + end + + def call(settings:) + settings.each do |name, value| + if value.is_a?(Array) + # remove blank values in array settings + value.delete_if(&:blank?) + elsif value.is_a?(Hash) + value.delete_if { |_, v| v.blank? } + else + value = value.strip + end + Setting[name] = value + end + end +end diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb new file mode 100644 index 0000000000..a68144e58d --- /dev/null +++ b/app/views/admin/index.html.erb @@ -0,0 +1,41 @@ +<%#-- copyright +OpenProject is a project management system. +Copyright (C) 2012-2018 the OpenProject Foundation (OPF) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 3. + +OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +Copyright (C) 2006-2017 Jean-Philippe Lang +Copyright (C) 2010-2013 the ChiliProject Team + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +See docs/COPYRIGHT.rdoc for more details. + +++#%> + +<% html_title(l(:label_administration), l(:label_overview)) -%> + +<%= toolbar title: t(:label_overview) %> + +
diff --git a/app/views/admin/plugins.html.erb b/app/views/admin/plugins.html.erb index 0bf5f49044..5459da923c 100644 --- a/app/views/admin/plugins.html.erb +++ b/app/views/admin/plugins.html.erb @@ -36,7 +36,6 @@ See docs/COPYRIGHT.rdoc for more details.
-
-
-
-
- <%= AttributeHelpText.human_attribute_name(:attribute_name) %>
-
-
- |
-
-
-
-
-
- <%= AttributeHelpText.human_attribute_name(:help_text) %>
-
-
- |
- - - | -
---|---|---|
- <%= link_to h(attribute_help_text.attribute_caption), - edit_attribute_help_text_path(attribute_help_text) %> - | -
- |
- - <%= link_to( - op_icon('icon icon-delete'), - (attribute_help_text_path(attribute_help_text)), - method: :delete, - data: { confirm: I18n.t(:text_are_you_sure) }, - title: t(:button_delete)) %> - | -
+
+
+
+
+ <%= AttributeHelpText.human_attribute_name(:attribute_name) %>
+
+
+ |
+
+
+
+
+
+ <%= AttributeHelpText.human_attribute_name(:help_text) %>
+
+
+ |
+ + + | +
---|---|---|
+ <%= link_to h(attribute_help_text.attribute_caption), + edit_attribute_help_text_path(attribute_help_text) %> + | +
+ |
+ + <%= link_to( + op_icon('icon icon-delete'), + (attribute_help_text_path(attribute_help_text)), + method: :delete, + data: { confirm: I18n.t(:text_are_you_sure) }, + title: t(:button_delete)) %> + | +