Class: Pageflow::Admin::AddMembershipButton Private
- Inherits:
-
ViewComponent
- Object
- Arbre::Component
- ViewComponent
- Pageflow::Admin::AddMembershipButton
- Defined in:
- app/views/components/pageflow/admin/add_membership_button.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
Instance Method Details
#build(user, parent, entity_type) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/views/components/pageflow/admin/add_membership_button.rb', line 7 def build(user, parent, entity_type) if parent.is_a?(User) = I18n.t("pageflow.admin.#{entity_type}.add") path = new_admin_user_membership_path( parent, entity_type: to_class_name(entity_type) ) data_tooltip = I18n.t("pageflow.admin.#{entity_type}." \ 'none_addable_tooltip') rel = "add_#{entity_type}_membership" elsif parent.is_a?(Entry) path = new_admin_entry_membership_path( parent, entity_type: to_class_name(entity_type) ) quota = Pageflow.config.quotas.get(:users, parent.account) else path = new_admin_account_membership_path( parent, entity_type: to_class_name(entity_type) ) end unless parent.is_a?(User) = I18n.t('pageflow.admin.users.add') data_tooltip = I18n.t('pageflow.admin.user.none_addable_tooltip') rel = 'add_member' end if parent.is_a?(Entry) && parent.account.users.length < 2 render('pageflow/admin/entries/cannot_add_user', user:, parent:, entity_type:, quota:) elsif membership_possible_for(user, parent, entity_type) para do link_to(, path, class: 'button', data: {rel:}) end else para(content_tag('a', , class: 'button disabled', data: {rel:}), 'data-tooltip' => data_tooltip) render 'pageflow/admin/users/cannot_add', user:, parent:, entity_type:, quota: end end |