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

Fixes about the dialog for generating tokens

Klaus Zanders57d2e3765f7e
diff --git a/app/components/my/access_token/api/row_component.rb b/app/components/my/access_token/api/row_component.rb
index 70641421e9c..a1ec1bc648d 100644
--- a/app/components/my/access_token/api/row_component.rb
+++ b/app/components/my/access_token/api/row_component.rb
@@ -59,9 +59,8 @@ module My
def delete_link
link_to "",
{
- controller: :my,
- action: "revoke_api_key",
- token_id: api_token.id
+ action: :revoke_api_key,
+ access_token_id: api_token.id
},
method: :delete,
data: { confirm: t("my_account.access_tokens.simple_revoke_confirmation"), test_selector: "api-token-revoke" },
diff --git a/app/components/my/access_token/api_tokens_section_component.html.erb b/app/components/my/access_token/api_tokens_section_component.html.erb
index 3527199661c..c916b443181 100644
--- a/app/components/my/access_token/api_tokens_section_component.html.erb
+++ b/app/components/my/access_token/api_tokens_section_component.html.erb
@@ -45,6 +45,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= render(
Primer::Beta::Button.new(
tag: :a,
+ mt: 3,
scheme: :primary,
test_selector: "api-token-add",
href: dialog_my_access_tokens_path(token_type: "api"),
diff --git a/app/components/my/access_token/new_access_token_component.html.erb b/app/components/my/access_token/new_access_token_dialog_component.html.erb
similarity index 87%
rename from app/components/my/access_token/new_access_token_component.html.erb
rename to app/components/my/access_token/new_access_token_dialog_component.html.erb
index 7d4764a3e7c..757f641cae9 100644
--- a/app/components/my/access_token/new_access_token_component.html.erb
+++ b/app/components/my/access_token/new_access_token_dialog_component.html.erb
@@ -30,17 +30,14 @@ See COPYRIGHT and LICENSE files for more details.
<%=
render(
Primer::Alpha::Dialog.new(
- id: "new-access-token-dialog",
+ id: DIALOG_ID,
title: I18n.t("my.access_token.new_access_token_dialog_title"),
- test_selector: "new-access-token-dialog",
+ test_selector: DIALOG_ID,
size: :large
)
) do |dialog|
- dialog.with_header(
- show_divider: false,
- visually_hide_title: false
- )
+ dialog.with_header(show_divider: false, visually_hide_title: false)
- render(My::AccessToken::NewAccessTokenFormComponent.new(token: Token::API.new))
+ render(My::AccessToken::NewAccessTokenFormComponent.new(token: new_token))
end
%>
diff --git a/app/components/my/access_token/new_access_token_component.rb b/app/components/my/access_token/new_access_token_dialog_component.rb
similarity index 74%
rename from app/components/my/access_token/new_access_token_component.rb
rename to app/components/my/access_token/new_access_token_dialog_component.rb
index 45e15b3a213..37be01b1f53 100644
--- a/app/components/my/access_token/new_access_token_component.rb
+++ b/app/components/my/access_token/new_access_token_dialog_component.rb
@@ -30,7 +30,26 @@
module My
module AccessToken
- class NewAccessTokenComponent < ApplicationComponent
+ class NewAccessTokenDialogComponent < ApplicationComponent
+ include OpTurbo::Streamable
+
+ attr_reader :token_type
+
+ def initialize(token_type: "api")
+ super
+ @token_type = token_type
+ end
+
+ DIALOG_ID = "new-access-token-dialog"
+
+ private
+
+ def new_token
+ case token_type
+ when "api" then Token::API.new
+ when "ical-meeting" then Token::ICalMeeting.new
+ end
+ end
end
end
end
diff --git a/app/controllers/my/access_tokens_controller.rb b/app/controllers/my/access_tokens_controller.rb
index 85ba7ec8e17..591bec72a7f 100644
--- a/app/controllers/my/access_tokens_controller.rb
+++ b/app/controllers/my/access_tokens_controller.rb
@@ -30,6 +30,8 @@
module My
class AccessTokensController < ::ApplicationController
+ include OpTurbo::ComponentStream
+
before_action :require_login
before_action :set_current_user
@@ -50,6 +52,10 @@ module My
:revoke_ical_token,
:delete_storage_token
+ def dialog
+ @token_type = params[:token_type] || "api"
+ end
+
def index
@ical_meeting_tokens = current_user.ical_meeting_tokens
diff --git a/app/views/my/access_tokens/dialog.turbo_stream.erb b/app/views/my/access_tokens/dialog.turbo_stream.erb
index df147cb9ac6..7a40bbfc58a 100644
--- a/app/views/my/access_tokens/dialog.turbo_stream.erb
+++ b/app/views/my/access_tokens/dialog.turbo_stream.erb
@@ -1,3 +1,3 @@
<%= turbo_stream.dialog do
- render(My::AccessToken::NewAccessTokenComponent.new(token_type: @token_type))
+ render(My::AccessToken::NewAccessTokenDialogComponent.new(token_type: @token_type))
end %>