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
Use Primer Button for "AddButtonComponent"
Henriette Dargeefe54cf8ca75
diff --git a/app/components/add_button_component.html.erb b/app/components/add_button_component.html.erbindex bfe3065020d..179a0cf8998 100644--- a/app/components/add_button_component.html.erb+++ b/app/components/add_button_component.html.erb@@ -1,9 +1,11 @@-<a href="<%= dynamic_path %>"- id="<%= id %>"- title="<%= title %>"- arial-label="<%= aria_label %>"- class="<%= link_css_class %>">- <%= icon %>- <%= label %>-</a>-+<%= render(Primer::ButtonComponent.new(scheme: :primary,+ aria: { label: aria_label },+ title:,+ test_selector:,+ tag: :a,+ id:,+ href: dynamic_path) ) do |button|+ button.with_leading_visual_icon(icon: :plus)+ label_text+end+%>diff --git a/app/components/add_button_component.rb b/app/components/add_button_component.rbindex 3b971f87af9..973e2283ece 100644--- a/app/components/add_button_component.rb+++ b/app/components/add_button_component.rb@@ -48,12 +48,6 @@ class AddButtonComponent < ApplicationComponentaccessibility_label_textend- def label- content_tag(:span,- label_text,- class: "button--text")- end-def aria_labelaccessibility_label_textend@@ -65,12 +59,4 @@ class AddButtonComponent < ApplicationComponentdef label_textraise "Specify the label text to be used for this component"end-- def link_css_class- "button -primary"- end-- def icon- helpers.op_icon("button--icon icon-add")- endenddiff --git a/modules/boards/app/components/boards/add_button_component.rb b/modules/boards/app/components/boards/add_button_component.rbindex fb2eac3cf06..495cde364bb 100644--- a/modules/boards/app/components/boards/add_button_component.rb+++ b/modules/boards/app/components/boards/add_button_component.rb@@ -47,6 +47,10 @@ module Boards"add-board-button"end+ def test_selector+ "add-board-button"+ end+def accessibility_label_textI18n.t("boards.label_create_new_board")enddiff --git a/modules/boards/app/views/boards/boards/index.html.erb b/modules/boards/app/views/boards/boards/index.html.erbindex 56996a595d0..256a0c4ae14 100644--- a/modules/boards/app/views/boards/boards/index.html.erb+++ b/modules/boards/app/views/boards/boards/index.html.erb@@ -40,7 +40,7 @@ See COPYRIGHT and LICENSE files for more details.<%=render Primer::OpenProject::SubHeader.new do |subheader|- subheader.with_action_component(data: { "test-selector": "add-board-button"}) do+ subheader.with_action_component dorender Boards::AddButtonComponent.new(current_project: @project)endenddiff --git a/modules/boards/spec/features/support/board_index_page.rb b/modules/boards/spec/features/support/board_index_page.rbindex 96083f2371c..bdcae4a11fd 100644--- a/modules/boards/spec/features/support/board_index_page.rb+++ b/modules/boards/spec/features/support/board_index_page.rb@@ -59,11 +59,9 @@ module Pagesdef create_board(action: "Basic", title: "#{action} Board", expect_empty: false, via_toolbar: true)if via_toolbar- within '[data-test-selector="add-board-button"]' do- click_link "Board"- end+ page.find_test_selector("add-board-button").clickelse- find('[data-test-selector="boards--create-button"]').click+ page.find_test_selector("boards--create-button").clickendnew_board_page = NewBoard.newdiff --git a/modules/boards/spec/features/support/board_list_page.rb b/modules/boards/spec/features/support/board_list_page.rbindex 921ae9ad134..e7720229b8b 100644--- a/modules/boards/spec/features/support/board_list_page.rb+++ b/modules/boards/spec/features/support/board_list_page.rb@@ -35,15 +35,11 @@ module Pagesenddef expect_create_button- within '[data-test-selector="add-board-button"]' do- expect(page).to have_link "Board"- end+ expect(page).to have_test_selector "add-board-button"enddef expect_no_create_button- within '[data-test-selector="add-board-button"]' do- expect(page).to have_no_link "Board"- end+ expect(page).not_to have_test_selector "add-board-button"enddef expect_delete_buttons(*boards)diff --git a/modules/boards/spec/features/support/board_new_page.rb b/modules/boards/spec/features/support/board_new_page.rbindex 869040a692e..f41ffca0ba2 100644--- a/modules/boards/spec/features/support/board_new_page.rb+++ b/modules/boards/spec/features/support/board_new_page.rb@@ -13,9 +13,7 @@ module Pagesdef navigate_by_create_buttonvisit work_package_boards_path unless page.current_path == work_package_boards_path- within '[data-test-selector="add-board-button"]' do- click_link "Board"- end+ page.find_test_selector("add-board-button").clickenddef set_title(title)diff --git a/modules/calendar/app/components/calendar/add_button_component.html.erb b/modules/calendar/app/components/calendar/add_button_component.html.erbdeleted file mode 100644index b1da75b2a66..00000000000--- a/modules/calendar/app/components/calendar/add_button_component.html.erb+++ /dev/null@@ -1,8 +0,0 @@-<a href="<%= dynamic_path %>"- id="<%= id %>"- title="<%= title %>"- arial-label="<%= aria_label %>"- class="<%= link_css_class %>">- <%= icon %>- <%= label %>-</a>diff --git a/modules/calendar/app/components/calendar/add_button_component.rb b/modules/calendar/app/components/calendar/add_button_component.rbindex 95d23f979aa..c825653bcce 100644--- a/modules/calendar/app/components/calendar/add_button_component.rb+++ b/modules/calendar/app/components/calendar/add_button_component.rb@@ -51,6 +51,10 @@ module Calendar"add-calendar-button"end+ def test_selector+ "add-calendar-button"+ end+def accessibility_label_textI18n.t("js.calendar.create_new")enddiff --git a/modules/calendar/app/views/calendar/calendars/index.html.erb b/modules/calendar/app/views/calendar/calendars/index.html.erbindex f1d7cdbf2b6..f380220465b 100644--- a/modules/calendar/app/views/calendar/calendars/index.html.erb+++ b/modules/calendar/app/views/calendar/calendars/index.html.erb@@ -39,7 +39,7 @@ See COPYRIGHT and LICENSE files for more details.<%=render Primer::OpenProject::SubHeader.new do |subheader|- subheader.with_action_component(data: { "test-selector": "add-calendar-button"}) do+ subheader.with_action_component dorender Calendar::AddButtonComponent.new(current_project: @project)endenddiff --git a/modules/calendar/spec/features/calendar_sharing_spec.rb b/modules/calendar/spec/features/calendar_sharing_spec.rbindex 46dd7c32aec..dc75f286c40 100644--- a/modules/calendar/spec/features/calendar_sharing_spec.rb+++ b/modules/calendar/spec/features/calendar_sharing_spec.rb@@ -140,7 +140,7 @@ RSpec.describe "Calendar sharing via ical", :js doit "shows disabled sharing menu item" dovisit project_calendars_path(project)- click_link "Create new calendar"+ page.find_test_selector("add-calendar-button").click# wait for settings button to become visibleexpect(page).to have_css("#work-packages-settings-button")diff --git a/modules/calendar/spec/support/pages/calendar.rb b/modules/calendar/spec/support/pages/calendar.rbindex 1f04bb41fc4..be68b344b29 100644--- a/modules/calendar/spec/support/pages/calendar.rb+++ b/modules/calendar/spec/support/pages/calendar.rb@@ -140,9 +140,7 @@ module Pagesenddef click_on_create_button- within '[data-test-selector="add-calendar-button"]' do- click_link "Calendar"- end+ page.find_test_selector("add-calendar-button").clickenddef click_on_cancel_button@@ -150,19 +148,19 @@ module Pagesenddef expect_create_button- expect(page).to have_css ".button", text: "Calendar"+ expect(page).to have_test_selector "add-calendar-button"enddef expect_no_create_button- expect(page).to have_no_css ".button", text: "Calendar"+ expect(page).not_to have_test_selector "add-calendar-button"enddef expect_delete_button(query)- expect(page).to have_css "[data-test-selector='calendar-remove-#{query.id}']"+ expect(page).to have_test_selector "calendar-remove-#{query.id}"enddef expect_no_delete_button(query)- expect(page).to have_no_css "[data-test-selector='calendar-remove-#{query.id}']"+ expect(page).not_to have_test_selector "calendar-remove-#{query.id}"enddef expect_no_views_visiblediff --git a/modules/team_planner/app/components/team_planner/add_button_component.rb b/modules/team_planner/app/components/team_planner/add_button_component.rbindex 3724dee5c52..19653b26861 100644--- a/modules/team_planner/app/components/team_planner/add_button_component.rb+++ b/modules/team_planner/app/components/team_planner/add_button_component.rb@@ -47,6 +47,10 @@ module TeamPlanner"add-team-planner-button"end+ def test_selector+ "add-team-planner-button"+ end+def accessibility_label_textI18n.t("team_planner.label_create_new_team_planner")enddiff --git a/modules/team_planner/app/views/team_planner/team_planner/index.html.erb b/modules/team_planner/app/views/team_planner/team_planner/index.html.erbindex 9cfb95ae7a9..73b03fe6f65 100644--- a/modules/team_planner/app/views/team_planner/team_planner/index.html.erb+++ b/modules/team_planner/app/views/team_planner/team_planner/index.html.erb@@ -10,7 +10,7 @@<%=render Primer::OpenProject::SubHeader.new do |subheader|- subheader.with_action_component(data: { "test-selector": "add-team-planner-button"}) do+ subheader.with_action_component dorender ::TeamPlanner::AddButtonComponent.new(current_project: @project)endenddiff --git a/modules/team_planner/app/views/team_planner/team_planner/overview.html.erb b/modules/team_planner/app/views/team_planner/team_planner/overview.html.erbindex 0cfe3fd8cd6..a123874b152 100644--- a/modules/team_planner/app/views/team_planner/team_planner/overview.html.erb+++ b/modules/team_planner/app/views/team_planner/team_planner/overview.html.erb@@ -9,7 +9,7 @@<%=render Primer::OpenProject::SubHeader.new do |subheader|- subheader.with_action_component(data: { "test-selector": "add-team-planner-button"}) do+ subheader.with_action_component dorender ::TeamPlanner::AddButtonComponent.newendenddiff --git a/modules/team_planner/spec/features/team_planner_spec.rb b/modules/team_planner/spec/features/team_planner_spec.rbindex 5fd1465fc86..b29c0e4304a 100644--- a/modules/team_planner/spec/features/team_planner_spec.rb+++ b/modules/team_planner/spec/features/team_planner_spec.rb@@ -43,7 +43,7 @@ RSpec.describe "Team planner",endexpect(page).to have_content "There is currently nothing to display."- click_on "Create", match: :first+ page.find_test_selector("add-team-planner-button").clickteam_planner.expect_titlediff --git a/modules/team_planner/spec/support/pages/team_planner.rb b/modules/team_planner/spec/support/pages/team_planner.rbindex 99cbfb08591..63751740896 100644--- a/modules/team_planner/spec/support/pages/team_planner.rb+++ b/modules/team_planner/spec/support/pages/team_planner.rb@@ -172,15 +172,11 @@ module Pagesenddef expect_create_button- within '[data-test-selector="add-team-planner-button"]' do- expect(page).to have_link text: "Team planner"- end+ expect(page).to have_test_selector "add-team-planner-button"enddef expect_no_create_button- within '[data-test-selector="add-team-planner-button"]' do- expect(page).to have_no_link text: "Team planner"- end+ expect(page).not_to have_test_selector "add-team-planner-button"enddef expect_views_listed_in_order(*queries)@@ -192,9 +188,7 @@ module Pagesenddef click_on_create_button- within '[data-test-selector="add-team-planner-button"]' do- click_link "Team planner"- end+ page.find_test_selector("add-team-planner-button").clickenddef click_on_cancel_button