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 Enterprise Edition restriction to "action" board types
Aaron Contreras776a26e750dc
diff --git a/frontend/src/global_styles/content/_tiles.sass b/frontend/src/global_styles/content/_tiles.sassindex bdec05bcbac..589e0eeaeec 100644--- a/frontend/src/global_styles/content/_tiles.sass+++ b/frontend/src/global_styles/content/_tiles.sass@@ -26,6 +26,11 @@// See COPYRIGHT and LICENSE files for more details.//+++.form--field-container+ &.-enterprise-restricted+ flex-direction: column+ align-items: start+.form--field&.-align-startalign-items: start@@ -57,6 +62,9 @@border-radius: 10px !importantcursor: pointer+ &.-disabled+ @include button-disabled+&--contentdisplay: flexcolumn-gap: 0.75remdiff --git a/lib/open_project/static/links.rb b/lib/open_project/static/links.rbindex 25ef806c985..3b24469b797 100644--- a/lib/open_project/static/links.rb+++ b/lib/open_project/static/links.rb@@ -243,6 +243,9 @@ module OpenProjectattribute_highlighting: {href: 'https://www.openproject.org/docs/user-guide/work-packages/work-package-table-configuration/#attribute-highlighting-enterprise-add-on'},+ boards: {+ href: 'https://www.openproject.org/docs/user-guide/agile-boards/#action-boards-enterprise-add-on'+ },custom_field_projects: {href: 'https://www.openproject.org/docs/system-admin-guide/custom-fields/custom-fields-projects/'},diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rbindex 1ea820ac258..ca006393cb3 100644--- a/modules/boards/app/controllers/boards/boards_controller.rb+++ b/modules/boards/app/controllers/boards/boards_controller.rb@@ -37,6 +37,8 @@ module ::Boardsdef new; enddef create+ return render_403 if restricted_board_type?+service_result = service_call@board_grid = service_result.result@@ -62,6 +64,10 @@ module ::Boards@board_grid = Boards::Grid.newend+ def restricted_board_type?+ !EnterpriseToken.allows_to?(:board_view) && board_grid_params[:attribute] != 'basic'+ end+def service_callservice_class.new(user: User.current).call(diff --git a/modules/boards/app/helpers/boards_helper.rb b/modules/boards/app/helpers/boards_helper.rbindex 89aebf6fae1..339650e1706 100644--- a/modules/boards/app/helpers/boards_helper.rb+++ b/modules/boards/app/helpers/boards_helper.rb@@ -1,11 +1,15 @@# frozen_string_literal: truemodule BoardsHelper- BoardTypeAttributes = Struct.new(:radio_button_value, :title, :description, :image_path)+ BoardTypeAttributes = Struct.new(:radio_button_value,+ :title,+ :description,+ :image_path,+ :disabled?)def board_types[- build_board_type_attributes('basic', 'lists'),+ build_board_type_attributes('basic', 'lists', false),build_board_type_attributes('status', 'status'),build_board_type_attributes('assignee', 'assignees'),build_board_type_attributes('version', 'version'),@@ -14,10 +18,11 @@ module BoardsHelper]end- def build_board_type_attributes(type_name, image_name)+ def build_board_type_attributes(type_name, image_name, disabled = !EnterpriseToken.allows_to?(:board_view))BoardTypeAttributes.new(type_name,I18n.t("boards.board_type_attributes.#{type_name}"),I18n.t("boards.board_type_descriptions.#{type_name}"),- "assets/images/board_creation_modal/#{image_name}.svg")+ "assets/images/board_creation_modal/#{image_name}.svg",+ disabled)endenddiff --git a/modules/boards/app/views/boards/boards/_form.html.erb b/modules/boards/app/views/boards/boards/_form.html.erbindex d6d9f9573ff..34ebc8c3b24 100644--- a/modules/boards/app/views/boards/boards/_form.html.erb+++ b/modules/boards/app/views/boards/boards/_form.html.erb@@ -59,10 +59,24 @@ See COPYRIGHT and LICENSE files for more details.<div class="form--field -required -align-start"><label class="form--label" for="board_type"><%= t('boards.label_board_type') %></label>- <div class="form--field-container">+ <div class="form--field-container -enterprise-restricted">+ <% unless EnterpriseToken.allows_to?(:board_view) %>+ <p>+ <%= angular_component_tag 'op-enterprise-banner',+ inputs: {+ collapsible: false,+ opReferrer: 'boards',+ linkMessage: t('boards.upsale.upgrade'),+ textMessage: t('boards.upsale.teaser_text'),+ moreInfoLink: OpenProject::Static::Links.links[:enterprise_docs][:boards][:href]+ }+ %>+ </p>+ <% end %>+<div class="op-tile-block"><% board_types.each_with_index do |board_type, tile_number| %>- <label class="op-tile-block--tile form--radio-button-container -wide"+ <label class="op-tile-block--tile form--radio-button-container -wide <%= '-disabled' if board_type.disabled? %>"for="boards_grid_attribute_<%= board_type.radio_button_value %>"data-qa-selector="op-tile-block"><div class="op-tile-block--content">@@ -70,6 +84,7 @@ See COPYRIGHT and LICENSE files for more details.board_type.radio_button_value,tile_number == 0,no_label: true,+ disabled: board_type.disabled?,class: 'radio-button' %><div><span data-qa-selector="op-tile-block-title" class="op-tile-block--title">diff --git a/modules/boards/config/locales/en.yml b/modules/boards/config/locales/en.ymlindex 03e4b2efd38..e303e52bf32 100644--- a/modules/boards/config/locales/en.yml+++ b/modules/boards/config/locales/en.yml@@ -37,3 +37,7 @@ en:subtasks: >Board with automated columns for sub-elements.Dragging work packages to other lists updates the parent accordingly.++ upsale:+ teaser_text: 'Would you like to automate your workflows with Boards? Advanced boards are an Enterprise add-on. Please upgrade to a paid plan.'+ upgrade: 'Upgrade now'diff --git a/modules/boards/spec/features/boards_global_create_spec.rb b/modules/boards/spec/features/boards_global_create_spec.rbindex 80bdbc6b138..6c4bf4d8c40 100644--- a/modules/boards/spec/features/boards_global_create_spec.rb+++ b/modules/boards/spec/features/boards_global_create_spec.rb@@ -42,138 +42,151 @@ RSpec.describe 'Boards',new_board_page.visit!end- context 'with all fields set' do- before do- wait_for_reload # Halt until the project autocompleter is ready+ context 'with a Community Edition', with_ee: %i[] do+ it 'renders an enterprise banner and disables all restriced board types', :aggregate_failures do+ expect(page).to have_selector('op-enterprise-banner')+ expect(page).to have_selector(:radio_button, 'Basic')- new_board_page.set_title "Gotham Renewal Board"- new_board_page.set_project project+ %w[Status Assignee Version Subproject Parent-child].each do |restricted_board_type|+ expect(page).to have_selector(:radio_button, restricted_board_type, disabled: true)+ endend+ end- context 'when creating a "Basic" board' do+ context 'with an Enterprise Edition' do+ context 'with all fields set' dobefore do- new_board_page.set_board_type 'Basic'- new_board_page.click_on_submit+ wait_for_reload # Halt until the project autocompleter is ready- wait_for_reload+ new_board_page.set_title "Gotham Renewal Board"+ new_board_page.set_project projectend- it 'creates the board and redirects me to it' do- expect(page).to have_text(I18n.t(:notice_successful_create))- expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")- expect(page).to have_text "Gotham Renewal Board"- end- end+ context 'when creating a "Basic" board' do+ before do+ new_board_page.set_board_type 'Basic'+ new_board_page.click_on_submit- context 'when creating a "Status" board' do- before do- new_board_page.set_board_type 'Status'- new_board_page.click_on_submit+ wait_for_reload+ end- wait_for_reload+ it 'creates the board and redirects me to it' do+ expect(page).to have_text(I18n.t(:notice_successful_create))+ expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")+ expect(page).to have_text "Gotham Renewal Board"+ endend- it 'creates the board and redirects me to it' do- expect(page).to have_text(I18n.t(:notice_successful_create))- expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")- expect(page).to have_text "Gotham Renewal Board"- expect(page).to have_selector("[data-query-name='#{status.name}']")- end- end+ context 'when creating a "Status" board' do+ before do+ new_board_page.set_board_type 'Status'+ new_board_page.click_on_submit- context 'when creating an "Assignee" board' do- before do- new_board_page.set_board_type 'Assignee'- new_board_page.click_on_submit+ wait_for_reload+ end- wait_for_reload+ it 'creates the board and redirects me to it' do+ expect(page).to have_text(I18n.t(:notice_successful_create))+ expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")+ expect(page).to have_text "Gotham Renewal Board"+ expect(page).to have_selector("[data-query-name='#{status.name}']")+ endend- it 'creates the board and redirects me to it' do- expect(page).to have_text(I18n.t(:notice_successful_create))- expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")- expect(page).to have_text "Gotham Renewal Board"- end- end+ context 'when creating an "Assignee" board' do+ before do+ new_board_page.set_board_type 'Assignee'+ new_board_page.click_on_submit- context 'when creating a "Version" board' do- before do- new_board_page.set_board_type 'Version'- new_board_page.click_on_submit+ wait_for_reload+ end- wait_for_reload+ it 'creates the board and redirects me to it' do+ expect(page).to have_text(I18n.t(:notice_successful_create))+ expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")+ expect(page).to have_text "Gotham Renewal Board"+ endend- it 'creates the board and redirects me to it', :aggregate_failures do- expect(page).to have_text(I18n.t(:notice_successful_create))- expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")- expect(page).to have_text "Gotham Renewal Board"- versions.each do |version|- expect(page).to have_selector("[data-query-name='#{version.name}'")+ context 'when creating a "Version" board' do+ before do+ new_board_page.set_board_type 'Version'+ new_board_page.click_on_submit++ wait_for_reload+ end++ it 'creates the board and redirects me to it', :aggregate_failures do+ expect(page).to have_text(I18n.t(:notice_successful_create))+ expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")+ expect(page).to have_text "Gotham Renewal Board"+ versions.each do |version|+ expect(page).to have_selector("[data-query-name='#{version.name}'")+ endendend- end- context 'when creating a "Subproject" board' do- before do- new_board_page.set_board_type 'Subproject'- new_board_page.click_on_submit+ context 'when creating a "Subproject" board' do+ before do+ new_board_page.set_board_type 'Subproject'+ new_board_page.click_on_submit- wait_for_reload- end+ wait_for_reload+ end- it 'creates the board and redirects me to it' do- expect(page).to have_text(I18n.t(:notice_successful_create))- expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")- expect(page).to have_text "Gotham Renewal Board"+ it 'creates the board and redirects me to it' do+ expect(page).to have_text(I18n.t(:notice_successful_create))+ expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")+ expect(page).to have_text "Gotham Renewal Board"+ endend- end- context 'when creating a "Parent-child" board' do- before do- new_board_page.set_board_type 'Parent-child'- new_board_page.click_on_submit+ context 'when creating a "Parent-child" board' do+ before do+ new_board_page.set_board_type 'Parent-child'+ new_board_page.click_on_submit- wait_for_reload- end+ wait_for_reload+ end- it 'creates the board and redirects me to it' do- expect(page).to have_text(I18n.t(:notice_successful_create))- expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")- expect(page).to have_text "Gotham Renewal Board"+ it 'creates the board and redirects me to it' do+ expect(page).to have_text(I18n.t(:notice_successful_create))+ expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")+ expect(page).to have_text "Gotham Renewal Board"+ endendend- end- context 'when missing a required field' do- describe 'title' do- before do- wait_for_reload # Halt until the project autocompleter is ready+ context 'when missing a required field' do+ describe 'title' do+ before do+ wait_for_reload # Halt until the project autocompleter is ready- new_board_page.set_project(project)- new_board_page.click_on_submit- end+ new_board_page.set_project(project)+ new_board_page.click_on_submit+ end- it 'renders a required attribute validation error' do- expect(Boards::Grid.all).to be_empty+ it 'renders a required attribute validation error' do+ expect(Boards::Grid.all).to be_empty- # Required HTML attribute just warns- expect(page).to have_current_path(new_work_package_board_path)+ # Required HTML attribute just warns+ expect(page).to have_current_path(new_work_package_board_path)+ endend- end- describe 'project_id' do- before do- new_board_page.set_title("Batman's Itinerary")- new_board_page.click_on_submit+ describe 'project_id' do+ before do+ new_board_page.set_title("Batman's Itinerary")+ new_board_page.click_on_submit- wait_for_reload- end+ wait_for_reload+ end- it 'renders a required attribute validation error' do- expect(Boards::Grid.all).to be_empty+ it 'renders a required attribute validation error' do+ expect(Boards::Grid.all).to be_empty- expect(page).to have_text("Project can't be blank.")+ expect(page).to have_text("Project can't be blank.")+ endendendend