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
Convert Project Boards from being Angular-rendered to Rails-rendered
Aaron Contreraseec442f35218
diff --git a/modules/boards/app/components/boards/table_component.rb b/modules/boards/app/components/boards/table_component.rbindex 90f202e0893..e44b5be602b 100644--- a/modules/boards/app/components/boards/table_component.rb+++ b/modules/boards/app/components/boards/table_component.rb@@ -30,7 +30,7 @@module Boardsclass TableComponent < ::TableComponent- columns :name, :project_id, :type, :created_at+ options :current_projectsortable_columns :name, :project_id, :created_atdef initial_sort@@ -46,5 +46,14 @@ module Boards[attr, { caption: Boards::Grid.human_attribute_name(attr) }]endend++ def columns+ @columns ||= [+ :name,+ (:project_id if current_project.blank?),+ :type,+ :created_at+ ].compact+ endendenddiff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rbindex 9326d75121a..dd94e23198e 100644--- a/modules/boards/app/controllers/boards/boards_controller.rb+++ b/modules/boards/app/controllers/boards/boards_controller.rb@@ -16,7 +16,7 @@ module ::Boardsmenu_item :board_viewdef index- render layout: 'angular/angular'+ @board_grids = Boards::Grid.includes(:project).where(project: @project)enddef overviewdiff --git a/modules/boards/app/views/boards/boards/index.html.erb b/modules/boards/app/views/boards/boards/index.html.erbindex d314de3539e..df99e3e8d2f 100644--- a/modules/boards/app/views/boards/boards/index.html.erb+++ b/modules/boards/app/views/boards/boards/index.html.erb@@ -1 +1,40 @@+<%#-- 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')) -%>++<%= toolbar title: t('boards.label_boards') do %>+ <%= render Boards::AddButtonComponent.new(current_project: @project) %>+<% end %>++<% if @board_grids.empty? -%>+ <%= no_results_box %>+<% else -%>+ <%= render Boards::TableComponent.new(rows: @board_grids, current_project: @project) %>+<% end -%>diff --git a/modules/boards/spec/features/board_index_spec.rb b/modules/boards/spec/features/board_index_spec.rbnew file mode 100644index 00000000000..ff0ed123b9a--- /dev/null+++ b/modules/boards/spec/features/board_index_spec.rb@@ -0,0 +1,120 @@+#-- 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.+#++++require 'spec_helper'+require_relative 'support/board_index_page'++RSpec.describe 'Work Package Project Boards Index Page',+ :js,+ :with_cuprite,+ with_ee: %i[board_view],+ with_flag: { more_global_index_pages: true } do+ # The identifier is important to test https://community.openproject.com/wp/29754+ shared_let(:project) { create(:project, identifier: 'boards', enabled_module_names: %i[work_package_tracking board_view]) }++ shared_let(:management_permissions) do+ %i[show_board_views manage_board_views add_work_packages view_work_packages manage_public_queries]+ end+ shared_let(:view_only_permissions) do+ %i[show_board_views add_work_packages view_work_packages]+ end++ shared_let(:priority) { create(:default_priority) }+ shared_let(:status) { create(:default_status) }++ let(:user) do+ create(:user,+ member_in_project: project,+ member_through_role: role)+ end+ let(:permissions) { management_permissions }+ let(:role) { create(:role, permissions:) }++ let(:board_view) { create(:board_grid_with_query, name: 'My board', project:) }+ let(:other_board_view) { create(:board_grid_with_query, name: 'My other board', project:) }++ let(:board_index) { Pages::BoardIndex.new(project) }++ before do+ login_as user+ end++ context 'as a user with board management permissions' do+ let(:permissions) { management_permissions }++ it 'shows a create button' do+ board_index.visit!++ board_index.expect_create_button+ end+ end++ context 'as a user without board management permissions' do+ let(:permissions) { view_only_permissions }++ it 'does not show a create button' do+ board_index.visit!++ board_index.expect_no_create_button+ end+ end++ context 'when no boards exist' do+ it 'displays the empty message' do+ board_index.visit!++ board_index.expect_no_boards_listed+ end+ end++ context 'when boards exists' do+ before do+ board_view+ other_board_view+ end++ it 'lists the boards' do+ board_index.visit!++ board_index.expect_boards_listed(board_view, other_board_view)+ end++ it 'paginates results', with_settings: { per_page_options: '1' } do+ # First page displays the historically last meeting+ board_index.visit!+ board_index.expect_boards_listed(board_view)+ board_index.expect_boards_not_listed(other_board_view)++ board_index.expect_to_be_on_page(1)++ board_index.to_page(2)+ board_index.expect_boards_listed(other_board_view)+ board_index.expect_boards_not_listed(board_view)+ end+ end+enddiff --git a/modules/boards/spec/features/support/board_index_page.rb b/modules/boards/spec/features/support/board_index_page.rbindex cb26f4b5377..700118f5e85 100644--- a/modules/boards/spec/features/support/board_index_page.rb+++ b/modules/boards/spec/features/support/board_index_page.rb@@ -45,6 +45,18 @@ module Pagesendend+ def expect_create_button+ within '.toolbar-items' do+ expect(page).to have_link 'Board'+ end+ end++ def expect_no_create_button+ within '.toolbar-items' do+ expect(page).not_to have_link 'Board'+ end+ end+def expect_editable(editable)# Editable / draggable checkexpect(page).to have_conditional_selector(editable, '.buttons a.icon-delete')@@ -56,6 +68,38 @@ module Pagesexpect(page).to have_conditional_selector(present, 'td.name', text: name)end+ def expect_boards_listed(*boards)+ within '#content-wrapper' do+ boards.each do |board|+ expect(page).to have_selector("td.name", text: board.name)+ end+ end+ end++ def expect_boards_not_listed(*boards)+ within '#content-wrapper' do+ boards.each do |board|+ expect(page).not_to have_selector("td.title", text: board.name)+ end+ end+ end++ def expect_no_boards_listed+ within '#content-wrapper' do+ expect(page).to have_content I18n.t(:no_results_title_text)+ end+ end++ def expect_to_be_on_page(number)+ expect(page).to have_selector('.op-pagination--item_current', text: number)+ end++ def to_page(number)+ within '.op-pagination--pages' do+ click_link number.to_s+ end+ end+def create_board(action: nil, expect_empty: false, via_toolbar: false)if via_toolbarpage.find('[data-qa-selector="sidebar--create-board-button"]').click