Class: Pageflow::Admin::Tabs

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/admin/tabs.rb

Instance Method Summary collapse

Constructor Details

#initializeTabs

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.

Returns a new instance of Tabs.



5
6
7
# File 'lib/pageflow/admin/tabs.rb', line 5

def initialize
  @tabs = {}
end

Instance Method Details

#find_by_resource(resource) ⇒ 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.



33
34
35
36
37
# File 'lib/pageflow/admin/tabs.rb', line 33

def find_by_resource(resource)
  @tabs.fetch(resource_name(resource), []).map do |options|
    Tab.new(options, resource)
  end
end

#register(resource_name, options) ⇒ Object

Display additional tabs on admin resource pages.

Parameters:

  • resource_name (Symbol)

    A resource name like ‘:entry`, `:user`, `:account` or `:site`.

  • options (Hash)

Options Hash (options):

  • :name (Symbol)

    Unique identifier.

  • :component (Arbre::Component)

    Component to render as tab contents

  • :required_role (Symbol) — default: `nil`

    Requires the current user to either have an account or entry membership with at least the given role. By default all users can see the tab.

  • :required_account_role (Symbol) — default: `nil`

    Requires the current user to have an account membership with at least the given role. By default all users can see the tab. This option only takes effect for the entry resource.

  • :admin_only (Boolean) — default: `false`

    Allow only admins to see the tab.



27
28
29
30
# File 'lib/pageflow/admin/tabs.rb', line 27

def register(resource_name, options)
  @tabs[resource_name] ||= []
  @tabs[resource_name] << options
end