mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
parent
f006341931
commit
e88f3591ea
@ -41,6 +41,7 @@ const ProvisionCard = memo(
|
||||
isProvider,
|
||||
actions,
|
||||
deleteAction,
|
||||
configureAction,
|
||||
}) => {
|
||||
const {
|
||||
ID,
|
||||
@ -69,6 +70,7 @@ const ProvisionCard = memo(
|
||||
{actions?.map((action) => (
|
||||
<Action key={action?.cy} {...action} />
|
||||
))}
|
||||
{configureAction && <ButtonToTriggerForm {...configureAction} />}
|
||||
{deleteAction && <ButtonToTriggerForm {...deleteAction} />}
|
||||
</>
|
||||
)
|
||||
@ -127,6 +129,7 @@ ProvisionCard.propTypes = {
|
||||
isProvider: PropTypes.bool,
|
||||
image: PropTypes.string,
|
||||
deleteAction: PropTypes.object,
|
||||
configureAction: PropTypes.object,
|
||||
actions: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
handleClick: PropTypes.func.isRequired,
|
||||
@ -143,6 +146,7 @@ ProvisionCard.defaultProps = {
|
||||
isSelected: undefined,
|
||||
image: undefined,
|
||||
deleteAction: undefined,
|
||||
confifureAction: undefined,
|
||||
value: {},
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
/* ------------------------------------------------------------------------- *
|
||||
* Copyright 2002-2022, 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 { createForm } from 'client/utils'
|
||||
import {
|
||||
SCHEMA,
|
||||
FIELDS,
|
||||
} from 'client/components/Forms/Provision/ConfigureForm/schema'
|
||||
|
||||
const ConfigureForm = createForm(SCHEMA, FIELDS)
|
||||
|
||||
export default ConfigureForm
|
@ -0,0 +1,32 @@
|
||||
/* ------------------------------------------------------------------------- *
|
||||
* Copyright 2002-2022, 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 { object, boolean } from 'yup'
|
||||
import { T, INPUT_TYPES } from 'client/constants'
|
||||
import { getValidationFromFields } from 'client/utils'
|
||||
|
||||
const FORCE = {
|
||||
name: 'force',
|
||||
label: T.Force,
|
||||
type: INPUT_TYPES.SWITCH,
|
||||
tooltip: T.ForceConcept,
|
||||
validation: boolean()
|
||||
.notRequired()
|
||||
.default(() => false),
|
||||
}
|
||||
|
||||
export const FIELDS = [FORCE]
|
||||
|
||||
export const SCHEMA = object(getValidationFromFields(FIELDS))
|
@ -31,4 +31,11 @@ const CreateForm = (configProps) =>
|
||||
const DeleteForm = (configProps) =>
|
||||
AsyncLoadForm({ formPath: 'Provision/DeleteForm' }, configProps)
|
||||
|
||||
export { CreateForm, DeleteForm }
|
||||
/**
|
||||
* @param {ConfigurationProps} configProps - Configuration
|
||||
* @returns {ReactElement|CreateFormCallback} Asynchronous loaded form
|
||||
*/
|
||||
const ConfigureForm = (configProps) =>
|
||||
AsyncLoadForm({ formPath: 'Provision/ConfigureForm' }, configProps)
|
||||
|
||||
export { CreateForm, DeleteForm, ConfigureForm }
|
||||
|
@ -281,6 +281,7 @@ module.exports = {
|
||||
CleanupConcept: 'Delete all vms and images first, then delete the resources',
|
||||
Force: 'Force',
|
||||
ForceConcept: 'Force configure to execute',
|
||||
ConfigureProvision: 'Configure provision %s',
|
||||
|
||||
/* sections */
|
||||
Dashboard: 'Dashboard',
|
||||
|
@ -28,7 +28,7 @@ import {
|
||||
import { useSearch, useDialog } from 'client/hooks'
|
||||
import { useGeneralApi } from 'client/features/General'
|
||||
|
||||
import { DeleteForm } from 'client/components/Forms/Provision'
|
||||
import { DeleteForm, ConfigureForm } from 'client/components/Forms/Provision'
|
||||
import { ListHeader, ListCards } from 'client/components/List'
|
||||
import AlertError from 'client/components/Alerts/Error'
|
||||
import { ProvisionCard } from 'client/components/Cards'
|
||||
@ -104,16 +104,33 @@ function Provisions() {
|
||||
CardComponent={ProvisionCard}
|
||||
cardsProps={({ value: { ID, NAME } }) => ({
|
||||
handleClick: () => handleClickfn(ID, NAME),
|
||||
actions: [
|
||||
{
|
||||
handleClick: async () => {
|
||||
await configureProvision({ id: ID })
|
||||
enqueueInfo(`Configuring provision - ID: ${ID}`)
|
||||
},
|
||||
configureAction: {
|
||||
buttonProps: {
|
||||
'data-cy': 'provision-configure',
|
||||
icon: <EditIcon />,
|
||||
cy: 'provision-configure',
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
dialogProps: {
|
||||
title: (
|
||||
<Translate
|
||||
word={T.ConfigureProvision}
|
||||
values={`#${ID} ${NAME}`}
|
||||
/>
|
||||
),
|
||||
},
|
||||
form: ConfigureForm,
|
||||
onSubmit: async (formData) => {
|
||||
try {
|
||||
await configureProvision({ id: ID, ...formData })
|
||||
enqueueInfo(`Configuring provision - ID: ${ID}`)
|
||||
} finally {
|
||||
hide()
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
deleteAction: {
|
||||
buttonProps: {
|
||||
'data-cy': 'provision-delete',
|
||||
|
@ -173,6 +173,7 @@ const provisionApi = oneApi.injectEndpoints({
|
||||
*
|
||||
* @param {object} params - Request parameters
|
||||
* @param {string} params.id - Provision id
|
||||
* @param {boolean} params.force - Force configure to execute
|
||||
* @returns {object} Object of document updated
|
||||
* @throws Fails when response isn't code 200
|
||||
*/
|
||||
|
@ -127,6 +127,9 @@ module.exports = {
|
||||
id: {
|
||||
from: resource,
|
||||
},
|
||||
force: {
|
||||
from: postBody,
|
||||
},
|
||||
},
|
||||
},
|
||||
[PROVISION_GET_RESOURCE]: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user