Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow disabling dashboard #501

Closed
brain-geek opened this Issue · 29 comments
@brain-geek

It should be possible to disable dashboard at all - and use one of resources as main page of backend. I haven`t found any way to do so in docs or api.

In my project, I have 3 resources. And there is nothing to put on dashboard, so users see empty page after logging in, instead of something useful.

@mitchwd

+1

@pcreux
Collaborator

We could add the following option to the initializer:

display_dashboard = false

In the meantime, you can add the following to your routes:

  match 'admin', :to => 'admin/categories#index'
@brain-geek

Maybe, more like this:

ActiveAdmin.setup do |config|
  config.replace_dashboard_with :products
end
@mattvague
Collaborator

How about:

ActiveAdmin.setup do |config|

  # Enable dashboard (by default)
  config.dashboard  = true

  # Disable dashboard
  config.dashboard = false

  # Change dashboard to model
  config.dashboard  = :products

end
@brain-geek

This would be great.

@mitchwd

Really love mattvague's implementation.

@charlietran

+1 to mattvague's idea

@ahx

Disabling the dashboard on a per-namespace basis would be really handy, too.

@brain-geek

I`ve added basic code for this feature, but tests dont pass. brain-geek@883a136

@mattvague mattvague was assigned
@oki

+1 for this feature

@mrli

i just add

ActiveAdmin.setup do |config|

# Enable dashboard (by default)
config.dashboard = true

# Disable dashboard
config.dashboard = false

# Change dashboard to model
config.dashboard = :products

end

for my code but not work .

@latortuga

@lb563 this thread is a suggestion for that kind of syntax, it's not implemented yet.

@mrli

oh .yes .hope to that become true.

@msaspence

+1 to mattvague's idea

@msaspence

also the ability to name custom pages dashboard when dashboard disabled
currently causes "superclass mismatch for class DashboardController"

@pcreux pcreux closed this
@brain-geek

@pcreux Why have you closed this issue? Lot of people voted for it, so it may be really useful as feature request.

@ekortright

I think this would be very useful to have, even if it's only the ability to turn the dashboard on or off.

Currently (as of v. 0.4.4), you can replace the dashboard with another page by assigning the menu label "Dashboard" to the new page, but some people just don't have a need for a dashboard page.

@Lyricalpanda

Well what I need is actually something similar. I'd like to conditionally hide the dashboard, based on user role. So user.role=='ADMIN' will show the dashboard, but user.role=='INTERN' will hide it. It's achievable for resources, not sure why it's not for the dashboard.

@brendon

In app/admin/dashboard.rb you can just set menu false and that will hide the dashboard button.

Then in your config/initializers/active_admin.rb set something like:

config.root_to = 'entities#index'

My main controller is Entities in this case. That effectively hides the dashboard. I guess you could still browse to it manually...

@tonyc

I'm running into this issue as well, I don't have a good way to add a before_filter to the Dashboards controller (can't find a decent way to do it, maybe it is there), so I also can't disable /admin/dashboads for non-admin users, like I do the other "normal" resource controllers.

Simply hiding the menu item doesn't cause people poking and prodding into the URL by accident.

@seanlinsley
Owner

Hey guys, Active Admin version 0.5.x removes the old built-in Dashboard construct. Now a dashboard is a regular page, and you can do anything you want to it (including remove it). To see the new syntax, check out the file that would be automatically added if you made a new Rails application with 0.5.x.

@tonyc

Oh, thanks. I didn't even think to even think about checking to see if removing the file would help.

I'm still struggling with allowing the dashboard to admin users and disallowing to non-admin users, but that's a different issue entirely.

Thanks again!

@seanlinsley
Owner

@tonyc, if you just want to redirect non-admin users to a different page, do this:

controller do
  def index
    redirect_to whatever_path unless current_user.admin?
  end
end
@brendon

I added an administrator boolean column to the admin_users table and this is the setup for my admin_user.rb file:

ActiveAdmin.register AdminUser, :as => 'User' do     

  menu :if => proc{ current_admin_user.administrator? }

  index do
    column :email
    column :administrator do |admin_user|
      admin_user.administrator? ? 'Yes' : 'No'
    end
    column :current_sign_in_at
    column :current_sign_in_ip
    column :last_sign_in_at
    column :last_sign_in_ip
    column :sign_in_count
    default_actions
  end

  form do |f|       
    f.inputs "Admin Details" do
      f.input :email
      f.input :password
      f.input :password_confirmation
      f.input :administrator, :as => :radio
    end
    f.buttons
  end

  controller do
    before_filter :check_for_administrator

    def check_for_administrator
      redirect_to some_other_path, :alert => 'You are not an administrator!' unless current_admin_user.administrator?
    end
  end
end

Notes: I wanted to refer to the AdminUsers as Users in the admin interface though in the database I have a seperate users table for the main app (thus the `as => 'User' parameter).

@seanlinsley
Owner

@brendon, could you slim down that code example? There's a lot of extra stuff in there that obscures your point. This is what matters:

ActiveAdmin.register AdminUser, :as => 'User' do
  menu :if => proc{ current_admin_user.administrator? }

  controller do
    before_filter :check_for_administrator

    def check_for_administrator
      redirect_to some_other_path, :alert => 'You are not an administrator!' unless current_admin_user.administrator?
    end
  end
end
@brendon

Hi Daxter, that's fair enough. I've removed a bit of extraneous detail but thought I'd show an implementation for those wanting a bit more detail. Perhaps this was the wrong place to post it? I thought tonyc might have wanted to see the interface implementation of the administrator option.

@seanlinsley
Owner

If you run into that type of situation, the options are (in order of desirability):

  • if it's short enough, have code inline in your comment
  • else, link to (and potentially write up documentation for) either the official docs or the wiki
  • else, link to a Gist from your comment for anyone interested

At least that's my thoughts on how to best share info here on GitHub.

@brendon

Thanks Daxter, point taken. Do you want me to remove the code above or just leave it in this instance?

@seanlinsley
Owner

Don't worry about it. (I'm laughing at myself now, because my comment only managed to add more cruft to this Issue)

@mattvague mattvague was unassigned by brain-geek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.