New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dashboard configuration to (not) be displayed in navigation #1418
Closed
robinboening
wants to merge
1
commit into
thoughtbot:master
from
robinboening:feature/dashboard_configuration
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Administrate | ||
class Navigation | ||
attr_reader :resources | ||
|
||
def initialize(namespace) | ||
namespace = Administrate::Namespace.new(namespace) | ||
@resources = namespace.resources.select(&:display_in_navigation?) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
require "rails_helper" | ||
|
||
describe "navigation" do | ||
let(:navigation) { find(".navigation") } | ||
|
||
it "highlights the link to the current page's resource type" do | ||
visit admin_customers_path | ||
|
||
|
@@ -9,6 +11,28 @@ | |
expect(active_link.text).to eq "Customers" | ||
end | ||
|
||
it "displays links to resources from admin namespace" do | ||
visit admin_root_path | ||
|
||
expect(navigation).to have_link("Customers") | ||
expect(navigation).to have_link("Line Items") | ||
expect(navigation).to have_link("Log Entries") | ||
expect(navigation).to have_link("Products") | ||
expect(navigation).to have_link("Product Meta Tags") | ||
expect(navigation).to have_link("Payments") | ||
expect(navigation).to have_link("Series") | ||
expect(navigation).to have_link("Blog/Posts") | ||
end | ||
|
||
it "does not display links to resources configured to not be rendered in navigation" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [89/80] |
||
LineItemDashboard.configuration.navigation = false | ||
|
||
visit admin_root_path | ||
expect(navigation).not_to have_link("Line Items") | ||
|
||
LineItemDashboard.configuration.navigation = true # Reset to default | ||
end | ||
|
||
it "displays translated name of model" do | ||
translations = { | ||
activerecord: { | ||
|
@@ -24,7 +48,6 @@ | |
with_translations(:en, translations) do | ||
visit admin_customers_path | ||
|
||
navigation = find(".navigation") | ||
expect(navigation).to have_link("Users") | ||
expect(page).to have_header("Users") | ||
end | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you think of making this name more abstract or generic? Something like
RelationalRecordsDashboard
orAssociationsDashboard
? I found myself wondering ifLineItem
had any significance, and am curious to know if anyone else paused at that.Thanks for working towards an enhancement to
administrate
!