start placing project settings into nested module

pull/9779/head
ulferts 3 years ago
parent 9ecd930d52
commit 79e9008091
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 10
      app/controllers/projects/settings/modules_controller.rb
  2. 2
      app/helpers/project_settings_helper.rb
  3. 2
      app/views/projects/settings/modules/_form.html.erb
  4. 4
      app/views/projects/settings/modules/show.html.erb
  5. 6
      config/initializers/permissions.rb
  6. 19
      config/routes.rb
  7. 12
      spec/controllers/projects_settings_menu_controller_spec.rb
  8. 2
      spec/features/global_roles/no_module_spec.rb
  9. 2
      spec/features/wiki/adding_editing_history_spec.rb

@ -28,13 +28,9 @@
# See COPYRIGHT and LICENSE files for more details.
#++
class ProjectSettings::ModulesController < ProjectSettingsController
class Projects::Settings::ModulesController < ProjectSettingsController
menu_item :settings_modules
def show
render template: 'project_settings/modules'
end
def update
call = Projects::EnabledModulesService
.new(model: @project, user: current_user)
@ -43,10 +39,10 @@ class ProjectSettings::ModulesController < ProjectSettingsController
if call.success?
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to settings_modules_project_path(@project)
redirect_to modules_settings_project_path(@project)
else
@errors = call.errors
render 'project_settings/modules'
render 'show'
end
end
end

@ -39,7 +39,7 @@ module ProjectSettingsHelper
},
{
name: 'modules',
action: { controller: '/project_settings/modules', action: 'show' },
action: { controller: '/projects/settings/modules', action: 'show' },
if: ->(project) { User.current.allowed_to?(:select_project_modules, project) },
label: :label_module_plural
},

@ -27,7 +27,7 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% sorted_modules = OpenProject::AccessControl.available_project_modules.sort_by { |name| l_or_humanize(name, prefix: "project_module_") } %>
<% sorted_modules = OpenProject::AccessControl.available_project_modules.sort_by { |name| t(:"project_module_#{name}") } %>
<% sorted_modules.each do |name| %>
<div class="form--field">
<%= form.collection_check_box :enabled_module_names,

@ -34,10 +34,10 @@ See COPYRIGHT and LICENSE files for more details.
<%= error_messages_for_contract(@project, @errors) %>
<%= labelled_tabular_form_for @project,
url: settings_modules_project_path(@project),
url: modules_settings_project_path(@project),
method: :patch do |form| %>
<%= render partial: "/projects/form/modules",
<%= render partial: "form",
locals: { form: form } %>
<p><%= form.button t(:button_save), class: 'button -highlight -with-icon icon-checkmark' %></p>

@ -47,7 +47,7 @@ OpenProject::AccessControl.map do |map|
map.permission :manage_user,
{
users: %i[index show new create edit update resend_invitation],
"users/memberships": %i[create update destroy],
'users/memberships': %i[create update destroy],
admin: %i[index]
},
require: :loggedin,
@ -57,7 +57,7 @@ OpenProject::AccessControl.map do |map|
map.permission :manage_placeholder_user,
{
placeholder_users: %i[index show new create edit update deletion_info destroy],
"placeholder_users/memberships": %i[create update destroy],
'placeholder_users/memberships': %i[create update destroy],
admin: %i[index]
},
require: :loggedin,
@ -85,7 +85,7 @@ OpenProject::AccessControl.map do |map|
map.permission :select_project_modules,
{
projects: :modules,
'project_settings/modules': %i[show update]
'projects/settings/modules': %i[show update]
},
require: :member,
dependencies: :edit_project

@ -180,9 +180,26 @@ OpenProject::Application.routes.draw do
scope module: 'projects' do
post :templated, controller: 'templated', action: :create
delete :templated, controller: 'templated', action: :destroy
namespace 'settings' do
ProjectSettingsHelper
.project_settings_tabs
.select { |s| s[:name] == 'modules' }
.each do |tab|
get tab[:name],
controller: tab[:name],
action: :show
patch tab[:name],
controller: tab[:name],
action: :update
end
end
end
ProjectSettingsHelper.project_settings_tabs.each do |tab|
ProjectSettingsHelper
.project_settings_tabs
.reject { |s| s[:name] == 'modules' }
.each do |tab|
get "settings/#{tab[:name]}",
controller: "project_settings/#{tab[:name]}",
action: :show,

@ -28,7 +28,7 @@
require 'spec_helper'
describe ProjectSettings::ModulesController, 'menu', type: :controller do
describe Projects::Settings::ModulesController, 'menu', type: :controller do
let(:current_user) do
FactoryBot.build_stubbed(:user).tap do |u|
allow(u)
@ -58,7 +58,7 @@ describe ProjectSettings::ModulesController, 'menu', type: :controller do
it 'renders show' do
get 'show', params: @params
expect(response).to be_successful
expect(response).to render_template 'project_settings/modules'
expect(response).to render_template 'projects/settings/modules/show'
end
it 'renders main menu without wiki menu item' do
@ -79,7 +79,7 @@ describe ProjectSettings::ModulesController, 'menu', type: :controller do
it 'renders show' do
get 'show', params: @params
expect(response).to be_successful
expect(response).to render_template 'project_settings/modules'
expect(response).to render_template 'projects/settings/modules/show'
end
it 'renders main menu with wiki menu item' do
@ -105,7 +105,7 @@ describe ProjectSettings::ModulesController, 'menu', type: :controller do
it 'renders show' do
get 'show', params: @params
expect(response).to be_successful
expect(response).to render_template 'project_settings/modules'
expect(response).to render_template 'projects/settings/modules/show'
end
it 'renders main menu with wiki menu item' do
@ -131,7 +131,7 @@ describe ProjectSettings::ModulesController, 'menu', type: :controller do
it 'renders show' do
get 'show', params: @params
expect(response).to be_successful
expect(response).to render_template 'project_settings/modules'
expect(response).to render_template 'projects/settings/modules/show'
end
it 'renders main menu with activity tab' do
@ -149,7 +149,7 @@ describe ProjectSettings::ModulesController, 'menu', type: :controller do
it 'renders show' do
get 'show', params: @params
expect(response).to be_successful
expect(response).to render_template 'project_settings/modules'
expect(response).to render_template 'projects/settings/modules/show'
end
it 'renders main menu without activity tab' do

@ -49,7 +49,7 @@ describe 'Global role: No module', type: :feature, js: true do
# And I am already admin
# When I go to the modules tab of the settings page for the project "test"
# Then I should not see "Global"
visit settings_modules_project_path(project)
visit modules_settings_project_path(project)
expect(page).to have_text 'Activity'
expect(page).to have_no_text 'Foo'

@ -57,7 +57,7 @@ describe 'wiki pages', type: :feature, js: true, with_settings: { journal_aggreg
end
scenario 'adding, editing and history' do
visit settings_modules_project_path(project)
visit modules_settings_project_path(project)
expect(page).to have_no_selector('.menu-sidebar .main-item-wrapper', text: 'Wiki')

Loading…
Cancel
Save