Skip to content

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

Replace the dropdown menu in the projects list with a Primer::Alpha::Action menu

Henriette Darge5324e36ccad3
diff --git a/app/components/members/row_component.rb b/app/components/members/row_component.rb
index faa931c9f10..41b96e6a06b 100644
--- a/app/components/members/row_component.rb
+++ b/app/components/members/row_component.rb
@@ -226,6 +226,7 @@ module Members
def view_work_package_shares_action_options
{
scheme: :default,
+ tag: :a,
icon: "op-view-list",
label: I18n.t(:button_view_shared_work_packages),
href: shared_work_packages_url
diff --git a/app/components/projects/row_component.html.erb b/app/components/projects/row_component.html.erb
index 9807cbe3fd5..8ed51f18924 100644
--- a/app/components/projects/row_component.html.erb
+++ b/app/components/projects/row_component.html.erb
@@ -37,19 +37,8 @@ See COPYRIGHT and LICENSE files for more details.
</td>
<% end %>
<td class="buttons">
- <% if more_menu_items.any? %>
- <ul class="project-actions">
- <li aria-haspopup="true" title="<%= I18n.t(:label_open_menu) %>" class="drop-down">
- <a class="icon icon-show-more-horizontal context-menu--icon" title="<%= t(:label_open_menu) %>" href></a>
- <ul style="display:none;" class="menu-drop-down-container">
- <% more_menu_items.each do |item| %>
- <li>
- <%= link_to(*item) %>
- </li>
- <% end %>
- </ul>
- </li>
- </ul>
+ <% button_links.each do |link| %>
+ <%= link %>
<% end %>
</td>
-</tr>
\ No newline at end of file
+</tr>
diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb
index e88037f71a2..5aa83b50b81 100644
--- a/app/components/projects/row_component.rb
+++ b/app/components/projects/row_component.rb
@@ -179,6 +179,40 @@ module Projects
end
end
+ def button_links
+ return [] if more_menu_items.empty?
+
+ if more_menu_items.one?
+ more_menu_items.first => {label:, **button_options}
+
+ [render(Primer::Beta::IconButton.new(**button_options,
+ size: :small,
+ tag: :a,
+ scheme: button_options[:scheme] == :default ? :invisible : button_options[:scheme],
+ "aria-label": label,
+ test_selector: "project-list-row--single-action"))]
+ else
+ [
+ render(Primer::Alpha::ActionMenu.new(test_selector: "project-list-row--action-menu")) do |menu|
+ menu.with_show_button(scheme: :invisible,
+ size: :small,
+ icon: :"kebab-horizontal",
+ "aria-label": t(:label_open_menu),
+ tooltip_direction: :w)
+ more_menu_items.each do |action_options|
+ action_options => {scheme:, label:, icon:, **button_options}
+ menu.with_item(scheme:,
+ label:,
+ test_selector: "project-list-row--action-menu-item",
+ content_arguments: button_options) do |item|
+ item.with_leading_visual_icon(icon:)
+ end
+ end
+ end
+ ]
+ end
+ end
+
def more_menu_items
@more_menu_items ||= [more_menu_subproject_item,
more_menu_settings_item,
@@ -191,70 +225,86 @@ module Projects
def more_menu_subproject_item
if User.current.allowed_in_project?(:add_subprojects, project)
- [t(:label_subproject_new),
- new_project_path(parent_id: project.id),
- { class: "icon-context icon-add",
- title: t(:label_subproject_new) }]
+ {
+ scheme: :default,
+ icon: :plus,
+ label: I18n.t(:label_subproject_new),
+ href: new_project_path(parent_id: project.id)
+ }
end
end
def more_menu_settings_item
if User.current.allowed_in_project?({ controller: "/projects/settings/general", action: "show", project_id: project.id },
project)
- [t(:label_project_settings),
- project_settings_general_path(project),
- { class: "icon-context icon-settings",
- title: t(:label_project_settings) }]
+ {
+ scheme: :default,
+ icon: :gear,
+ label: I18n.t(:label_project_settings),
+ href: project_settings_general_path(project)
+ }
end
end
def more_menu_activity_item
if User.current.allowed_in_project?(:view_project_activity, project)
- [
- t(:label_project_activity),
- project_activity_index_path(project, event_types: ["project_attributes"]),
- { class: "icon-context icon-checkmark",
- title: t(:label_project_activity) }
- ]
+ {
+ scheme: :default,
+ icon: :check,
+ label: I18n.t(:label_project_activity),
+ href: project_activity_index_path(project, event_types: ["project_attributes"]),
+ }
end
end
def more_menu_archive_item
if User.current.allowed_in_project?(:archive_project, project) && project.active?
- [t(:button_archive),
- project_archive_path(project, status: params[:status]),
- { data: { confirm: t("project.archive.are_you_sure", name: project.name) },
- method: :post,
- class: "icon-context icon-locked",
- title: t(:button_archive) }]
+ {
+ scheme: :default,
+ icon: :lock,
+ label: I18n.t(:button_archive),
+ rel: "nofollow",
+ href: project_archive_path(project, status: params[:status]),
+ data: {
+ confirm: t("project.archive.are_you_sure", name: project.name),
+ method: :post
+ },
+ }
end
end
def more_menu_unarchive_item
if User.current.admin? && project.archived? && (project.parent.nil? || project.parent.active?)
- [t(:button_unarchive),
- project_archive_path(project, status: params[:status]),
- { method: :delete,
- class: "icon-context icon-unlocked",
- title: t(:button_unarchive) }]
+ {
+ scheme: :default,
+ icon: :unlock,
+ label: I18n.t(:button_unarchive),
+ rel: "nofollow",
+ href: project_archive_path(project, status: params[:status]),
+ data: { method: :delete }
+ }
end
end
def more_menu_copy_item
if User.current.allowed_in_project?(:copy_projects, project) && !project.archived?
- [t(:button_copy),
- copy_project_path(project),
- { class: "icon-context icon-copy",
- title: t(:button_copy) }]
+ {
+ scheme: :default,
+ icon: :copy,
+ label: I18n.t(:button_copy),
+ href: copy_project_path(project),
+ }
end
end
def more_menu_delete_item
if User.current.admin
- [t(:button_delete),
- confirm_destroy_project_path(project),
- { class: "icon-context icon-delete",
- title: t(:button_delete) }]
+ {
+ scheme: :danger,
+ icon: :trash,
+ label: I18n.t(:button_delete),
+ href: confirm_destroy_project_path(project),
+ }
end
end
diff --git a/app/components/projects/table_component.html.erb b/app/components/projects/table_component.html.erb
index a6c8cac9197..5653fbe2652 100644
--- a/app/components/projects/table_component.html.erb
+++ b/app/components/projects/table_component.html.erb
@@ -35,7 +35,7 @@ See COPYRIGHT and LICENSE files for more details.
<% columns.each do |column| %>
<col <%= "opHighlightCol" unless column.attribute == :hierarchy %> >
<% end %>
- <col opHighlightCol>
+ <col>
</colgroup>
<thead class="-sticky">
<tr>
@@ -71,8 +71,8 @@ See COPYRIGHT and LICENSE files for more details.
</th>
<% end %>
<% end %>
- <th class="-right">
- <div class="generic-table--header-outer">
+ <th>
+ <div class="generic-table--empty-header">
</div>
</th>
</tr>
diff --git a/app/components/projects/table_component.rb b/app/components/projects/table_component.rb
index 4183827f40f..e065662df8c 100644
--- a/app/components/projects/table_component.rb
+++ b/app/components/projects/table_component.rb
@@ -51,6 +51,10 @@ module Projects
"project-table"
end
+ def container_class
+ "generic-table--container_visible-overflow"
+ end
+
##
# The project sort by is handled differently
def build_sort_header(column, options)
diff --git a/frontend/src/app/core/setup/globals/global-listeners.ts b/frontend/src/app/core/setup/globals/global-listeners.ts
index 33ed70aee73..40f4f24615a 100644
--- a/frontend/src/app/core/setup/globals/global-listeners.ts
+++ b/frontend/src/app/core/setup/globals/global-listeners.ts
@@ -152,7 +152,7 @@ export function initializeGlobalListeners():void {
setupToggableFieldsets();
// Action menu logic
- jQuery('.project-actions, .toolbar-items').each((idx:number, menu:HTMLElement) => {
+ jQuery('.toolbar-items').each((idx:number, menu:HTMLElement) => {
installMenuLogic(jQuery(menu));
});
diff --git a/frontend/src/global_styles/content/_projects_list.sass b/frontend/src/global_styles/content/_projects_list.sass
index d6f5eacc505..1cf6c3437b7 100644
--- a/frontend/src/global_styles/content/_projects_list.sass
+++ b/frontend/src/global_styles/content/_projects_list.sass
@@ -69,11 +69,6 @@ $project-table--description-indention: 9px
.expand
display: inline
- .project-actions
- display: inline-block
- margin: 0
- .menu-drop-down-container
- text-align: left
.archived
color: var(--color-fg-muted)
span.archived-label
diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb
index 635c4844be9..36bb36b6df7 100644
--- a/spec/features/projects/projects_index_spec.rb
+++ b/spec/features/projects/projects_index_spec.rb
@@ -177,16 +177,13 @@ RSpec.describe "Projects index page",
expect(page).to have_text(project.name)
# Test visibility of 'more' menu list items
- item = page.first("tbody tr .icon-show-more-horizontal", visible: :all)
- item.hover
- item.click
-
- menu = page.first("tbody tr .project-actions")
- expect(menu).to have_text("Copy")
- expect(menu).to have_text("Project settings")
- expect(menu).to have_text("New subproject")
- expect(menu).to have_text("Delete")
- expect(menu).to have_text("Archive")
+ projects_page.activate_menu_of(project) do |menu|
+ expect(menu).to have_text("Copy")
+ expect(menu).to have_text("Project settings")
+ expect(menu).to have_text("New subproject")
+ expect(menu).to have_text("Delete")
+ expect(menu).to have_text("Archive")
+ end
# Test visibility of admin only properties
within("#project-table") do
@@ -909,9 +906,9 @@ RSpec.describe "Projects index page",
expect(page).to have_text(parent_project.name)
- # 'More' does not become visible on hover
- page.find("tbody tr").hover
- expect(page).to have_no_css(".icon-show-more-horizontal")
+ # 'More' does not become visible
+ expect(page).to have_no_css('[data-test-selector="project-list-row--single-action"]')
+ expect(page).to have_no_css('[data-test-selector="project-list-row--action-menu"]')
# For a project member with :copy_projects privilege the 'More' menu is visible.
login_as(can_copy_projects_manager)
@@ -919,37 +916,15 @@ RSpec.describe "Projects index page",
expect(page).to have_text(parent_project.name)
- # 'More' becomes visible on hover
- # because we use css opacity we can not test for the visibility changes
- page.find("tbody tr").hover
- expect(page).to have_css(".icon-show-more-horizontal")
-
# Test visibility of 'more' menu list items
- page.find("tbody tr .icon-show-more-horizontal").click
- menu = page.find("tbody tr .project-actions")
- expect(menu).to have_text("Copy")
- expect(menu).to have_no_text("New subproject")
- expect(menu).to have_no_text("Delete")
- expect(menu).to have_no_text("Archive")
- expect(menu).to have_no_text("Unarchive")
+ expect(page).to have_css('[data-test-selector="project-list-row--single-action"] .octicon-copy')
# For a project member with :add_subprojects privilege the 'More' menu is visible.
login_as(can_add_subprojects_manager)
visit projects_path
- # 'More' becomes visible on hover
- # because we use css opacity we can not test for the visibility changes
- page.find("tbody tr").hover
- expect(page).to have_css(".icon-show-more-horizontal")
-
# Test visibility of 'more' menu list items
- page.find("tbody tr .icon-show-more-horizontal").click
- menu = page.find("tbody tr .project-actions")
- expect(menu).to have_text("New subproject")
- expect(menu).to have_no_text("Copy")
- expect(menu).to have_no_text("Delete")
- expect(menu).to have_no_text("Archive")
- expect(menu).to have_no_text("Unrchive")
+ expect(page).to have_css('[data-test-selector="project-list-row--single-action"] .octicon-plus')
# Test admin only properties are invisible
within("#project-table") do
@@ -1189,20 +1164,11 @@ RSpec.describe "Projects index page",
expect(page).to have_text(project.name)
- # 'More' becomes visible on hover
- # because we use css opacity we can not test for the visibility changes
- page.find("tbody tr", text: project.name).hover
- expect(page).to have_css(".icon-show-more-horizontal")
-
- # "Project activity" item should be displayed in the 'more' menu
- page.find("tbody tr .icon-show-more-horizontal").click
-
- menu = page.find("tbody tr .project-actions")
- expect(menu).to have_text(I18n.t(:label_project_activity))
+ expect(page).to have_css('[data-test-selector="project-list-row--single-action"] .octicon-check')
# Clicking the menu item should redirect to project activity page
# with only project attributes displayed
- menu.find_link(text: I18n.t(:label_project_activity)).click
+ page.find('[data-test-selector="project-list-row--single-action"]').click
expect(page).to have_current_path(project_activity_index_path(project_with_activity_enabled), ignore_query: true)
expect(page).to have_checked_field(id: "event_types_project_attributes")
diff --git a/spec/support/pages/projects/index.rb b/spec/support/pages/projects/index.rb
index 90c541f239c..a2e53053c86 100644
--- a/spec/support/pages/projects/index.rb
+++ b/spec/support/pages/projects/index.rb
@@ -307,10 +307,11 @@ module Pages
def activate_menu_of(project)
within_row(project) do |row|
row.hover
- menu = find("ul.project-actions")
- menu.click
+ menu = find("[data-test-selector='project-list-row--action-menu']")
+ menu_button = find("[data-test-selector='project-list-row--action-menu'] button")
+ menu_button.click
wait_for_network_idle if using_cuprite?
- expect(page).to have_css(".menu-drop-down-container")
+ expect(page).to have_css("[data-test-selector='project-list-row--action-menu-item']")
yield menu
end
end