1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-10 01:17:40 +03:00

M #~: Implements only_on hypervisor condition (#2198)

This commit is contained in:
Sergio Betanzos 2022-06-28 17:48:07 +02:00 committed by GitHub
parent a6fb6a2f85
commit 3d19709d94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 11 deletions

View File

@ -16,7 +16,7 @@
import { string, number } from 'yup'
import { INPUT_TYPES, T, HYPERVISORS, Field } from 'client/constants'
const { kvm, vcenter, firecracker, lxc } = HYPERVISORS
const { vcenter, firecracker, lxc } = HYPERVISORS
/** @type {Field[]} List of general fields */
export const GENERAL_FIELDS = [
@ -126,7 +126,7 @@ export const VCENTER_FIELDS = [
{
name: 'VCENTER_ADAPTER_TYPE',
label: T.BusAdapterController,
notOnHypervisors: [kvm, firecracker],
onlyOnHypervisors: [vcenter],
type: INPUT_TYPES.SELECT,
values: [
{ text: '', value: '' },
@ -140,7 +140,7 @@ export const VCENTER_FIELDS = [
{
name: 'VCENTER_DISK_TYPE',
label: T.DiskProvisioningType,
notOnHypervisors: [kvm, firecracker],
onlyOnHypervisors: [vcenter],
type: INPUT_TYPES.SELECT,
values: [
{ text: '', value: '' },

View File

@ -60,7 +60,7 @@ const Content = ({ hypervisor }) => {
const AdvancedOptions = ({ hypervisor } = {}) => ({
id: STEP_ID,
label: T.AdvancedOptions,
resolver: () => SCHEMA(hypervisor),
resolver: SCHEMA(hypervisor),
optionsValidate: { abortEarly: false },
content: () => Content({ hypervisor }),
})

View File

@ -60,7 +60,7 @@ const Content = ({ hypervisor }) => {
const AdvancedOptions = ({ hypervisor } = {}) => ({
id: STEP_ID,
label: T.AdvancedOptions,
resolver: () => SCHEMA(hypervisor),
resolver: SCHEMA(hypervisor),
optionsValidate: { abortEarly: false },
content: () => Content({ hypervisor }),
})

View File

@ -42,7 +42,7 @@ const Content = ({ hypervisor }) => {
const BasicConfiguration = ({ hypervisor } = {}) => ({
id: STEP_ID,
label: T.Configuration,
resolver: () => SCHEMA(hypervisor),
resolver: SCHEMA(hypervisor),
optionsValidate: { abortEarly: false },
content: () => Content({ hypervisor }),
})

View File

@ -49,8 +49,7 @@ export const createColumns = ({ filters = {}, columns = [] }) => {
...((filterById || filterByAccessor) &&
(
{
// TODO: Add label to filters
// label: createLabelFilter,
// TODO: Implements time filter component
time: createTimeFilter,
}[`${id}`.toLowerCase()] ?? createCategoryFilter
)(column)),

View File

@ -288,9 +288,18 @@ export const getActionsAvailable = (actions = {}, hypervisor = '') =>
.filter(([_, action]) => {
if (typeof action === 'boolean') return action
const { enabled = false, not_on: notOn = [] } = action || {}
const {
enabled = false,
not_on: notOn = [],
only_on: onlyOn = [],
} = action || {}
return !!enabled && !notOn?.includes?.(hypervisor)
return (
!!enabled &&
((!notOn && !onlyOn) ||
(notOn && !notOn?.includes?.(hypervisor)) ||
onlyOn?.includes?.(hypervisor))
)
})
.map(([actionName, _]) => actionName)

View File

@ -236,7 +236,10 @@ export const filterFieldsByHypervisor = (
fields
.map((field) => (typeof field === 'function' ? field(hypervisor) : field))
.filter(
({ notOnHypervisors } = {}) => !notOnHypervisors?.includes?.(hypervisor)
({ notOnHypervisors, onlyOnHypervisors } = {}) =>
(!notOnHypervisors && !onlyOnHypervisors) ||
(notOnHypervisors && !notOnHypervisors.includes?.(hypervisor)) ||
onlyOnHypervisors?.includes?.(hypervisor)
)
/**