F #3951: Add provision routes (#340)

This commit is contained in:
Sergio Betanzos authored and GitHub committed 2020-10-21 13:15:14 +02:00
1 parent b14923b798
commit 34aa09fbe7
41 files changed
+186 -204

No files matched your search

@@ -49,7 +49,9 @@ const InternalLayout = ({ authRoute, label, children }) => {
unmountOnExit
>
<Container maxWidth={false} className={classes.scrollable}>
{children}
<Container className={classes.container} disableGutters>
{children}
</Container>
</Container>
</CSSTransition>
</Box>
@@ -50,6 +50,11 @@ export default makeStyles(theme => ({
color: theme.palette.primary.light
}
},
container: {
height: '100%',
display: 'flex',
flexDirection: 'column'
},
/* ROUTES TRANSITIONS */
appear: {},
appearActive: {},
@@ -43,8 +43,9 @@ const Sidebar = () => {
const SidebarEndpoints = useMemo(
() =>
endpoints
?.filter(
({ authenticated, sidebar = false }) => authenticated && sidebar
?.filter(({ authenticated, sidebar = false }) => authenticated && sidebar)
?.filter(({ devMode = false }) =>
!devMode || (process?.env?.NODE_ENV === 'development' && devMode)
)
?.map((endpoint, index) =>
endpoint.routes ? (
@@ -1,56 +0,0 @@
import React, { useEffect } from 'react'
import { useHistory } from 'react-router-dom'
import { Box, LinearProgress } from '@material-ui/core'
import { Alert } from '@material-ui/lab'
import useApplication from 'client/hooks/useApplication'
import useFetch from 'client/hooks/useFetch'
import ListCards from 'client/components/List/ListCards'
import { ApplicationTemplateCard } from 'client/components/Cards'
import { PATH } from 'client/router/endpoints'
import { Tr } from 'client/components/HOC'
const ApplicationsTemplatesList = () => {
const history = useHistory()
const { applicationsTemplates, getApplicationsTemplates } = useApplication()
const { fetchRequest, loading, error } = useFetch(getApplicationsTemplates)
useEffect(() => {
fetchRequest()
}, [])
if (error) {
return (
<Box pt={3} display="flex" justifyContent="center">
<Alert severity="error" icon={false} variant="filled">
{Tr('Cannot connect to OneFlow server')}
</Alert>
</Box>
)
}
if (loading) {
return <LinearProgress />
}
return (
<Box p={3}>
<ListCards
list={applicationsTemplates}
handleCreate={() => history.push(PATH.APPLICATIONS_TEMPLATES.CREATE)}
CardComponent={ApplicationTemplateCard}
cardsProps={({ value: { ID } }) => ({
handleEdit: () =>
history.push(PATH.APPLICATIONS_TEMPLATES.EDIT.replace(':id', ID)),
handleDeploy: undefined,
handleRemove: undefined
})}
/>
</Box>
)
}
export default ApplicationsTemplatesList
@@ -1,73 +0,0 @@
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
import React, { useState } from 'react'
import { Tab, Tabs, Paper, Container } from '@material-ui/core'
import ApplicationsTemplatesList from 'client/containers/Applications/List/Templates'
import ApplicationsDeployed from 'client/containers/Applications/List/Deployed'
const TABS = {
TEMPLATES: 'templates',
APPLICATIONS: 'applications'
}
function Applications () {
const [value, setValue] = useState(TABS.TEMPLATES)
const handleChange = (_, newValue) => {
setValue(newValue)
}
return (
<Container
disableGutters
style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
>
<Paper>
<Tabs
value={value}
onChange={handleChange}
indicatorColor="primary"
textColor="primary"
>
<Tab
value={TABS.TEMPLATES}
label="Applications templates"
id={`tab-${TABS.TEMPLATES}`}
/>
<Tab
value={TABS.APPLICATIONS}
label="Applications deployed"
id={`tab-${TABS.APPLICATIONS}`}
/>
</Tabs>
</Paper>
<div hidden={value !== TABS.TEMPLATES}>
{value === TABS.TEMPLATES && <ApplicationsTemplatesList />}
</div>
<div hidden={value !== TABS.APPLICATIONS}>
{value === TABS.APPLICATIONS && <ApplicationsDeployed />}
</div>
</Container>
)
}
Applications.propTypes = {}
Applications.defaultProps = {}
export default Applications
@@ -10,7 +10,7 @@ import ListCards from 'client/components/List/ListCards'
import { ApplicationCard } from 'client/components/Cards'
import { Tr } from 'client/components/HOC'
const ApplicationsDeployed = () => {
function ApplicationsInstances () {
const { applications, getApplications } = useApplication()
const { fetchRequest, loading, error } = useFetch(getApplications)
@@ -45,4 +45,4 @@ const ApplicationsDeployed = () => {
)
}
export default ApplicationsDeployed
export default ApplicationsInstances
@@ -1,3 +0,0 @@
import { makeStyles } from '@material-ui/core'
export default makeStyles(theme => ({}))
@@ -9,7 +9,7 @@ import ListCards from 'client/components/List/ListCards'
import { DialogForm } from 'client/components/Dialogs'
import { NetworkCard } from 'client/components/Cards'
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Tiers'
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers'
import { FORM_FIELDS, NETWORK_FORM_SCHEMA, STEP_FORM_SCHEMA } from './schema'
export const STEP_ID = 'networking'
@@ -7,7 +7,7 @@ import ReactFlow, { Background } from 'react-flow-renderer'
import { useFormContext } from 'react-hook-form'
import SpeedDials from 'client/components/SpeedDials'
import { STEP_ID as TIER_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Tiers'
import { STEP_ID as TIER_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers'
import CustomNode from './CustomNode'
import useFlowGraph from './useFlowGraph'
@@ -4,8 +4,8 @@ import useListForm from 'client/hooks/useListForm'
import ListCards from 'client/components/List/ListCards'
import { SelectCard } from 'client/components/Cards'
import { STEP_ID as NETWORKING } from 'client/containers/ApplicationsTemplates/Create/Steps/Networking'
import { Context } from 'client/containers/ApplicationsTemplates/Create/Steps/Tiers'
import { STEP_ID as NETWORKING } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Networking'
import { Context } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers'
import { STEP_FORM_SCHEMA } from './schema'
export const STEP_ID = 'networks'
@@ -9,8 +9,8 @@ import { Box } from '@material-ui/core'
import useListForm from 'client/hooks/useListForm'
import FormStepper from 'client/components/FormStepper'
import { DialogForm } from 'client/components/Dialogs'
import { STEP_ID as NETWORKING_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Networking'
import { STEP_ID as NETWORKS_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Tiers/Steps/Networks'
import { STEP_ID as NETWORKING_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Networking'
import { STEP_ID as NETWORKS_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Networks'
import Steps from './Steps'
import Flow from './Flow'
@@ -1,12 +1,12 @@
import React, { useEffect } from 'react'
import { Redirect, useHistory, useParams } from 'react-router-dom'
import { Container } from '@material-ui/core'
import { LinearProgress } from '@material-ui/core'
import { useForm, FormProvider } from 'react-hook-form'
import { yupResolver } from '@hookform/resolvers'
import FormStepper from 'client/components/FormStepper'
import Steps from 'client/containers/ApplicationsTemplates/Create/Steps'
import Steps from 'client/containers/ApplicationsTemplates/Form/Create/Steps'
import { PATH } from 'client/router/endpoints'
import useFetch from 'client/hooks/useFetch'
@@ -14,7 +14,7 @@ import useApplication from 'client/hooks/useApplication'
import mapApplicationToForm from 'client/utils/parser/toApplicationForm'
import mapFormToApplication from 'client/utils/parser/toApplicationTemplate'
function ApplicationCreate () {
function ApplicationsTemplatesCreateForm () {
const history = useHistory()
const { id } = useParams()
const { steps, defaultValues, resolvers } = Steps()
@@ -38,11 +38,11 @@ function ApplicationCreate () {
if (id) {
updateApplicationTemplate({ id, data: application }).then(
res => res && history.push(PATH.APPLICATIONS)
res => res && history.push(PATH.APPLICATIONS_TEMPLATES.LIST)
)
} else {
createApplicationTemplate({ data: application }).then(
res => res && history.push(PATH.APPLICATIONS)
res => res && history.push(PATH.APPLICATIONS_TEMPLATES.LIST)
)
}
}
@@ -60,24 +60,17 @@ function ApplicationCreate () {
return <Redirect to={PATH.DASHBOARD} />
}
return (
<Container
disableGutters
style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
>
{(id && !data) || loading ? (
<div>is loading...</div>
) : (
<FormProvider {...methods}>
<FormStepper steps={steps} schema={resolvers} onSubmit={onSubmit} />
</FormProvider>
)}
</Container>
return (id && !data) || loading ? (
<LinearProgress />
) : (
<FormProvider {...methods}>
<FormStepper steps={steps} schema={resolvers} onSubmit={onSubmit} />
</FormProvider>
)
}
ApplicationCreate.propTypes = {}
ApplicationsTemplatesCreateForm.propTypes = {}
ApplicationCreate.defaultProps = {}
ApplicationsTemplatesCreateForm.defaultProps = {}
export default ApplicationCreate
export default ApplicationsTemplatesCreateForm
@@ -1,3 +1,60 @@
import ApplicationsTemplatesCreate from 'client/containers/ApplicationsTemplates/Create'
import React, { useEffect } from 'react'
export { ApplicationsTemplatesCreate }
import { useHistory } from 'react-router-dom'
import { Box, LinearProgress } from '@material-ui/core'
import { Alert } from '@material-ui/lab'
import { PATH } from 'client/router/endpoints'
import useApplication from 'client/hooks/useApplication'
import useFetch from 'client/hooks/useFetch'
// import DeployForm from 'client/containers/Applications/Form'
import ListCards from 'client/components/List/ListCards'
import { ApplicationTemplateCard } from 'client/components/Cards'
import { Tr } from 'client/components/HOC'
const ApplicationsTemplates = () => {
const history = useHistory()
// const [showDialog, setShowDialog] = useState(false)
const { applicationsTemplates, getApplicationsTemplates } = useApplication()
const { fetchRequest, loading, error } = useFetch(getApplicationsTemplates)
useEffect(() => {
fetchRequest()
}, [])
if (error) {
return (
<Box pt={3} display="flex" justifyContent="center">
<Alert severity="error" icon={false} variant="filled">
{Tr('Cannot connect to OneFlow server')}
</Alert>
</Box>
)
}
if (loading) {
return <LinearProgress />
}
return (
<Box p={3}>
<ListCards
list={applicationsTemplates}
handleCreate={() => history.push(PATH.APPLICATIONS_TEMPLATES.CREATE)}
CardComponent={ApplicationTemplateCard}
cardsProps={({ value: { ID } }) => ({
handleEdit: () =>
history.push(PATH.APPLICATIONS_TEMPLATES.EDIT.replace(':id', ID)),
// handleShow: () => setShowDialog(ID),
handleRemove: undefined
})}
/>
{/* {showDialog !== false && (
<DeployForm id={showDialog} handleCancel={() => setShowDialog(false)} />
)} */}
</Box>
)
}
export default ApplicationsTemplates
@@ -0,0 +1,15 @@
import React from 'react'
import { Typography } from '@material-ui/core'
function Providers () {
return (
<Typography>Providers</Typography>
)
}
Providers.propTypes = {}
Providers.defaultProps = {}
export default Providers
@@ -0,0 +1,15 @@
import React from 'react'
import { Typography } from '@material-ui/core'
function Provisions () {
return (
<Typography>Provisions</Typography>
)
}
Provisions.propTypes = {}
Provisions.defaultProps = {}
export default Provisions
+56 -30
View File
@@ -1,24 +1,10 @@
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
import {
Dashboard as DashboardIcon,
Settings as SettingsIcon,
Ballot as BallotIcon,
Palette as PaletteIcon,
Reddit as RedditIcon
FormatListBulleted as TemplatesIcons,
Apps as InstancesIcons,
Public as ProvidersIcon,
SettingsSystemDaydream as ProvisionsIcon
} from '@material-ui/icons'
import { matchPath } from 'react-router-dom'
@@ -27,17 +13,36 @@ import Dashboard from 'client/containers/Dashboard'
import Settings from 'client/containers/Settings'
import TestApi from 'client/containers/TestApi'
import Webconsole from 'client/containers/Webconsole'
import { ApplicationsTemplatesCreate } from 'client/containers/ApplicationsTemplates'
import Applications from 'client/containers/Applications'
import ApplicationsTemplates from 'client/containers/ApplicationsTemplates'
import ApplicationsTemplatesCreateForm from 'client/containers/ApplicationsTemplates/Form/Create'
import ApplicationsInstances from 'client/containers/ApplicationsInstances'
import Providers from 'client/containers/Providers'
import Provisions from 'client/containers/Provisions'
export const PATH = {
LOGIN: '/',
DASHBOARD: '/dashboard',
APPLICATIONS_TEMPLATES: {
LIST: '/applications-templates',
CREATE: '/applications-templates/create',
EDIT: '/applications-templates/edit/:id'
},
APPLICATIONS: '/applications',
APPLICATIONS: {
LIST: '/applications'
},
PROVIDERS: {
LIST: '/providers',
CREATE: '/providers/create',
EDIT: '/providers/edit/:id'
},
PROVISIONS: {
LIST: '/provisions',
CREATE: '/provisions/create',
EDIT: '/provisions/edit/:id'
},
SETTINGS: '/settings',
TEST_API: '/test-api'
}
@@ -62,7 +67,6 @@ const ENDPOINTS = [
path: PATH.SETTINGS,
authenticated: true,
header: true,
icon: SettingsIcon,
component: Settings
},
{
@@ -83,27 +87,49 @@ const ENDPOINTS = [
icon: BallotIcon,
component: Webconsole
},
{
label: 'Templates',
path: PATH.APPLICATIONS_TEMPLATES.LIST,
authenticated: true,
sidebar: true,
icon: TemplatesIcons,
component: ApplicationsTemplates
},
{
label: 'Create Application template',
path: PATH.APPLICATIONS_TEMPLATES.CREATE,
authenticated: true,
icon: PaletteIcon,
component: ApplicationsTemplatesCreate
component: ApplicationsTemplatesCreateForm
},
{
label: 'Edit Application template',
path: PATH.APPLICATIONS_TEMPLATES.EDIT,
authenticated: true,
icon: PaletteIcon,
component: ApplicationsTemplatesCreate
component: ApplicationsTemplatesCreateForm
},
{
label: 'Applications',
path: PATH.APPLICATIONS,
label: 'Instances',
path: PATH.APPLICATIONS.LIST,
authenticated: true,
sidebar: true,
icon: RedditIcon,
component: Applications
icon: InstancesIcons,
component: ApplicationsInstances
},
{
label: 'Providers',
path: PATH.PROVIDERS.LIST,
authenticated: true,
sidebar: true,
icon: ProvidersIcon,
component: Providers
},
{
label: 'Provisions',
path: PATH.PROVISIONS.LIST,
authenticated: true,
sidebar: true,
icon: ProvisionsIcon,
component: Provisions
}
]
@@ -1,9 +1,9 @@
import { v4 as uuidv4 } from 'uuid'
import { STEP_ID as APPLICATION_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/BasicConfiguration'
import { STEP_ID as CLUSTER_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Clusters'
import { STEP_ID as NETWORKING_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Networking'
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Tiers'
import { STEP_ID as APPLICATION_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/BasicConfiguration'
import { STEP_ID as CLUSTER_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Clusters'
import { STEP_ID as NETWORKING_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Networking'
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers'
import parseTemplateToObject from './templateToObject'
@@ -1,7 +1,7 @@
import { STEP_ID as APPLICATION_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/BasicConfiguration'
import { STEP_ID as CLUSTER_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Clusters'
import { STEP_ID as NETWORKING_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Networking'
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Create/Steps/Tiers'
import { STEP_ID as APPLICATION_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/BasicConfiguration'
import { STEP_ID as CLUSTER_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Clusters'
import { STEP_ID as NETWORKING_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Networking'
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers'
const mapNetworkToUserInput = network => {
const { mandatory, description, type, idVnet, extra } = network