-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🦋Update provider account Invitations index page #3923
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
# TODO: remove and use presenter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are only two small methods left here, why not move them to the presenter directly instead of leaving a TODO? |
||
module InvitationsHelper | ||
def invitation_sent_date(invitation) | ||
invitation.sent_at&.to_s(:long) || 'Not sent yet' | ||
|
@@ -10,9 +13,4 @@ def invitation_status(invitation) | |
"no" | ||
end | ||
end | ||
|
||
def button_to_resend_buyer_invitation(invitation) | ||
fancy_link_to('Resend', resend_provider_admin_account_invitation_path(invitation.account,invitation), | ||
{ :id => "resend-invitation-#{invitation.id}", :method => :put }) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# frozen_string_literal: true | ||
|
||
class Provider::Admin::Account::InvitationsIndexPresenter | ||
include System::UrlHelpers.system_url_helpers | ||
include InvitationsHelper | ||
|
||
alias status invitation_status | ||
alias sent_date invitation_sent_date | ||
|
||
def initialize(invitations, user, params) | ||
@ability = Ability.new(user) | ||
pagination_params = { page: params[:page] || 1, per_page: params[:per_page] || 20 } | ||
sorting_params = "#{params[:sort].presence || 'sent_at'} #{params[:direction].presence || 'desc'}" | ||
@invitations = invitations.paginate(pagination_params) | ||
.reorder(sorting_params) | ||
end | ||
|
||
attr_reader :invitations | ||
|
||
def empty_state? | ||
@invitations.total_entries.zero? | ||
end | ||
|
||
def can_send_invitations? | ||
@ability.can?(:create, Invitation) && @ability.can?(:see, :multiple_users) | ||
end | ||
|
||
# def sent_date(invitation) | ||
# invitation.sent_at&.to_s(:long) || 'Not sent yet' | ||
# end | ||
|
||
# def status(invitation) | ||
# invitation_status(invitation) | ||
# # if invitation.accepted? | ||
# # "yes, on #{invitation.accepted_at.to_s(:short)}" | ||
# # else | ||
# # 'no' | ||
# # end | ||
# end | ||
Comment on lines
+28
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better don't push commented code IMO |
||
|
||
def can_manage_invitation?(invitation) | ||
@can_manage_invitation ||= @ability.can?(:manage, invitation) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks wrong, after the first call, it will cache the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would actually work in this case, because for the provider users the abilities are for the whole class, there is no condition that would make it different for different invitations - it's either allowed for all, or not allowed for all. But I agree that still it's not right 😬 |
||
end | ||
|
||
def toolbar_props | ||
{ | ||
totalEntries: @invitations.total_entries, | ||
actions: [{ | ||
variant: :primary, | ||
label: I18n.t('provider.admin.account.invitations.index.send_invitation_title'), | ||
href: new_provider_admin_account_invitation_path | ||
}] | ||
} | ||
end | ||
|
||
end |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is not used anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not really but it was added 10+ years ago and I think XML responses are only used by API endpoints.
There is nothing about it in 3scale API docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE: After some digging I can't really justify removing this response so I will restore it and add a comment for posterity.