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

primerize the auto login table

Behrokh Satarnejade317d8867e99
diff --git a/app/components/users/auto_login_tokens/row_component.rb b/app/components/users/auto_login_tokens/row_component.rb
index 95c8eeabf9d..d79cc05bf31 100644
--- a/app/components/users/auto_login_tokens/row_component.rb
+++ b/app/components/users/auto_login_tokens/row_component.rb
@@ -30,7 +30,7 @@
module Users
module AutoLoginTokens
- class RowComponent < ::RowComponent
+ class RowComponent < ::OpPrimer::BorderBoxRowComponent
delegate :current_token, to: :table
def token
@@ -68,22 +68,47 @@ module Users
helpers.format_date(expires)
end
+ def actions
+ action_menu
+ end
+
+ private
+
def button_links
- [delete_link].compact
+ [action_menu]
+ end
+
+ def action_menu
+ render(Primer::Alpha::ActionMenu.new(anchor_align: :end)) do |menu|
+ menu.with_show_button(
+ icon: "kebab-horizontal",
+ "aria-label": t(:label_more),
+ scheme: :invisible,
+
+ data: { "test-selector": "more-button" }
+ )
+ delete_action(menu)
+ end
end
- def delete_link
+ def delete_action(menu)
return if current?
- link_to(
- helpers.op_icon("icon icon-delete"),
- { controller: "/my/auto_login_tokens", action: "destroy", id: token.id },
- class: "button--link",
- role: :button,
- method: :delete,
- data: { confirm: I18n.t(:text_are_you_sure), disable_with: I18n.t(:label_loading) },
- title: I18n.t(:button_delete)
- )
+ menu.with_item(
+ label: I18n.t(:button_delete),
+ scheme: :danger,
+ href: url_for({ controller: "/my/auto_login_tokens", action: "destroy", id: token.id }),
+ tag: :button,
+ form_arguments: { method: :delete },
+ content_arguments: {
+ data: {
+ confirm: I18n.t(:text_are_you_sure),
+ disable_with: I18n.t(:label_loading)
+ }
+ }
+ ) do |item|
+ item.with_leading_visual_icon(icon: :trash)
+ end
end
end
end
diff --git a/app/components/users/auto_login_tokens/table_component.rb b/app/components/users/auto_login_tokens/table_component.rb
index 11c2879d7ea..fc0a6a239c9 100644
--- a/app/components/users/auto_login_tokens/table_component.rb
+++ b/app/components/users/auto_login_tokens/table_component.rb
@@ -30,13 +30,18 @@
module Users
module AutoLoginTokens
- class TableComponent < ::TableComponent
+ class TableComponent < ::OpPrimer::BorderBoxTableComponent
columns :is_current, :browser, :device, :expires_on
sortable_columns :updated_at
options :current_token
+ mobile_columns :is_current, :browser, :device, :expires_on
- def sortable?
- false
+ def mobile_title
+ t("users.sessions.remembered_devices")
+ end
+
+ def has_actions?
+ true
end
def headers
diff --git a/app/components/users/sessions/table_component.rb b/app/components/users/sessions/table_component.rb
index 39246572414..17314f0eeaf 100644
--- a/app/components/users/sessions/table_component.rb
+++ b/app/components/users/sessions/table_component.rb
@@ -42,6 +42,7 @@ module Users
def has_actions?
true
end
+
def initial_sort
%i[updated_at desc]
end