fleet/frontend/components/side_panels/SiteTopNav/navItems.js
Zach Wasserman 39cef4c43f
Revert "Fleet UI: Reroute homepage (#1640)" (#1724)
Reverts #1640 so that the homepage does not change during the patch release.

This commit will be re-applied after the release is cut.
2021-08-18 18:06:03 -07:00

70 lines
1.5 KiB
JavaScript

import PATHS from "router/paths";
import URL_PREFIX from "router/url_prefix";
import permissionUtils from "utilities/permissions";
export default (currentUser) => {
const adminNavItems = [
{
icon: "settings",
name: "Settings",
iconName: "settings",
location: {
regex: new RegExp(`^${URL_PREFIX}/settings/`),
pathname: PATHS.ADMIN_SETTINGS,
},
},
];
const userNavItems = [
{
icon: "logo",
name: "Home",
iconName: "logo",
location: {
regex: new RegExp(`^${URL_PREFIX}/home/dashboard`),
pathname: PATHS.HOMEPAGE,
},
},
{
icon: "hosts",
name: "Hosts",
iconName: "hosts",
location: {
regex: new RegExp(`^${URL_PREFIX}/hosts/`),
pathname: PATHS.MANAGE_HOSTS,
},
},
{
icon: "query",
name: "Queries",
iconName: "queries",
location: {
regex: new RegExp(`^${URL_PREFIX}/queries/`),
pathname: PATHS.MANAGE_QUERIES,
},
},
];
const globalMaintainerNavItems = [
{
icon: "packs",
name: "Schedule",
iconName: "packs",
location: {
regex: new RegExp(`^${URL_PREFIX}/(schedule|packs)/`),
pathname: PATHS.MANAGE_SCHEDULE,
},
},
];
if (permissionUtils.isGlobalAdmin(currentUser)) {
return [...userNavItems, ...globalMaintainerNavItems, ...adminNavItems];
}
if (permissionUtils.isGlobalMaintainer(currentUser)) {
return [...userNavItems, ...globalMaintainerNavItems];
}
return userNavItems;
};