Extend GetNavItems with key

The service GetNavItems always returns all NavItems. Can this call be extended with an optional key property that will only return the NavItems declared with the key in NavItemsMap dictionary in the Results list and leave NavItemsMap empty.


Support added in this commit, you can use Name to specify which NavItems collection to return.

[Route("/metadata/nav", "GET")]
[Route("/metadata/nav/{Name}", "GET")]
public class GetNavItems : IReturn<GetNavItemsResponse>
    public string Name { get; set; }

This change is available in the latest v5.8.1 on MyGet.

1 Like

The NavItem has a Show and Hide property. I don’t see any samples how to use this. My goal is to have a list of NavItems returned for the current request, filtered via Role(s) membership and/or Permissions, maybe extend it with a Disabled property to not return the item in the returned list of NavItems.

There are UI components that render menus for #Script Pages, Razor, Vue, React, Angular.

If you don’t want to use the existing components, you can look at any of the implementations of the SPA Component Libraries for how they’re implemented.

The Vue Navigation Docs explain what the built-in user attributes are and provides an example explaining its behavior. E.g. the user attributes list is provided when rendering the control, which if hide/show attribute is present simply hides or displays the navitem if the attribute is in the list.

The built-in list of user attributes is available from UserAttributes.fromSession():

export const store: State = {
  nav: global.NAV_ITEMS as GetNavItemsResponse,
  userSession: global.AUTH as AuthenticateResponse,
  userAttributes: UserAttributes.fromSession(global.AUTH),

Which you can further extend with your own attributes (i.e. collection of string literals).

<navbar :items="store.nav.results" :attributes="store.userAttributes" />

If you want to further filter the nav items that’s up to you, but it works decoratively where navitems specify when they should be visible or hidden which the list of user attributes control. So you could have your own custom “reporting” attribute where all your navitems that you only want to display when this attribute is set would have a definition of "show":"reporting".

store.userAttributes = [store.userAttributes...,'reporting'];