Merge pull request #7444 from opf/feature/30285-30286-Create-new-admin-menu-nodes
[30285][30286] Rework of admin menu structurepull/7453/head
commit
0a338708f7
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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) %> |
||||||
|
|
||||||
|
<div class="menu-blocks--container"> |
||||||
|
<% @menu_nodes.each do |menu_node| -%> |
||||||
|
<%= link_to menu_node.url, { class: 'menu-block' } do %> |
||||||
|
<%= op_icon('menu-block--icon ' + menu_node.icon) %> |
||||||
|
<span class="menu-block--title"> <%= menu_node.caption %> </span> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
</div> |
@ -1,107 +0,0 @@ |
|||||||
<%#-- 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. |
|
||||||
|
|
||||||
++#%> |
|
||||||
|
|
||||||
<% entries = @texts_by_type[tab[:name]] || [] %> |
|
||||||
<% if entries.any? %> |
|
||||||
<div class="generic-table--container"> |
|
||||||
<div class="generic-table--results-container"> |
|
||||||
<table class="generic-table"> |
|
||||||
<colgroup> |
|
||||||
<col highlight-col> |
|
||||||
<col highlight-col> |
|
||||||
<col highlight-col> |
|
||||||
<col> |
|
||||||
</colgroup> |
|
||||||
<thead> |
|
||||||
<tr> |
|
||||||
<th> |
|
||||||
<div class="generic-table--sort-header-outer"> |
|
||||||
<div class="generic-table--sort-header"> |
|
||||||
<span> |
|
||||||
<%= AttributeHelpText.human_attribute_name(:attribute_name) %> |
|
||||||
</span> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</th> |
|
||||||
<th> |
|
||||||
<div class="generic-table--sort-header-outer"> |
|
||||||
<div class="generic-table--sort-header"> |
|
||||||
<span> |
|
||||||
<%= AttributeHelpText.human_attribute_name(:help_text) %> |
|
||||||
</span> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</th> |
|
||||||
<th> |
|
||||||
<div class="generic-table--empty-header"></div> |
|
||||||
</th> |
|
||||||
</tr> |
|
||||||
</thead> |
|
||||||
<tbody> |
|
||||||
<% entries.each do |attribute_help_text| -%> |
|
||||||
<tr class="attribute-help-text--entry"> |
|
||||||
<td> |
|
||||||
<%= link_to h(attribute_help_text.attribute_caption), |
|
||||||
edit_attribute_help_text_path(attribute_help_text) %> |
|
||||||
</td> |
|
||||||
<td> |
|
||||||
<attribute-help-text |
|
||||||
data-help-text-id="<%= attribute_help_text.id %>" |
|
||||||
data-attribute="<%= attribute_help_text.attribute_name %>" |
|
||||||
data-attribute-scope="'<%= attribute_help_text.attribute_scope %>'" |
|
||||||
data-additional-label="<%= t(:'attribute_help_texts.show_preview') %>"> |
|
||||||
</attribute-help-text> |
|
||||||
</td> |
|
||||||
<td class="buttons"> |
|
||||||
<%= 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)) %> |
|
||||||
</td> |
|
||||||
</tr> |
|
||||||
<% end %> |
|
||||||
</tbody> |
|
||||||
</table> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<% else %> |
|
||||||
<%= no_results_box %> |
|
||||||
<% end %> |
|
||||||
|
|
||||||
<div class="generic-table--action-buttons"> |
|
||||||
<%= link_to new_attribute_help_text_path(name: tab[:name]), |
|
||||||
{ class: 'attribute-help-texts--create-button button -alt-highlight', |
|
||||||
aria: {label: t(:'attribute_help_texts.add_new')}, |
|
||||||
title: t(:'attribute_help_texts.add_new')} do %> |
|
||||||
<%= op_icon('button--icon icon-add') %> |
|
||||||
<span class="button--text"><%= t('activerecord.models.attribute_help_text') %></span> |
|
||||||
<% end %> |
|
||||||
</div> |
|
@ -0,0 +1,88 @@ |
|||||||
|
#-- 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. |
||||||
|
#++ |
||||||
|
|
||||||
|
require 'spec_helper' |
||||||
|
|
||||||
|
describe AdminController, type: :controller do |
||||||
|
let(:user) { FactoryBot.build :admin } |
||||||
|
|
||||||
|
before do |
||||||
|
allow(User).to receive(:current).and_return user |
||||||
|
end |
||||||
|
|
||||||
|
describe '#index' do |
||||||
|
it 'renders index' do |
||||||
|
get :index |
||||||
|
|
||||||
|
expect(response).to be_successful |
||||||
|
expect(response).to render_template 'index' |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe '#plugins' do |
||||||
|
render_views |
||||||
|
|
||||||
|
context 'with plugins' do |
||||||
|
before do |
||||||
|
Redmine::Plugin.register :foo do end |
||||||
|
Redmine::Plugin.register :bar do end |
||||||
|
end |
||||||
|
|
||||||
|
it 'renders the plugins' do |
||||||
|
get :plugins |
||||||
|
|
||||||
|
expect(response).to be_successful |
||||||
|
expect(response).to render_template 'plugins' |
||||||
|
|
||||||
|
expect(response.body).to have_selector('td span', text: 'Foo') |
||||||
|
expect(response.body).to have_selector('td span', text: 'Bar') |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context 'without plugins' do |
||||||
|
before do |
||||||
|
Redmine::Plugin.clear |
||||||
|
end |
||||||
|
|
||||||
|
it 'renders even without plugins' do |
||||||
|
get :plugins |
||||||
|
expect(response).to be_successful |
||||||
|
expect(response).to render_template 'plugins' |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe '#info' do |
||||||
|
it 'renders info' do |
||||||
|
get :info |
||||||
|
|
||||||
|
expect(response).to be_successful |
||||||
|
expect(response).to render_template 'info' |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -1,102 +0,0 @@ |
|||||||
#-- 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. |
|
||||||
#++ |
|
||||||
require_relative '../legacy_spec_helper' |
|
||||||
require 'admin_controller' |
|
||||||
|
|
||||||
describe AdminController, type: :controller do |
|
||||||
render_views |
|
||||||
|
|
||||||
fixtures :all |
|
||||||
|
|
||||||
before do |
|
||||||
User.current = nil |
|
||||||
request.session[:user_id] = 1 # admin |
|
||||||
end |
|
||||||
|
|
||||||
it 'should index' do |
|
||||||
get :index |
|
||||||
assert_select 'div', false, |
|
||||||
attributes: { class: /nodata/ } |
|
||||||
end |
|
||||||
|
|
||||||
it 'should no plugins' do |
|
||||||
Redmine::Plugin.clear |
|
||||||
|
|
||||||
get :plugins |
|
||||||
assert_response :success |
|
||||||
assert_template 'plugins' |
|
||||||
end |
|
||||||
|
|
||||||
it 'should plugins' do |
|
||||||
# Register a few plugins |
|
||||||
Redmine::Plugin.register :foo do |
|
||||||
name 'Foo plugin' |
|
||||||
author 'John Smith' |
|
||||||
description 'This is a test plugin' |
|
||||||
version '0.0.1' |
|
||||||
settings default: { 'sample_setting' => 'value', 'foo' => 'bar' }, partial: 'foo/settings' |
|
||||||
end |
|
||||||
Redmine::Plugin.register :bar do |
|
||||||
end |
|
||||||
|
|
||||||
get :plugins |
|
||||||
assert_response :success |
|
||||||
assert_template 'plugins' |
|
||||||
|
|
||||||
assert_select 'td', child: { tag: 'span', content: 'Foo plugin' } |
|
||||||
assert_select 'td', child: { tag: 'span', content: 'Bar' } |
|
||||||
end |
|
||||||
|
|
||||||
it 'should info' do |
|
||||||
get :info |
|
||||||
assert_response :success |
|
||||||
assert_template 'info' |
|
||||||
end |
|
||||||
|
|
||||||
it 'should admin menu plugin extension' do |
|
||||||
Redmine::MenuManager.map :admin_menu do |menu| |
|
||||||
menu.push :test_admin_menu_plugin_extension, |
|
||||||
{ controller: '/admin', action: 'plugins' }, |
|
||||||
caption: 'Test' |
|
||||||
end |
|
||||||
|
|
||||||
User.current = User.find(1) |
|
||||||
|
|
||||||
get :plugins |
|
||||||
assert_response :success |
|
||||||
assert_select 'a', |
|
||||||
attributes: { href: '/admin/plugins' }, |
|
||||||
content: 'Test' |
|
||||||
|
|
||||||
Redmine::MenuManager.map :admin_menu do |menu| |
|
||||||
menu.delete :test_admin_menu_plugin_extension |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
Loading…
Reference in new issue