-
Notifications
You must be signed in to change notification settings - Fork 134
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
Navigation Overhaul #68
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
29 changes: 29 additions & 0 deletions
29
src/Bootstrap/NavigationRouteFilterExamples/AdministrationRouteFilter.cs
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,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using NavigationRoutes; | ||
|
||
namespace NavigationRouteFilterExamples | ||
{ | ||
public class AdministrationRouteFilter :INavigationRouteFilter | ||
{ | ||
// an excercise for the reader would be to load the role name | ||
// from your config file so this isn't compiled in, or add a constructor | ||
// that accepts a role name to use to make this a more generic filter | ||
private string AdministrationRole = "admin"; | ||
|
||
public bool ShouldRemove(System.Web.Routing.Route navigationRoutes) | ||
{ | ||
if (navigationRoutes.DataTokens.HasFilterToken()) | ||
{ | ||
var filterToken = navigationRoutes.DataTokens.FilterToken(); | ||
var result = !HttpContext.Current.User.IsInRole(AdministrationRole) && filterToken == AdministrationRole; | ||
return result; | ||
} | ||
|
||
return false; | ||
|
||
} | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
src/NavigationRoutes/NavigationRoutes/NavigationRouteOptions.cs
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,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
|
||
namespace NavigationRoutes | ||
{ | ||
public class NavigationRouteOptions | ||
{ | ||
public NavigationRouteOptions() | ||
{ | ||
this.AreaName = string.Empty; | ||
this.HasBreakAfter = false; | ||
this.IsRightAligned = false; | ||
this.FilterToken = string.Empty; | ||
this.ElementId = string.Empty; | ||
} | ||
|
||
/// <summary> | ||
/// You can specify an area to properly render your route, if required | ||
/// </summary> | ||
public string AreaName { get; set; } | ||
|
||
/// <summary> | ||
/// This will be the ID rendered in the DOM, if specified | ||
/// </summary> | ||
public string ElementId { get; set; } | ||
|
||
/// <summary> | ||
/// This will insert a break after the menu item rendered for the route. If this is a top-level | ||
/// item, the break will be in the nav bar. For child items, the break appears in the dropdown list. | ||
/// </summary> | ||
public bool HasBreakAfter { get; set; } | ||
|
||
/// <summary> | ||
/// Setting this property on any item will cause the UL containing the entire group to be | ||
/// pulled to right. | ||
/// </summary> | ||
public bool IsRightAligned { get; set; } | ||
|
||
/// <summary> | ||
/// A string value to store additional information about the route for the purposes of | ||
/// filtering. The value is stored in the DataTokens collection and can be accessed in | ||
/// an implementation of INavigationRouteFilter. | ||
/// </summary> | ||
public string FilterToken { get; set; } | ||
|
||
// todo: figure out other relevant options | ||
// ? public bool HasBreakBefore { get; set; } | ||
// ? public string Icon { get; set; } | ||
|
||
} | ||
} |
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
Oops, something went wrong.
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.
Those who want to get the role based navigation menu working properly should pay special attention to this code line.