OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Refactor `/boards(/*state)` into separate `index` and `show` actions
Aaron Contrerasbdbaefd97036
diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rbindex dd94e23198e..bc689c38b92 100644--- a/modules/boards/app/controllers/boards/boards_controller.rb+++ b/modules/boards/app/controllers/boards/boards_controller.rb@@ -3,7 +3,7 @@ module ::Boardsbefore_action :find_optional_projectbefore_action :build_board_grid, only: %i[new]- with_options only: [:index] do+ with_options only: %i[index show] do# The boards permission alone does not suffice# to view work packagesbefore_action :authorize@@ -33,6 +33,10 @@ module ::Boards:boardsend+ def show+ render layout: 'angular/angular'+ end+def new; enddef create@@ -42,7 +46,7 @@ module ::Boardsif service_result.success?flash[:notice] = I18n.t(:notice_successful_create)- redirect_to board_grid_path+ redirect_to project_work_package_board_path(@project, @board_grid)else@errors = service_result.errorsrender action: :new@@ -92,9 +96,5 @@ module ::Boardsdef board_grid_paramsparams.require(:boards_grid).permit(%i[name attribute])end-- def board_grid_path- "/projects/#{@project.identifier}/boards/#{@board_grid.id}"- endendenddiff --git a/modules/boards/app/views/boards/boards/show.html.erb b/modules/boards/app/views/boards/boards/show.html.erbnew file mode 100644index 00000000000..3655423d098--- /dev/null+++ b/modules/boards/app/views/boards/boards/show.html.erb@@ -0,0 +1,30 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-2023 the OpenProject GmbH++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-2013 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 COPYRIGHT and LICENSE files for more details.++++#%>++<% html_title(t('boards.label_boards')) -%>diff --git a/modules/boards/config/routes.rb b/modules/boards/config/routes.rbindex 90c46cb5ee1..649cf0c6e72 100644--- a/modules/boards/config/routes.rb+++ b/modules/boards/config/routes.rb@@ -3,23 +3,18 @@ OpenProject::Application.routes.draw doresources :boards,controller: 'boards/boards',- only: %i[new create],+ only: %i[index show new create],as: :work_package_boards- scope '', as: :work_package_boards do- get '/boards(/*state)', to: 'boards/boards#index'- end-scope 'projects/:project_id', as: 'project' doresources :boards,controller: 'boards/boards',- only: %i[new],+ only: %i[index new show],as: :work_package_boards# Adding the `create` action into the above `resources` macro would# result in a name collision between it and `get /boards(/*state)`# as it would result in both being named `project_work_package_boards`post '/boards', to: 'boards/boards#create'- get '/boards(/*state)', to: 'boards/boards#index', as: :work_package_boardsendenddiff --git a/modules/boards/lib/open_project/boards/engine.rb b/modules/boards/lib/open_project/boards/engine.rbindex acc9cdf88d8..9e8a19d14f4 100644--- a/modules/boards/lib/open_project/boards/engine.rb+++ b/modules/boards/lib/open_project/boards/engine.rb@@ -29,7 +29,7 @@ module OpenProject::Boardsname: 'OpenProject Boards' doproject_module :board_view, dependencies: :work_package_tracking, order: 80 dopermission :show_board_views,- { 'boards/boards': %i[index overview] },+ { 'boards/boards': %i[index show overview] },dependencies: :view_work_packages,contract_actions: { boards: %i[read] }permission :manage_board_views,diff --git a/modules/boards/spec/routing/boards_routing_spec.rb b/modules/boards/spec/routing/boards_routing_spec.rbindex 06f991d1885..f4954bbbcf0 100644--- a/modules/boards/spec/routing/boards_routing_spec.rb+++ b/modules/boards/spec/routing/boards_routing_spec.rb@@ -31,8 +31,8 @@ require 'spec_helper'RSpec.describe 'Boards routing' doit doexpect(subject)- .to route(:get, '/projects/foobar/boards/state')- .to(controller: 'boards/boards', action: 'index', project_id: 'foobar', state: 'state')+ .to route(:get, '/boards/all')+ .to(controller: 'boards/boards', action: 'overview')endit do@@ -43,14 +43,14 @@ RSpec.describe 'Boards routing' doit doexpect(subject)- .to route(:get, '/boards/state')- .to(controller: 'boards/boards', action: 'index', state: 'state')+ .to route(:get, '/boards/1')+ .to(controller: 'boards/boards', action: 'show', id: 1)endit doexpect(subject)- .to route(:get, '/projects/foobar/boards/new')- .to(controller: 'boards/boards', action: 'new', project_id: 'foobar')+ .to route(:get, '/projects/foobar/boards/1')+ .to(controller: 'boards/boards', action: 'show', project_id: 'foobar', id: 1)endit do@@ -59,6 +59,12 @@ RSpec.describe 'Boards routing' do.to(controller: 'boards/boards', action: 'new')end+ it do+ expect(subject)+ .to route(:get, '/projects/foobar/boards/new')+ .to(controller: 'boards/boards', action: 'new', project_id: 'foobar')+ end+it doexpect(subject).to route(:post, '/projects/foobar/boards')