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:
parent
a6fb6a2f85
commit
3d19709d94
@ -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: '' },
|
||||
|
@ -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 }),
|
||||
})
|
||||
|
@ -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 }),
|
||||
})
|
||||
|
@ -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 }),
|
||||
})
|
||||
|
@ -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)),
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
)
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user