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
Add "Create New Board" button to Overview Page
Aaron Contreras83d14fd2cac5
diff --git a/modules/boards/app/components/boards/add_button_component.rb b/modules/boards/app/components/boards/add_button_component.rbnew file mode 100644index 00000000000..3bed8eb1912--- /dev/null+++ b/modules/boards/app/components/boards/add_button_component.rb@@ -0,0 +1,54 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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.+# +++#++module Boards+ class AddButtonComponent < ::AddButtonComponent+ def render?+ User.current.allowed_to_globally?(:manage_board_views)+ end++ def dynamic_path+ new_work_package_board_path+ end++ def id+ 'add-board-button'+ end++ def accessibility_label_text+ I18n.t('boards.label_create_new_board')+ end++ def label_text+ I18n.t('boards.label_board')+ end+ end+enddiff --git a/modules/boards/app/views/boards/boards/new.html.erb b/modules/boards/app/views/boards/boards/new.html.erbnew file mode 100644index 00000000000..6dda34e4adb--- /dev/null+++ b/modules/boards/app/views/boards/boards/new.html.erb@@ -0,0 +1,31 @@+<%#-- 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_create_new_board') %>+<%= toolbar title: t('boards.label_create_new_board') %>diff --git a/modules/boards/app/views/boards/boards/overview.html.erb b/modules/boards/app/views/boards/boards/overview.html.erbindex ae876b38d89..fc33c6bf6ea 100644--- a/modules/boards/app/views/boards/boards/overview.html.erb+++ b/modules/boards/app/views/boards/boards/overview.html.erb@@ -29,7 +29,9 @@ See COPYRIGHT and LICENSE files for more details.<% html_title(t('boards.label_boards')) -%>-<%= toolbar title: t('boards.label_boards') -%>+<%= toolbar title: t('boards.label_boards') do %>+ <%= render Boards::AddButtonComponent.new %>+<% end %><% if @board_grids.empty? -%><%= no_results_box %>diff --git a/modules/boards/config/locales/en.yml b/modules/boards/config/locales/en.ymlindex 893ca755275..c9b6613ba32 100644--- a/modules/boards/config/locales/en.yml+++ b/modules/boards/config/locales/en.yml@@ -7,6 +7,7 @@ en:boards:label_board: "Board"label_boards: "Boards"+ label_create_new_board: "Create new board"board_types:free: Basicaction: "Action board (%{attribute})"diff --git a/modules/boards/spec/features/board_overview_spec.rb b/modules/boards/spec/features/board_overview_spec.rbindex 60111488f78..aa46c26bb44 100644--- a/modules/boards/spec/features/board_overview_spec.rb+++ b/modules/boards/spec/features/board_overview_spec.rb@@ -29,27 +29,38 @@require 'spec_helper'require_relative './support/board_overview_page'-RSpec.describe 'Work Package boards overview spec',- with_cuprite: true,+RSpec.describe 'Work Package Boards Overview',+ :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(:other_project) { create(:project, 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) docreate(:user,member_in_project: project,member_through_role: role)end- # The identifier is important to test https://community.openproject.com/wp/29754- let(:project) { create(:project, identifier: 'boards', enabled_module_names: %i[work_package_tracking board_view]) }- let(:other_project) { create(:project, enabled_module_names: %i[work_package_tracking board_view]) }- let(:permissions) { %i[show_board_views manage_board_views add_work_packages view_work_packages manage_public_queries] }+ let(:permissions) { management_permissions }let(:role) { create(:role, permissions:) }- let!(:priority) { create(:default_priority) }- let!(:status) { create(:default_status) }- let(:board_overview) { Pages::BoardOverview.new }+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(:other_project_board_view) { create(:board_grid_with_query, name: 'Unseeable Board', project: other_project) }+ let(:board_overview) { Pages::BoardOverview.new }+before dologin_as userend@@ -60,6 +71,26 @@ RSpec.describe 'Work Package boards overview spec',board_overview.expect_global_menu_item_selectedend+ context 'as a user with board management permissions' do+ let(:permissions) { management_permissions }++ it 'shows a create button' do+ board_overview.visit!++ board_overview.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_overview.visit!++ board_overview.expect_no_create_button+ end+ end+context 'when no boards exist' doit 'displays the empty message' doboard_overview.visit!diff --git a/modules/boards/spec/features/support/board_overview_page.rb b/modules/boards/spec/features/support/board_overview_page.rbindex 793c115d545..dfaac149ac0 100644--- a/modules/boards/spec/features/support/board_overview_page.rb+++ b/modules/boards/spec/features/support/board_overview_page.rb@@ -41,6 +41,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_no_boards_listedwithin '#content-wrapper' doexpect(page).to have_content I18n.t(:no_results_title_text)