Skip to content

Instantly share code, notes, and snippets.

@splinter
Created October 4, 2016 07:06
Show Gist options
  • Save splinter/e7acd3e251ca80e33d3bc23934e48f44 to your computer and use it in GitHub Desktop.
Save splinter/e7acd3e251ca80e33d3bc23934e48f44 to your computer and use it in GitHub Desktop.
pageDecorators.navigationBar = function(ctx, page, utils) {
var app = require('rxt').app;
//Change the context to support cross tenant views
var tenantAppResources = tenantApi.createTenantAwareAppResources(ctx.session);
//Support for cross tenant views
ctx = tenantAppResources.context;
var rxtManager = ctx.rxtManager;
//Obtain all of the available rxt types
var availableTypes = app.getUIActivatedAssets(ctx.tenantId);
var types = [];
var type;
var currentType;
page.isUserDomainAndUrlDomainDifferent = tenantAppResources.isUserDomainAndUrlDomainDifferent;
page.navigationBar = {};
var isLandingPage = true;
var noTypeSelected = true;
for (var index in availableTypes) {
type = availableTypes[index];
if (permissionsAPI.hasAssetPermission(permissionsAPI.ASSET_LIST, type, ctx.tenantId, ctx.username)) {
currentType = rxtManager.getRxtTypeDetails(type);
currentType.selected = false;
currentType.style = "all-item";
currentType.listingUrl = utils.buildAssetPageUrl(currentType.shortName, '/list');
if (currentType.shortName == page.rxt.shortName) {
currentType.selected = true;
currentType.style = "active home top-item";
isLandingPage = false;
noTypeSelected = false;
}
types.push(currentType);
}
}
page.navigationBar.noTypeSelected = noTypeSelected;
page.navigationBar.types = types;
page.navigationBar.landingPage = isLandingPage;
return page;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment