diff --git a/src/fireedge/src/client/apps/provision/_app.js b/src/fireedge/src/client/apps/provision/_app.js
index 2726285558..54086571da 100644
--- a/src/fireedge/src/client/apps/provision/_app.js
+++ b/src/fireedge/src/client/apps/provision/_app.js
@@ -16,14 +16,18 @@
import * as React from 'react'
import Router from 'client/router'
-import routes from 'client/apps/provision/routes'
+import { ENDPOINTS, PATH } from 'client/apps/provision/routes'
+import { ENDPOINTS as DEV_ENDPOINTS } from 'client/router/dev'
import { useGeneralApi } from 'client/features/General'
import { useAuth, useAuthApi } from 'client/features/Auth'
import { useProvisionTemplate, useProvisionApi } from 'client/features/One'
+import Sidebar from 'client/components/Sidebar'
+import Notifier from 'client/components/Notifier'
import LoadingScreen from 'client/components/LoadingScreen'
import { _APPS } from 'client/constants'
+import { isDevelopment } from 'client/utils'
const APP_NAME = _APPS.provision.name
@@ -49,11 +53,26 @@ const ProvisionApp = () => {
})()
}, [jwt])
+ const endpoints = React.useMemo(() => [
+ ...ENDPOINTS,
+ ...(isDevelopment() ? DEV_ENDPOINTS : [])
+ ], [])
+
if (jwt && firstRender) {
return
}
- return
+ return (
+ <>
+ {isLogged && (
+ <>
+
+
+ >
+ )}
+
+ >
+ )
}
ProvisionApp.displayName = '_ProvisionApp'
diff --git a/src/fireedge/src/client/apps/sunstone/_app.js b/src/fireedge/src/client/apps/sunstone/_app.js
index cdc73aff7a..96015ee8bb 100644
--- a/src/fireedge/src/client/apps/sunstone/_app.js
+++ b/src/fireedge/src/client/apps/sunstone/_app.js
@@ -16,18 +16,23 @@
import * as React from 'react'
import Router from 'client/router'
-import routes from 'client/apps/sunstone/routes'
+import { ENDPOINTS, PATH, getEndpointsByView } from 'client/apps/sunstone/routes'
+import { ENDPOINTS as ONE_ENDPOINTS } from 'client/apps/sunstone/routesOne'
+import { ENDPOINTS as DEV_ENDPOINTS } from 'client/router/dev'
import { useGeneralApi } from 'client/features/General'
import { useAuth, useAuthApi } from 'client/features/Auth'
+import Sidebar from 'client/components/Sidebar'
+import Notifier from 'client/components/Notifier'
import LoadingScreen from 'client/components/LoadingScreen'
import { _APPS } from 'client/constants'
+import { isDevelopment } from 'client/utils'
const APP_NAME = _APPS.sunstone.name
const SunstoneApp = () => {
- const { isLogged, jwt, firstRender } = useAuth()
+ const { isLogged, jwt, firstRender, view, views } = useAuth()
const { getAuthUser, logout, getSunstoneViews } = useAuthApi()
const { changeTitle } = useGeneralApi()
@@ -37,7 +42,7 @@ const SunstoneApp = () => {
if (jwt) {
changeTitle(APP_NAME)
getAuthUser()
- getSunstoneViews()
+ await getSunstoneViews()
}
} catch {
logout()
@@ -45,11 +50,27 @@ const SunstoneApp = () => {
})()
}, [jwt])
+ const endpoints = React.useMemo(() => [
+ ...ENDPOINTS,
+ ...(view ? getEndpointsByView(views?.[view], ONE_ENDPOINTS) : []),
+ ...(isDevelopment() ? DEV_ENDPOINTS : [])
+ ], [view])
+
if (jwt && firstRender) {
return
}
- return
+ return (
+ <>
+ {isLogged && (
+ <>
+
+
+ >
+ )}
+
+ >
+ )
}
SunstoneApp.displayName = '_SunstoneApp'
diff --git a/src/fireedge/src/client/apps/sunstone/routes.js b/src/fireedge/src/client/apps/sunstone/routes.js
index d521ae7693..dee15c0224 100644
--- a/src/fireedge/src/client/apps/sunstone/routes.js
+++ b/src/fireedge/src/client/apps/sunstone/routes.js
@@ -1,33 +1,6 @@
import {
ReportColumns as DashboardIcon,
- Settings as SettingsIcon,
-
- Cell4x4 as InstancesIcons,
- ModernTv as VmsIcons,
- Shuffle as VRoutersIcons,
-
- Archive as TemplatesIcon,
- GoogleDocs as TemplateIcon,
-
- Box as StorageIcon,
- Db as DatastoreIcon,
- BoxIso as ImageIcon,
- SimpleCart as MarketplaceIcon,
- CloudDownload as MarketplaceAppIcon,
-
- ServerConnection as NetworksIcon,
- NetworkAlt as NetworkIcon,
- KeyframesCouple as NetworkTemplateIcon,
-
- CloudSync as InfrastructureIcon,
- Server as ClusterIcon,
- HardDrive as HostIcon,
- MinusPinAlt as ZoneIcon,
-
- Home as SystemIcon,
- User as UserIcon,
- Group as GroupIcon
-
+ Settings as SettingsIcon
} from 'iconoir-react'
import loadable from '@loadable/component'
@@ -35,95 +8,8 @@ import loadable from '@loadable/component'
const Dashboard = loadable(() => import('client/containers/Dashboard/Sunstone'), { ssr: false })
const Settings = loadable(() => import('client/containers/Settings'), { ssr: false })
-const VirtualMachines = loadable(() => import('client/containers/VirtualMachines'), { ssr: false })
-const VirtualRouters = loadable(() => import('client/containers/VirtualRouters'), { ssr: false })
-
-const VmTemplates = loadable(() => import('client/containers/VmTemplates'), { ssr: false })
-// const VrTemplates = loadable(() => import('client/containers/VrTemplates'), { ssr: false })
-// const VmGroups = loadable(() => import('client/containers/VmGroups'), { ssr: false })
-
-const Datastores = loadable(() => import('client/containers/Datastores'), { ssr: false })
-const Images = loadable(() => import('client/containers/Images'), { ssr: false })
-// const Files = loadable(() => import('client/containers/Files'), { ssr: false })
-const Marketplaces = loadable(() => import('client/containers/Marketplaces'), { ssr: false })
-const MarketplaceApps = loadable(() => import('client/containers/MarketplaceApps'), { ssr: false })
-
-const VirtualNetworks = loadable(() => import('client/containers/VirtualNetworks'), { ssr: false })
-const VNetworkTemplates = loadable(() => import('client/containers/VNetworkTemplates'), { ssr: false })
-// const NetworkTopologies = loadable(() => import('client/containers/NetworkTopologies'), { ssr: false })
-// const SecurityGroups = loadable(() => import('client/containers/SecurityGroups'), { ssr: false })
-
-const Clusters = loadable(() => import('client/containers/Clusters'), { ssr: false })
-const Hosts = loadable(() => import('client/containers/Hosts'), { ssr: false })
-const Zones = loadable(() => import('client/containers/Zones'), { ssr: false })
-
-const Users = loadable(() => import('client/containers/Users'), { ssr: false })
-const Groups = loadable(() => import('client/containers/Groups'), { ssr: false })
-// const VDCs = loadable(() => import('client/containers/VDCs'), { ssr: false })
-// const ACLs = loadable(() => import('client/containers/ACLs'), { ssr: false })
-
export const PATH = {
DASHBOARD: '/dashboard',
- INSTANCE: {
- VMS: {
- LIST: '/vms'
- },
- VROUTERS: {
- LIST: '/virtual-routers'
- }
- },
- TEMPLATE: {
- VMS: {
- LIST: '/vm-templates'
- }
- },
- STORAGE: {
- DATASTORES: {
- LIST: '/datastores'
- },
- IMAGES: {
- LIST: '/images'
- },
- FILES: {
- LIST: '/files'
- },
- MARKETPLACES: {
- LIST: '/marketplaces'
- },
- MARKETPLACE_APPS: {
- LIST: '/marketplaces-apps'
- }
- },
- NETWORK: {
- VNETS: {
- LIST: '/virtual-networks'
- },
- VN_TEMPLATES: {
- LIST: '/network-templates'
- },
- SEC_GROUPS: {
- LIST: '/security-groups'
- }
- },
- INFRASTRUCTURE: {
- CLUSTERS: {
- LIST: '/clusters'
- },
- HOSTS: {
- LIST: '/hosts'
- },
- ZONES: {
- LIST: '/zones'
- }
- },
- SYSTEM: {
- USERS: {
- LIST: '/users'
- },
- GROUPS: {
- LIST: '/groups'
- }
- },
SETTINGS: '/settings'
}
@@ -135,146 +21,6 @@ export const ENDPOINTS = [
icon: DashboardIcon,
Component: Dashboard
},
- {
- label: 'Instances',
- sidebar: true,
- icon: InstancesIcons,
- routes: [
- {
- label: 'VMs',
- path: PATH.INSTANCE.VMS.LIST,
- sidebar: true,
- icon: VmsIcons,
- Component: VirtualMachines
- },
- {
- label: 'Virtual Routers',
- path: PATH.INSTANCE.VROUTERS.LIST,
- sidebar: true,
- icon: VRoutersIcons,
- Component: VirtualRouters
- }
- ]
- },
- {
- label: 'Templates',
- sidebar: true,
- icon: TemplatesIcon,
- routes: [
- {
- label: 'VMs',
- path: PATH.TEMPLATE.VMS.LIST,
- sidebar: true,
- icon: TemplateIcon,
- Component: VmTemplates
- }
- ]
- },
- {
- label: 'Storage',
- sidebar: true,
- icon: StorageIcon,
- routes: [
- {
- label: 'Datastores',
- path: PATH.STORAGE.DATASTORES.LIST,
- sidebar: true,
- icon: DatastoreIcon,
- Component: Datastores
- },
- {
- label: 'Images',
- path: PATH.STORAGE.IMAGES.LIST,
- sidebar: true,
- icon: ImageIcon,
- Component: Images
- },
- {
- label: 'Marketplaces',
- path: PATH.STORAGE.MARKETPLACES.LIST,
- sidebar: true,
- icon: MarketplaceIcon,
- Component: Marketplaces
- },
- {
- label: 'Apps',
- path: PATH.STORAGE.MARKETPLACE_APPS.LIST,
- sidebar: true,
- icon: MarketplaceAppIcon,
- Component: MarketplaceApps
- }
- ]
- },
- {
- label: 'Networks',
- sidebar: true,
- icon: NetworksIcon,
- routes: [
- {
- label: 'Virtual Networks',
- path: PATH.NETWORK.VNETS.LIST,
- sidebar: true,
- icon: NetworkIcon,
- Component: VirtualNetworks
- },
- {
- label: 'Network Templates',
- path: PATH.NETWORK.VN_TEMPLATES.LIST,
- sidebar: true,
- icon: NetworkTemplateIcon,
- Component: VNetworkTemplates
- }
- ]
- },
- {
- label: 'Infrastructure',
- sidebar: true,
- icon: InfrastructureIcon,
- routes: [
- {
- label: 'Clusters',
- path: PATH.INFRASTRUCTURE.CLUSTERS.LIST,
- sidebar: true,
- icon: ClusterIcon,
- Component: Clusters
- },
- {
- label: 'Hosts',
- path: PATH.INFRASTRUCTURE.HOSTS.LIST,
- sidebar: true,
- icon: HostIcon,
- Component: Hosts
- },
- {
- label: 'Zones',
- path: PATH.INFRASTRUCTURE.ZONES.LIST,
- sidebar: true,
- icon: ZoneIcon,
- Component: Zones
- }
- ]
- },
- {
- label: 'System',
- sidebar: true,
- icon: SystemIcon,
- routes: [
- {
- label: 'Users',
- path: PATH.SYSTEM.USERS.LIST,
- sidebar: true,
- icon: UserIcon,
- Component: Users
- },
- {
- label: 'Groups',
- path: PATH.SYSTEM.GROUPS.LIST,
- sidebar: true,
- icon: GroupIcon,
- Component: Groups
- }
- ]
- },
{
label: 'Settings',
path: PATH.SETTINGS,
@@ -284,4 +30,26 @@ export const ENDPOINTS = [
}
]
+/**
+ * @param {String} view Current view selected in redux (auth-reducer)
+ * @param {Array} endpoints All endpoints of app
+ * @returns {Array} Returns all endpoints available
+ */
+export const getEndpointsByView = (view, endpoints = []) => {
+ const hasRoutePermission = route =>
+ view?.some(({ resource_name: name }) =>
+ route?.path.toLowerCase().endsWith(name.toLowerCase())
+ ) && route
+
+ return endpoints.map(({ routes: subRoutes, ...rest }) => {
+ if (Array.isArray(subRoutes)) {
+ const routes = subRoutes.map(hasRoutePermission).filter(Boolean)
+
+ return !!routes.length && { ...rest, routes }
+ }
+
+ return hasRoutePermission(rest)
+ }).filter(Boolean)
+}
+
export default { PATH, ENDPOINTS }
diff --git a/src/fireedge/src/client/apps/sunstone/routes-flow.js b/src/fireedge/src/client/apps/sunstone/routesFlow.js
similarity index 100%
rename from src/fireedge/src/client/apps/sunstone/routes-flow.js
rename to src/fireedge/src/client/apps/sunstone/routesFlow.js
diff --git a/src/fireedge/src/client/apps/sunstone/routesOne.js b/src/fireedge/src/client/apps/sunstone/routesOne.js
new file mode 100644
index 0000000000..31bdec6651
--- /dev/null
+++ b/src/fireedge/src/client/apps/sunstone/routesOne.js
@@ -0,0 +1,265 @@
+import {
+ Cell4x4 as InstancesIcons,
+ ModernTv as VmsIcons,
+ Shuffle as VRoutersIcons,
+
+ Archive as TemplatesIcon,
+ GoogleDocs as TemplateIcon,
+
+ Box as StorageIcon,
+ Db as DatastoreIcon,
+ BoxIso as ImageIcon,
+ SimpleCart as MarketplaceIcon,
+ CloudDownload as MarketplaceAppIcon,
+
+ ServerConnection as NetworksIcon,
+ NetworkAlt as NetworkIcon,
+ KeyframesCouple as NetworkTemplateIcon,
+
+ CloudSync as InfrastructureIcon,
+ Server as ClusterIcon,
+ HardDrive as HostIcon,
+ MinusPinAlt as ZoneIcon,
+
+ Home as SystemIcon,
+ User as UserIcon,
+ Group as GroupIcon
+
+} from 'iconoir-react'
+
+import loadable from '@loadable/component'
+
+const VirtualMachines = loadable(() => import('client/containers/VirtualMachines'), { ssr: false })
+const VirtualRouters = loadable(() => import('client/containers/VirtualRouters'), { ssr: false })
+
+const VmTemplates = loadable(() => import('client/containers/VmTemplates'), { ssr: false })
+// const VrTemplates = loadable(() => import('client/containers/VrTemplates'), { ssr: false })
+// const VmGroups = loadable(() => import('client/containers/VmGroups'), { ssr: false })
+
+const Datastores = loadable(() => import('client/containers/Datastores'), { ssr: false })
+const Images = loadable(() => import('client/containers/Images'), { ssr: false })
+// const Files = loadable(() => import('client/containers/Files'), { ssr: false })
+const Marketplaces = loadable(() => import('client/containers/Marketplaces'), { ssr: false })
+const MarketplaceApps = loadable(() => import('client/containers/MarketplaceApps'), { ssr: false })
+
+const VirtualNetworks = loadable(() => import('client/containers/VirtualNetworks'), { ssr: false })
+const VNetworkTemplates = loadable(() => import('client/containers/VNetworkTemplates'), { ssr: false })
+// const NetworkTopologies = loadable(() => import('client/containers/NetworkTopologies'), { ssr: false })
+// const SecurityGroups = loadable(() => import('client/containers/SecurityGroups'), { ssr: false })
+
+const Clusters = loadable(() => import('client/containers/Clusters'), { ssr: false })
+const Hosts = loadable(() => import('client/containers/Hosts'), { ssr: false })
+const Zones = loadable(() => import('client/containers/Zones'), { ssr: false })
+
+const Users = loadable(() => import('client/containers/Users'), { ssr: false })
+const Groups = loadable(() => import('client/containers/Groups'), { ssr: false })
+// const VDCs = loadable(() => import('client/containers/VDCs'), { ssr: false })
+// const ACLs = loadable(() => import('client/containers/ACLs'), { ssr: false })
+
+export const PATH = {
+ INSTANCE: {
+ VMS: {
+ LIST: '/vm'
+ },
+ VROUTERS: {
+ LIST: '/virtual-router'
+ }
+ },
+ TEMPLATE: {
+ VMS: {
+ LIST: '/vm-template'
+ }
+ },
+ STORAGE: {
+ DATASTORES: {
+ LIST: '/datastore'
+ },
+ IMAGES: {
+ LIST: '/image'
+ },
+ FILES: {
+ LIST: '/file'
+ },
+ MARKETPLACES: {
+ LIST: '/marketplace'
+ },
+ MARKETPLACE_APPS: {
+ LIST: '/marketplaces-app'
+ }
+ },
+ NETWORK: {
+ VNETS: {
+ LIST: '/virtual-network'
+ },
+ VN_TEMPLATES: {
+ LIST: '/network-template'
+ },
+ SEC_GROUPS: {
+ LIST: '/security-group'
+ }
+ },
+ INFRASTRUCTURE: {
+ CLUSTERS: {
+ LIST: '/cluster'
+ },
+ HOSTS: {
+ LIST: '/host'
+ },
+ ZONES: {
+ LIST: '/zone'
+ }
+ },
+ SYSTEM: {
+ USERS: {
+ LIST: '/user'
+ },
+ GROUPS: {
+ LIST: '/group'
+ }
+ }
+}
+
+export const ENDPOINTS = [
+ {
+ label: 'Instances',
+ sidebar: true,
+ icon: InstancesIcons,
+ routes: [
+ {
+ label: 'VMs',
+ path: PATH.INSTANCE.VMS.LIST,
+ sidebar: true,
+ icon: VmsIcons,
+ Component: VirtualMachines
+ },
+ {
+ label: 'Virtual Routers',
+ path: PATH.INSTANCE.VROUTERS.LIST,
+ sidebar: true,
+ icon: VRoutersIcons,
+ Component: VirtualRouters
+ }
+ ]
+ },
+ {
+ label: 'Templates',
+ sidebar: true,
+ icon: TemplatesIcon,
+ routes: [
+ {
+ label: 'VMs',
+ path: PATH.TEMPLATE.VMS.LIST,
+ sidebar: true,
+ icon: TemplateIcon,
+ Component: VmTemplates
+ }
+ ]
+ },
+ {
+ label: 'Storage',
+ sidebar: true,
+ icon: StorageIcon,
+ routes: [
+ {
+ label: 'Datastores',
+ path: PATH.STORAGE.DATASTORES.LIST,
+ sidebar: true,
+ icon: DatastoreIcon,
+ Component: Datastores
+ },
+ {
+ label: 'Images',
+ path: PATH.STORAGE.IMAGES.LIST,
+ sidebar: true,
+ icon: ImageIcon,
+ Component: Images
+ },
+ {
+ label: 'Marketplaces',
+ path: PATH.STORAGE.MARKETPLACES.LIST,
+ sidebar: true,
+ icon: MarketplaceIcon,
+ Component: Marketplaces
+ },
+ {
+ label: 'Apps',
+ path: PATH.STORAGE.MARKETPLACE_APPS.LIST,
+ sidebar: true,
+ icon: MarketplaceAppIcon,
+ Component: MarketplaceApps
+ }
+ ]
+ },
+ {
+ label: 'Networks',
+ sidebar: true,
+ icon: NetworksIcon,
+ routes: [
+ {
+ label: 'Virtual Networks',
+ path: PATH.NETWORK.VNETS.LIST,
+ sidebar: true,
+ icon: NetworkIcon,
+ Component: VirtualNetworks
+ },
+ {
+ label: 'Network Templates',
+ path: PATH.NETWORK.VN_TEMPLATES.LIST,
+ sidebar: true,
+ icon: NetworkTemplateIcon,
+ Component: VNetworkTemplates
+ }
+ ]
+ },
+ {
+ label: 'Infrastructure',
+ sidebar: true,
+ icon: InfrastructureIcon,
+ routes: [
+ {
+ label: 'Clusters',
+ path: PATH.INFRASTRUCTURE.CLUSTERS.LIST,
+ sidebar: true,
+ icon: ClusterIcon,
+ Component: Clusters
+ },
+ {
+ label: 'Hosts',
+ path: PATH.INFRASTRUCTURE.HOSTS.LIST,
+ sidebar: true,
+ icon: HostIcon,
+ Component: Hosts
+ },
+ {
+ label: 'Zones',
+ path: PATH.INFRASTRUCTURE.ZONES.LIST,
+ sidebar: true,
+ icon: ZoneIcon,
+ Component: Zones
+ }
+ ]
+ },
+ {
+ label: 'System',
+ sidebar: true,
+ icon: SystemIcon,
+ routes: [
+ {
+ label: 'Users',
+ path: PATH.SYSTEM.USERS.LIST,
+ sidebar: true,
+ icon: UserIcon,
+ Component: Users
+ },
+ {
+ label: 'Groups',
+ path: PATH.SYSTEM.GROUPS.LIST,
+ sidebar: true,
+ icon: GroupIcon,
+ Component: Groups
+ }
+ ]
+ }
+]
+
+export default { PATH, ENDPOINTS }
diff --git a/src/fireedge/src/client/components/Header/View.js b/src/fireedge/src/client/components/Header/View.js
index 854ae848f1..2c651ff186 100644
--- a/src/fireedge/src/client/components/Header/View.js
+++ b/src/fireedge/src/client/components/Header/View.js
@@ -11,7 +11,7 @@ import headerStyles from 'client/components/Header/styles'
const View = () => {
const classes = headerStyles()
- const { view, views } = useAuth()
+ const { view, views = {} } = useAuth()
const { changeView } = useAuthApi()
const handleChangeView = newView => {
diff --git a/src/fireedge/src/client/components/Route/NoAuthRoute.js b/src/fireedge/src/client/components/Route/NoAuthRoute.js
index 1211ee44eb..51ed858494 100644
--- a/src/fireedge/src/client/components/Route/NoAuthRoute.js
+++ b/src/fireedge/src/client/components/Route/NoAuthRoute.js
@@ -14,15 +14,20 @@
/* -------------------------------------------------------------------------- */
import * as React from 'react'
+import PropTypes from 'prop-types'
import { Redirect, Route } from 'react-router-dom'
import { useAuth } from 'client/features/Auth'
-const NoAuthRoute = props => {
+const NoAuthRoute = ({ redirectWhenAuth, ...props }) => {
const { isLogged, isLoginInProgress, isLoading } = useAuth()
const isAuthenticated = isLogged && !isLoginInProgress && !isLoading
- return isAuthenticated ? :
+ return isAuthenticated ? :
+}
+
+NoAuthRoute.propTypes = {
+ redirectWhenAuth: PropTypes.string
}
export default NoAuthRoute
diff --git a/src/fireedge/src/client/components/Sidebar/index.js b/src/fireedge/src/client/components/Sidebar/index.js
index a5addbd6f2..0b8a6b39c9 100644
--- a/src/fireedge/src/client/components/Sidebar/index.js
+++ b/src/fireedge/src/client/components/Sidebar/index.js
@@ -13,7 +13,7 @@
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
-import React, { useMemo, memo } from 'react'
+import React, { useMemo } from 'react'
import PropTypes from 'prop-types'
import clsx from 'clsx'
@@ -33,7 +33,7 @@ import SidebarLink from 'client/components/Sidebar/SidebarLink'
import SidebarCollapseItem from 'client/components/Sidebar/SidebarCollapseItem'
import Logo from 'client/icons/logo'
-const Sidebar = memo(({ endpoints }) => {
+const Sidebar = ({ endpoints }) => {
const classes = sidebarStyles()
const isUpLg = useMediaQuery(theme => theme.breakpoints.up('lg'), { noSsr: true })
@@ -43,17 +43,16 @@ const Sidebar = memo(({ endpoints }) => {
const handleSwapMenu = () => fixMenu(!isFixMenu)
const SidebarEndpoints = useMemo(
- () =>
- endpoints
- ?.filter(({ sidebar = false }) => sidebar)
- ?.map((endpoint, index) =>
- endpoint.routes ? (
-
- ) : (
-
- )
- ),
- []
+ () => endpoints
+ ?.filter(({ sidebar = false }) => sidebar)
+ ?.map((endpoint, index) =>
+ endpoint.routes ? (
+
+ ) : (
+
+ )
+ ),
+ [endpoints]
)
return (
@@ -87,7 +86,7 @@ const Sidebar = memo(({ endpoints }) => {
)
-}, (prev, next) => prev.endpoints.length === next.endpoints.length)
+}
Sidebar.propTypes = {
endpoints: PropTypes.array
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/index.js
index 2ffd0eebcf..f596096a19 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/index.js
@@ -8,7 +8,7 @@ import { yupResolver } from '@hookform/resolvers'
import FormStepper from 'client/components/FormStepper'
import Steps from 'client/containers/ApplicationsTemplates/Form/Create/Steps'
-import { PATH } from 'client/apps/sunstone/routes-flow'
+import { PATH } from 'client/apps/sunstone/routesFlow'
import { useFetch } from 'client/hooks'
import { useApplicationTemplateApi } from 'client/features/One'
import { parseApplicationToForm, parseFormToApplication } from 'client/utils'
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/index.js
index 14d6bd4c51..79af4b91e0 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/index.js
@@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react'
import { useHistory } from 'react-router-dom'
import { Container, Box } from '@material-ui/core'
-import { PATH } from 'client/apps/sunstone/routes-flow'
+import { PATH } from 'client/apps/sunstone/routesFlow'
import { useFetch } from 'client/hooks'
import { useApplicationTemplate, useApplicationTemplateApi } from 'client/features/One'
diff --git a/src/fireedge/src/client/router/index.js b/src/fireedge/src/client/router/index.js
index 08b09cad98..3d7489fc82 100644
--- a/src/fireedge/src/client/router/index.js
+++ b/src/fireedge/src/client/router/index.js
@@ -20,80 +20,57 @@ import { Redirect, Route, Switch } from 'react-router-dom'
import { TransitionGroup } from 'react-transition-group'
import { LinearProgress } from '@material-ui/core'
-import devRoutes from 'client/router/dev'
-import commonRoutes from 'client/router/common'
+import {
+ PATH as COMMON_PATH,
+ ENDPOINTS as COMMON_ENDPOINTS
+} from 'client/router/common'
import { ProtectedRoute, NoAuthRoute } from 'client/components/Route'
import { InternalLayout } from 'client/components/HOC'
-import Sidebar from 'client/components/Sidebar'
-import Notifier from 'client/components/Notifier'
-import { isDevelopment } from 'client/utils'
-const Router = ({ isLogged, routes }) => {
- const ENDPOINTS = React.useMemo(() => [
- ...routes.ENDPOINTS,
- ...(isDevelopment() ? devRoutes.ENDPOINTS : [])
- ], [])
+const renderRoute = ({ Component, ...rest }, index) => (
+
+
+ } />
+
+
+)
- const renderRoute = React.useCallback(
- ({ Component, ...rest }, index) => (
-
-
- } />
-
-
- ), [])
-
- return (
- <>
- {isLogged && (
- <>
-
-
- >
+const Router = ({ redirectWhenAuth, endpoints }) => (
+
+
+ {endpoints?.map(({ routes: subRoutes, ...rest }, index) =>
+ Array.isArray(subRoutes)
+ ? subRoutes?.map(renderRoute)
+ : renderRoute(rest, index)
)}
-
-
- {ENDPOINTS?.map(({ routes: subRoutes, ...rest }, index) =>
- Array.isArray(subRoutes)
- ? subRoutes?.map(renderRoute)
- : renderRoute(rest, index)
- )}
- {commonRoutes.ENDPOINTS?.map(({ Component, ...rest }, index) =>
-
-
-
- )}
- } />
-
-
- >
+ {COMMON_ENDPOINTS?.map(({ Component, ...rest }, index) =>
+
+
+
+ )}
+ } />
+
+
+)
+
+Router.propTypes = {
+ redirectWhenAuth: PropTypes.string,
+ endpoints: PropTypes.arrayOf(
+ PropTypes.shape({
+ Component: PropTypes.object,
+ icon: PropTypes.object,
+ label: PropTypes.string.isRequired,
+ path: PropTypes.string,
+ sidebar: PropTypes.bool,
+ routes: PropTypes.array
+ })
)
}
-Router.propTypes = {
- isLogged: PropTypes.bool,
- routes: PropTypes.shape({
- PATH: PropTypes.object,
- ENDPOINTS: PropTypes.arrayOf(
- PropTypes.shape({
- Component: PropTypes.object,
- icon: PropTypes.object,
- label: PropTypes.string.isRequired,
- path: PropTypes.string,
- sidebar: PropTypes.bool,
- routes: PropTypes.array
- })
- )
- })
-}
-
Router.defaultProps = {
- isLogged: false,
- routes: {
- PATH: {},
- ENDPOINTS: []
- }
+ redirectWhenAuth: '/dashboard',
+ endpoints: []
}
Router.displayName = 'Router'