While I was cruising about, I noticed that I wanted to return to the app, but that link wasn't in the admin. Also, sometimes when you're running a job, you get a dashboard to look at jobs. There's no link anywhere to find them. You're also logged in (most of the time) and there's no conventional logout button.
What I'm asking:
Basically add a nav to the top right near the search to logout if user_signed_in? is true and defined?. And maybe a link to main_app.root_url as well.
An API to add new links (such as giving users the ability to link to a CMS admin and/or a jobs dashboard possible) would be great. I know Solidus/Spree has this.
@BenMorganIO A top nav is something that will probably vary a lot between different implementations of Administrate. I'm not sure how to add a top nav that will be generally useful.
On master, we just added #269. This gives you the command rails generate administrate:views:layout. It'll go out in version 0.1.3, and until then you can get it by using:
gem "administrate", github: "thoughtbot/administrate"
If you (and others) want to share your top navbar implementation here, that would be a good first step to see if we can add a generally-useful API for it.
Cheers!
I added a top navbar on my app by generating the layout and adding it to that layout. Here's the code in Slim, but it should be easily translated to ERb. I also added another manifest with some style coming from the main app.
doctype html
html lang='en'
head
meta charset="utf-8"
meta name="ROBOTS" content="NOODP"
meta name="viewport" content="initial-scale=1"
title
= content_for(:title)
| |
= Rails.application.class.parent_name.titlecase
= stylesheet_link_tag "//fonts.googleapis.com/css?family=Lato:300,400,900", media: "all"
= stylesheet_link_tag "administrate/application", media: "all"
= stylesheet_link_tag "admin", media: "all"
= csrf_meta_tags
body.administrate
= render "application/navbar" # The top nav
main.main
.sidebar
= render "sidebar"
.container
= content_for(:search)
.content
= render "flashes"
= yield
= render "javascript"
Hope it helps.
Great, thanks! I'll leave this open to gauge interest - if anyone else wants to see this, let us know here.
I have 2 projects using administrate and the first thing you/user/client is thinking after doing what they need to do in administrate is "How do I get back to the main app". So basically overriding the view is the first thing I am going to do everytime.
Solution? Something like what @BenMorganIO said.
@minimul yep... The top nav of Spree 2 and 3 were views that I always edited in the beginning to add jobs and CMS admin links.
I would like to see a top nav as well.
For people like me that didn't know where to you the layouts, it needs to be inside:
app/views/layouts/administrate/application.html.erb
Enjoy
I can see how it could make sense not to include a top nav bar by default. I don't really see how it could make sense not to include a sign-out link by default.
or a "home" link back to the app
Seems like such a basic thing but yet it's not there. I'm not going to hold my breath considering this was opened in 2015 and there hasn't been any actual updates on this front.
I could never introduce this to my end-users without me spending the time to add custom navbar or even a sign out or home link.
Please add this, thank you!
we still need it
This would be great feature, everyone needs to get back to app!
is this going to be added ?
is this going to be added ?
I've opened #1376 as an attempt at solving half of this issue.
Attempting to solve sign out is a different problem. Administrate does not make any assumptions about how you authenticate your application (see: https://github.com/thoughtbot/administrate/blob/7ed5b0792b7dc0b622de83256a22fcaa1d7db54b/lib/generators/administrate/install/templates/application_controller.rb.erb#L11:L13), so there's nothing we can assume about signing out. Like the application_controller, the best we could do is document the best way of solving it.
I'm going to close this as #1376, which I hope to merge soon provides a partial solution to this.
Most helpful comment
Great, thanks! I'll leave this open to gauge interest - if anyone else wants to see this, let us know here.