Migrate pajamas buttons in invitation template
Related to #384452 (closed)
What does this MR do and why?
Migrate buttons in app/views/invites/show.html.haml
to use the Pajamas::ButtonComponent
abstraction.
Screenshots or screen recordings
No change
before | after |
---|---|
How to set up and validate locally
- Apply this patch to render this template locally
patch
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb
index 2a7f2d42e2af..a9ffce153f0d 100644
--- a/app/controllers/invites_controller.rb
+++ b/app/controllers/invites_controller.rb
@@ -5,7 +5,6 @@ class InvitesController < ApplicationController
prepend_before_action :authenticate_user!, :track_invite_join_click, only: :show
before_action :member
- before_action :ensure_member_exists
before_action :invite_details
skip_before_action :authenticate_user!, only: :decline
@@ -64,7 +63,8 @@ def member?
def member
strong_memoize(:member) do
@token = params[:id]
- Member.find_by_invite_token(@token)
+ # Member.find_by_invite_token(@token)
+ Member.find_by_id(@token)
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 86145c94545a..88f9638009e4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1561,6 +1561,7 @@ def any_email?(check_email)
end
def verified_email?(check_email)
+ return false
downcased = check_email.downcase
# handle the outdated private commit email case
diff --git a/app/views/invites/show.html.haml b/app/views/invites/show.html.haml
index cf471c874373..8a5cb49ff4ef 100644
--- a/app/views/invites/show.html.haml
+++ b/app/views/invites/show.html.haml
@@ -1,27 +1,12 @@
- page_title _("Invitation")
%h1.page-title.gl-font-size-h-display= _("Invitation")
-- if current_user_matches_invite?
- - if member?
- %p
- = _("You are already a member of this %{member_source}.") % { member_source: @invite_details[:title] }
- .actions
- = link_to _("Go to %{source_name}") % { source_name: @invite_details[:title] }, @invite_details[:url], class: "btn gl-button btn-confirm"
-
- - else
- %p
- - inviter = @member.created_by
- - link_to_inviter = link_to(inviter.name, user_url(inviter))
- - link_to_source = link_to(@invite_details[:name], @invite_details[:url])
-
- = html_escape(_("You have been invited by %{link_to_inviter} to join %{source_name} %{strong_open}%{link_to_source}%{strong_close} as %{role}")) % { link_to_inviter: link_to_inviter, source_name: @invite_details[:title], strong_open: '<strong>'.html_safe, link_to_source: link_to_source, strong_close: '</strong>'.html_safe, role: @member.human_access }
-
- .actions
- = render Pajamas::ButtonComponent.new(variant: :confirm, method: :post, href: accept_invite_url(@token)) do
- = _("Accept invitation")
- = render Pajamas::ButtonComponent.new(variant: :danger, method: :post, href: decline_invite_url(@token)) do
- = _("Decline")
-
+- if !current_user_matches_invite?
+ .actions
+ = render Pajamas::ButtonComponent.new(variant: :confirm, method: :post, href: accept_invite_url(@token)) do
+ = _("Accept invitation")
+ = render Pajamas::ButtonComponent.new(variant: :danger, method: :post, href: decline_invite_url(@token)) do
+ = _("Decline")
- else
%p
- mail_to_invite_email = mail_to(@member.invite_email)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Dheeraj Joshi