Sha256: ab525da271613126f8fa1459790839b151d22d7aea2df5cc1b9f70f91d3ea28b

Contents?: true

Size: 981 Bytes

Versions: 4

Compression:

Stored size: 981 Bytes

Contents

module ActiveAdmin
  module Views
    class UtilityNav < Component
      def tag_name
        "p"
      end

      def build(namespace)
        super(:id => "utility_nav", :class => "header-item")
        @namespace = namespace

        if current_active_admin_user?
          build_current_user
          build_logout_link
        end
      end

      private

      def build_current_user
        span display_name(current_active_admin_user), :class => "current_user"
      end

      def build_logout_link
        if @namespace.logout_link_path
          text_node helpers.link_to(I18n.t('active_admin.logout'), active_admin_logout_path, :method => logout_method)
        end
      end

      # Returns the logout path from the application settings
      def active_admin_logout_path
        helpers.render_or_call_method_or_proc_on(self, @namespace.logout_link_path)
      end

      def logout_method
        @namespace.logout_link_method || :get
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activeadmin-0.5.1 lib/active_admin/views/utility_nav.rb
activeadmin-0.5.0 lib/active_admin/views/utility_nav.rb
activeadmin-0.5.0.pre1 lib/active_admin/views/utility_nav.rb
activeadmin-0.5.0.pre lib/active_admin/views/utility_nav.rb