Allow disabling dashboard #501

Closed
brain-geek opened this Issue Sep 20, 2011 · 29 comments

Comments

Projects
None yet

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 commented Sep 21, 2011

+1

Contributor

pcreux commented Sep 21, 2011

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'

Maybe, more like this:

ActiveAdmin.setup do |config|
  config.replace_dashboard_with :products
end
Contributor

mattvague commented Sep 29, 2011

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

This would be great.

mitchwd commented Oct 4, 2011

Really love mattvague's implementation.

+1 to mattvague's idea

Contributor

ahx commented Nov 26, 2011

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

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

mattvague was assigned Feb 15, 2012

oki commented Feb 23, 2012

+1 for this feature

mrli commented Apr 19, 2012

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 .

Contributor

latortuga commented Apr 19, 2012

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

mrli commented Apr 20, 2012

oh .yes .hope to that become true.

+1 to mattvague's idea

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

pcreux closed this May 2, 2012

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

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.

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 commented Oct 2, 2012

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 commented Feb 6, 2013

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.

Owner

seanlinsley commented Feb 6, 2013

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 commented Feb 6, 2013

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!

Owner

seanlinsley commented Feb 6, 2013

@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 commented Feb 7, 2013

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).

Owner

seanlinsley commented Feb 7, 2013

@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 commented Feb 7, 2013

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.

Owner

seanlinsley commented Feb 7, 2013

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 commented Feb 8, 2013

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

Owner

seanlinsley commented Feb 8, 2013

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

mattvague was unassigned by brain-geek Aug 12, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment