B OpenNebula/one#8037: Add missing service inst. dialog (#4569)

Signed-off-by: Victor Hansson <vhansson@opennebula.io>
This commit is contained in:
vichansson authored and GitHub committed 2026-10-20 09:44:43 +02:00
1 parent 77ba107915
commit 1458f0b95f
6 files changed
+190 -68

No files matched your search

@@ -27,7 +27,7 @@
Component: Services
- title: Instantiate Service Template
path: /service/instantiate/
Component: InstantiateServiceTemplate
Component: CreateService
- title: Service
path: /service/:id
Component: ServiceDetail
@@ -0,0 +1,127 @@
/* ------------------------------------------------------------------------- *
* Copyright 2002-2026, 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 { Dialog, DialogContent, DialogTitle, Stack } from '@mui/material'
import { Cancel } from 'iconoir-react'
import PropTypes from 'prop-types'
import { ReactElement } from 'react'
import { Button } from '@modules/components/primitives/Buttons'
import { Table } from '@modules/components/primitives/Tables'
import { Text } from '@modules/components/primitives/Text'
import { T, TEXT_VARIANTS, TEXT_WEIGHTS } from '@ConstantsModule'
/**
* Displays a searchable template selector dialog.
*
* @param {object} props - Dialog and table configuration
* @param {string} props.title - Dialog title
* @param {object} props.table - Template table model
* @param {object[]} props.data - Templates to display
* @param {boolean} props.isRefreshing - Whether templates are loading
* @param {Function} props.onRefresh - Refreshes the templates
* @param {Function} props.onClose - Closes the dialog
* @param {Function} props.onSelect - Opens the selected template
* @returns {ReactElement} Template selector dialog
*/
export function TemplateSelectorDialog({
title,
table,
data,
isRefreshing,
onRefresh,
onClose,
onSelect,
}) {
return (
<Dialog
open
fullWidth
maxWidth="lg"
onClose={onClose}
PaperProps={{
sx: {
width: 'min(1120px, calc(100vw - 64px))',
maxWidth: 'none',
minHeight: '620px',
overflow: 'hidden',
},
}}
>
<DialogTitle>
<Stack
direction="row"
alignItems="center"
justifyContent="space-between"
gap={2}
>
<Text
value={title}
variant={TEXT_VARIANTS.H6}
weight={TEXT_WEIGHTS.SEMIBOLD}
/>
<Button
iconOnly={<Cancel />}
type="secondary"
title={T.Close}
onClick={onClose}
/>
</Stack>
</DialogTitle>
<DialogContent
sx={{
display: 'flex',
flexDirection: 'column',
minHeight: 0,
pb: 3,
}}
>
<Table
columns={table.columns()}
data={data}
dataCy={table.dataCy}
isLoading={isRefreshing}
isRowsSelectable
getRowId={(row) => String(row.ID)}
onRowClick={onSelect}
onRefresh={onRefresh}
isRefreshing={isRefreshing}
isEnableSearchBar
isEnableSort
isEnableFilters
searchPlaceholder={T.SearchTemplates}
defaultPageSize={5}
pageSizeOptions={[5, 10, 25, 50, 100]}
skeletonRows={4}
size="medium"
/>
</DialogContent>
</Dialog>
)
}
TemplateSelectorDialog.propTypes = {
title: PropTypes.string.isRequired,
table: PropTypes.shape({
columns: PropTypes.func.isRequired,
dataCy: PropTypes.string,
}).isRequired,
data: PropTypes.array.isRequired,
isRefreshing: PropTypes.bool,
onRefresh: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
onSelect: PropTypes.func.isRequired,
}
@@ -38,3 +38,4 @@ export * from '@modules/components/composed/QueryState'
export * from '@modules/components/composed/ResourceContainer'
export * from '@modules/components/composed/ResourceActionConfirmation'
export * from '@modules/components/composed/ResourceLink'
export * from '@modules/components/composed/TemplateSelectorDialog'
@@ -0,0 +1,50 @@
/* ------------------------------------------------------------------------- *
* Copyright 2002-2026, 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 { ReactElement } from 'react'
import { useHistory } from 'react-router'
import { TemplateSelectorDialog } from '@ComponentsModule'
import { PATH, T } from '@ConstantsModule'
import { servicetemplateTable } from '@ModelsModule'
import { Services } from '@modules/containers/Services/Services'
/**
* Displays the service create template selector.
*
* @returns {ReactElement} Services list with template selector dialog
*/
export function CreateService() {
const history = useHistory()
const { data = [], isFetching, refetch } = servicetemplateTable.useData()
return (
<>
<Services />
<TemplateSelectorDialog
title={T.SelectTemplate}
table={servicetemplateTable}
data={data}
isRefreshing={isFetching}
onRefresh={refetch}
onClose={() => history.replace(PATH.INSTANCE.SERVICES.LIST)}
onSelect={(template) =>
history.push(PATH.TEMPLATE.SERVICES.INSTANTIATE, template)
}
/>
</>
)
}
@@ -15,3 +15,4 @@
* ------------------------------------------------------------------------- */
export * from '@modules/containers/Services/Detail'
export * from '@modules/containers/Services/Services'
export * from '@modules/containers/Services/Create'
@@ -14,13 +14,11 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
import { Dialog, DialogContent, DialogTitle, Stack } from '@mui/material'
import { Cancel } from 'iconoir-react'
import { ReactElement, useCallback, useMemo } from 'react'
import { useHistory } from 'react-router'
import { Button, Table, Text } from '@ComponentsModule'
import { PATH, T, TEXT_VARIANTS, TEXT_WEIGHTS } from '@ConstantsModule'
import { TemplateSelectorDialog } from '@ComponentsModule'
import { PATH, T } from '@ConstantsModule'
import { vmtemplateTable } from '@ModelsModule'
import { VirtualMachines } from '@modules/containers/VirtualMachines/VirtualMachines'
@@ -62,70 +60,15 @@ export function CreateVm() {
return (
<>
<VirtualMachines />
<Dialog
open
fullWidth
maxWidth="lg"
<TemplateSelectorDialog
title={T.SelectVmTemplate}
table={vmtemplateTable}
data={templates}
isRefreshing={isRefreshing}
onRefresh={refresh}
onClose={handleClose}
PaperProps={{
sx: {
width: 'min(1120px, calc(100vw - 64px))',
maxWidth: 'none',
minHeight: '620px',
overflow: 'hidden',
},
}}
>
<DialogTitle>
<Stack
direction="row"
alignItems="center"
justifyContent="space-between"
gap={2}
>
<Text
value={T.SelectVmTemplate}
variant={TEXT_VARIANTS.H6}
weight={TEXT_WEIGHTS.SEMIBOLD}
/>
<Button
iconOnly={<Cancel />}
type="secondary"
title={T.Close}
onClick={handleClose}
/>
</Stack>
</DialogTitle>
<DialogContent
sx={{
display: 'flex',
flexDirection: 'column',
minHeight: 0,
pb: 3,
}}
>
<Table
columns={vmtemplateTable.columns()}
data={templates}
dataCy={vmtemplateTable.dataCy}
isLoading={isRefreshing}
isRowsSelectable
isMultiRowSelection={false}
getRowId={(row) => row.ID}
onRowClick={redirectToInstantiate}
onRefresh={refresh}
isRefreshing={isRefreshing}
isEnableSearchBar
isEnableSort
isEnableFilters
searchPlaceholder={T.SearchTemplates}
defaultPageSize={5}
pageSizeOptions={[5, 10, 25, 50, 100]}
skeletonRows={4}
size="medium"
/>
</DialogContent>
</Dialog>
onSelect={redirectToInstantiate}
/>
</>
)
}