mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-02 13:16:48 +09:00
F #3951: Fix dev routes
This commit is contained in:
1 parent
4e3c610b90
commit
fa3d913159
8 files changed
+57
-60
No files matched your search
@@ -22,18 +22,9 @@ import { _APPS } from 'client/constants'
|
||||
|
||||
const APP_NAME = _APPS.flow.name
|
||||
|
||||
const FlowApp = () => {
|
||||
/* if (process?.env?.NODE_ENV === 'development') {
|
||||
import('client/apps/_dev/routes').then(devRoutes => {
|
||||
routes = {
|
||||
PATH: { ...routes.PATH, ...devRoutes.PATH },
|
||||
ENDPOINTS: routes.ENDPOINTS.concat(devRoutes.ENDPOINTS)
|
||||
}
|
||||
})
|
||||
} */
|
||||
|
||||
return <Router title={APP_NAME} routes={routes} />
|
||||
}
|
||||
const FlowApp = () => (
|
||||
<Router title={APP_NAME} routes={routes} />
|
||||
)
|
||||
|
||||
FlowApp.displayName = '_FlowApp'
|
||||
|
||||
|
||||
@@ -25,21 +25,11 @@ const APP_NAME = _APPS.provision.name
|
||||
|
||||
const ProvisionApp = () => {
|
||||
const { isLogged, isLoginInProcess } = useAuth()
|
||||
const { getTemplates } = useProvision()
|
||||
// const { fetchRequest } = useFetch(getTemplates)
|
||||
|
||||
/* if (process?.env?.NODE_ENV === 'development') {
|
||||
import('client/apps/_dev/routes').then(devRoutes => {
|
||||
routes = {
|
||||
PATH: { ...routes.PATH, ...devRoutes.PATH },
|
||||
ENDPOINTS: routes.ENDPOINTS.concat(devRoutes.ENDPOINTS)
|
||||
}
|
||||
})
|
||||
} */
|
||||
const { getProvisionsTemplates } = useProvision()
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isLogged && !isLoginInProcess) {
|
||||
getTemplates()
|
||||
getProvisionsTemplates()
|
||||
}
|
||||
}, [isLogged])
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export default function useProvision () {
|
||||
// PROVIDERS TEMPLATES REQUESTS
|
||||
// --------------------------------------------
|
||||
|
||||
const getTemplates = useCallback(
|
||||
const getProvidersTemplates = useCallback(
|
||||
() =>
|
||||
serviceProvision
|
||||
.getProvidersTemplates({ filter })
|
||||
@@ -235,7 +235,7 @@ export default function useProvision () {
|
||||
|
||||
return {
|
||||
providersTemplates,
|
||||
getTemplates,
|
||||
getProvidersTemplates,
|
||||
|
||||
providers,
|
||||
getProvider,
|
||||
|
||||
@@ -16,7 +16,7 @@ export const ENDPOINTS = [
|
||||
devMode: true,
|
||||
sidebar: true,
|
||||
icon: BallotIcon,
|
||||
component: TestApi
|
||||
Component: TestApi
|
||||
},
|
||||
{
|
||||
label: 'Webconsole',
|
||||
@@ -25,6 +25,8 @@ export const ENDPOINTS = [
|
||||
devMode: true,
|
||||
sidebar: true,
|
||||
icon: BallotIcon,
|
||||
component: Webconsole
|
||||
Component: Webconsole
|
||||
}
|
||||
]
|
||||
|
||||
export default { PATH, ENDPOINTS }
|
||||
@@ -1,3 +0,0 @@
|
||||
export * as dev from 'client/router/dev'
|
||||
export * as flow from 'client/router/flow'
|
||||
export * as provision from 'client/router/provision'
|
||||
@@ -32,7 +32,7 @@ export const ENDPOINTS = [
|
||||
label: 'Login',
|
||||
path: PATH.LOGIN,
|
||||
authenticated: false,
|
||||
component: Login
|
||||
Component: Login
|
||||
},
|
||||
{
|
||||
label: 'Dashboard',
|
||||
@@ -40,14 +40,14 @@ export const ENDPOINTS = [
|
||||
authenticated: true,
|
||||
sidebar: true,
|
||||
icon: DashboardIcon,
|
||||
component: Dashboard
|
||||
Component: Dashboard
|
||||
},
|
||||
{
|
||||
label: 'Settings',
|
||||
path: PATH.SETTINGS,
|
||||
authenticated: true,
|
||||
header: true,
|
||||
component: Settings
|
||||
Component: Settings
|
||||
},
|
||||
{
|
||||
label: 'Templates',
|
||||
@@ -55,19 +55,19 @@ export const ENDPOINTS = [
|
||||
authenticated: true,
|
||||
sidebar: true,
|
||||
icon: TemplatesIcons,
|
||||
component: ApplicationsTemplates
|
||||
Component: ApplicationsTemplates
|
||||
},
|
||||
{
|
||||
label: 'Create Application template',
|
||||
path: PATH.APPLICATIONS_TEMPLATES.CREATE,
|
||||
authenticated: true,
|
||||
component: ApplicationsTemplatesCreateForm
|
||||
Component: ApplicationsTemplatesCreateForm
|
||||
},
|
||||
{
|
||||
label: 'Edit Application template',
|
||||
path: PATH.APPLICATIONS_TEMPLATES.EDIT,
|
||||
authenticated: true,
|
||||
component: ApplicationsTemplatesCreateForm
|
||||
Component: ApplicationsTemplatesCreateForm
|
||||
},
|
||||
{
|
||||
label: 'Instances',
|
||||
@@ -75,7 +75,7 @@ export const ENDPOINTS = [
|
||||
authenticated: true,
|
||||
sidebar: true,
|
||||
icon: InstancesIcons,
|
||||
component: ApplicationsInstances
|
||||
Component: ApplicationsInstances
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -19,23 +19,25 @@ import PropTypes from 'prop-types'
|
||||
import { Redirect, Route, Switch } from 'react-router-dom'
|
||||
import { TransitionGroup } from 'react-transition-group'
|
||||
|
||||
import * as endpoints from 'client/router/endpoints'
|
||||
import devRoutes from 'client/router/dev'
|
||||
import { InternalLayout, MainLayout } from 'client/components/HOC'
|
||||
import { APPS } from 'client/constants'
|
||||
|
||||
const Router = ({ title, routes: { PATH, ENDPOINTS } }) => {
|
||||
/* const { ENDPOINTS, PATH } = useMemo(() => ({
|
||||
...endpoints[app],
|
||||
const Router = ({ title, routes }) => {
|
||||
const { ENDPOINTS, PATH } = useMemo(() => ({
|
||||
...routes,
|
||||
...(process?.env?.NODE_ENV === 'development' &&
|
||||
{ ENDPOINTS: endpoints[app].ENDPOINTS.concat(endpoints.dev.ENDPOINTS) }
|
||||
{
|
||||
PATH: { ...routes.PATH, ...devRoutes.PATH },
|
||||
ENDPOINTS: routes.ENDPOINTS.concat(devRoutes.ENDPOINTS)
|
||||
}
|
||||
)
|
||||
}), [app]) */
|
||||
}), [])
|
||||
|
||||
const renderRoute = useCallback(({
|
||||
label = '',
|
||||
path = '',
|
||||
authenticated = true,
|
||||
component: Component,
|
||||
Component,
|
||||
...route
|
||||
}) => (
|
||||
<Route
|
||||
@@ -55,9 +57,7 @@ const Router = ({ title, routes: { PATH, ENDPOINTS } }) => {
|
||||
<MainLayout endpoints={{ ENDPOINTS, PATH }}>
|
||||
<TransitionGroup>
|
||||
<Switch>
|
||||
{React.useMemo(() => ENDPOINTS?.map(({ routes, ...endpoint }) =>
|
||||
endpoint.path ? renderRoute(endpoint) : routes?.map(renderRoute)
|
||||
), [])}
|
||||
{React.useMemo(() => ENDPOINTS?.map(renderRoute), [])}
|
||||
<Route component={() => <Redirect to={PATH.LOGIN} />} />
|
||||
</Switch>
|
||||
</TransitionGroup>
|
||||
@@ -66,11 +66,28 @@ const Router = ({ title, routes: { PATH, ENDPOINTS } }) => {
|
||||
}
|
||||
|
||||
Router.propTypes = {
|
||||
app: PropTypes.oneOf([undefined, ...APPS])
|
||||
title: PropTypes.string,
|
||||
routes: PropTypes.shape({
|
||||
PATH: PropTypes.object,
|
||||
ENDPOINTS: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
label: PropTypes.string.isRequired,
|
||||
path: PropTypes.string.isRequired,
|
||||
authenticated: PropTypes.bool.isRequired,
|
||||
sidebar: PropTypes.bool,
|
||||
icon: PropTypes.object,
|
||||
Component: PropTypes.func.isRequired
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
Router.defaultProps = {
|
||||
app: undefined
|
||||
title: undefined,
|
||||
routes: {
|
||||
PATH: {},
|
||||
ENDPOINTS: []
|
||||
}
|
||||
}
|
||||
|
||||
Router.displayName = 'Router'
|
||||
|
||||
@@ -36,7 +36,7 @@ export const ENDPOINTS = [
|
||||
label: 'Login',
|
||||
path: PATH.LOGIN,
|
||||
authenticated: false,
|
||||
component: Login
|
||||
Component: Login
|
||||
},
|
||||
{
|
||||
label: 'Dashboard',
|
||||
@@ -44,14 +44,14 @@ export const ENDPOINTS = [
|
||||
authenticated: true,
|
||||
sidebar: true,
|
||||
icon: DashboardIcon,
|
||||
component: Dashboard
|
||||
Component: Dashboard
|
||||
},
|
||||
{
|
||||
label: 'Settings',
|
||||
path: PATH.SETTINGS,
|
||||
authenticated: true,
|
||||
header: true,
|
||||
component: Settings
|
||||
Component: Settings
|
||||
},
|
||||
{
|
||||
label: 'Providers',
|
||||
@@ -59,19 +59,19 @@ export const ENDPOINTS = [
|
||||
authenticated: true,
|
||||
sidebar: true,
|
||||
icon: ProvidersIcon,
|
||||
component: Providers
|
||||
Component: Providers
|
||||
},
|
||||
{
|
||||
label: 'Create Provider',
|
||||
path: PATH.PROVIDERS.CREATE,
|
||||
authenticated: true,
|
||||
component: ProvidersCreateForm
|
||||
Component: ProvidersCreateForm
|
||||
},
|
||||
{
|
||||
label: 'Edit Provider template',
|
||||
path: PATH.PROVIDERS.EDIT,
|
||||
authenticated: true,
|
||||
component: ProvidersCreateForm
|
||||
Component: ProvidersCreateForm
|
||||
},
|
||||
{
|
||||
label: 'Provisions',
|
||||
@@ -79,19 +79,19 @@ export const ENDPOINTS = [
|
||||
authenticated: true,
|
||||
sidebar: true,
|
||||
icon: ProvisionsIcon,
|
||||
component: Provisions
|
||||
Component: Provisions
|
||||
},
|
||||
{
|
||||
label: 'Create Provision',
|
||||
path: PATH.PROVISIONS.CREATE,
|
||||
authenticated: true,
|
||||
component: ProvisionCreateForm
|
||||
Component: ProvisionCreateForm
|
||||
},
|
||||
{
|
||||
label: 'Edit Provision template',
|
||||
path: PATH.PROVISIONS.EDIT,
|
||||
authenticated: true,
|
||||
component: ProvisionCreateForm
|
||||
Component: ProvisionCreateForm
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Reference in new issue
Block a user