mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-02 05:06:14 +09:00
L #~: Add new rules to FireEdge linter (#1648)
This commit is contained in:
1 parent
39f89538b5
commit
564dab6171
60 files changed
+539
-413
No files matched your search
+27
-5
@@ -19,10 +19,24 @@
|
||||
},
|
||||
"plugins": ["jsdoc", "react", "header", "prettier"],
|
||||
"rules": {
|
||||
"prettier/prettier": ["error", {
|
||||
"singleQuote": true,
|
||||
"semi": false,
|
||||
"trailingComma": "es5",
|
||||
"default-case": "off",
|
||||
"prefer-const": ["error", {
|
||||
"destructuring": "all"
|
||||
}],
|
||||
"arrow-body-style": ["error", "as-needed"],
|
||||
"no-restricted-syntax": [
|
||||
"error",
|
||||
"ForInStatement",
|
||||
"LabeledStatement",
|
||||
"WithStatement"
|
||||
],
|
||||
"no-return-assign": ["error", "except-parens"],
|
||||
"no-param-reassign": ["error", {
|
||||
"props": false
|
||||
}],
|
||||
"no-shadow": ["error", {
|
||||
"hoist": "all",
|
||||
"allow": ["resolve", "reject", "done", "next", "err", "error", "children"]
|
||||
}],
|
||||
"import/no-extraneous-dependencies": ["error", {
|
||||
"devDependencies": ["*.js"]
|
||||
@@ -34,7 +48,15 @@
|
||||
}],
|
||||
"react/jsx-uses-react": "off",
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"default-case": 0,
|
||||
"react/display-name": "warn",
|
||||
"react/no-array-index-key": "off",
|
||||
"react/require-default-props": "off",
|
||||
"react/forbid-prop-types": "off",
|
||||
"prettier/prettier": ["error", {
|
||||
"singleQuote": true,
|
||||
"semi": false,
|
||||
"trailingComma": "es5"
|
||||
}],
|
||||
"jsdoc/require-jsdoc": ["error", {
|
||||
"publicOnly": true,
|
||||
"require": {
|
||||
|
||||
@@ -147,8 +147,8 @@ const SelectCard = memo(
|
||||
{/* CARD ACTIONS */}
|
||||
{actions?.length > 0 && (
|
||||
<CardActions {...cardActionsProps}>
|
||||
{actions?.map((action) => (
|
||||
<Action key={action?.cy} {...action} />
|
||||
{actions?.map((actionProps) => (
|
||||
<Action key={actionProps?.cy} {...actionProps} />
|
||||
))}
|
||||
</CardActions>
|
||||
)}
|
||||
|
||||
@@ -53,7 +53,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
* @returns {JSXElementConstructor} Chart bar component
|
||||
*/
|
||||
const SingleBar = ({ legend, data, total = 0 }) => {
|
||||
const fragments = data.map((data) => Math.floor((data * 10) / (total || 1)))
|
||||
const fragments = data.map((frag) => Math.floor((frag * 10) / (total || 1)))
|
||||
|
||||
const classes = useStyles({ fragments })
|
||||
|
||||
|
||||
@@ -120,14 +120,15 @@ ansiHTML.setColors = function (colors) {
|
||||
}
|
||||
|
||||
const _finalColors = {}
|
||||
for (const key in _defColors) {
|
||||
Object.entries(_defColors).forEach(([key, defHexColor]) => {
|
||||
let hex = Object.prototype.hasOwnProperty.call(colors, key)
|
||||
? colors[key]
|
||||
: null
|
||||
|
||||
if (!hex) {
|
||||
_finalColors[key] = _defColors[key]
|
||||
continue
|
||||
_finalColors[key] = defHexColor
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (key === 'reset') {
|
||||
@@ -138,17 +139,13 @@ ansiHTML.setColors = function (colors) {
|
||||
if (
|
||||
!Array.isArray(hex) ||
|
||||
hex.length === 0 ||
|
||||
hex.some(function (h) {
|
||||
return typeof h !== 'string'
|
||||
})
|
||||
hex.some((h) => typeof h !== 'string')
|
||||
) {
|
||||
throw new Error(
|
||||
`The value of '${key}' property must be an Array and each item could only be a hex string, e.g.: FF0000`
|
||||
)
|
||||
}
|
||||
|
||||
const defHexColor = _defColors[key]
|
||||
|
||||
if (!hex[0]) {
|
||||
hex[0] = defHexColor[0]
|
||||
}
|
||||
@@ -166,7 +163,8 @@ ansiHTML.setColors = function (colors) {
|
||||
}
|
||||
|
||||
_finalColors[key] = hex
|
||||
}
|
||||
})
|
||||
|
||||
_setTags(_finalColors)
|
||||
}
|
||||
|
||||
@@ -208,12 +206,11 @@ const _setTags = (colors) => {
|
||||
// dark grey
|
||||
_openTags[90] = `color:#${colors.darkgrey}`
|
||||
|
||||
for (const code in _styles) {
|
||||
const color = _styles[code]
|
||||
Object.entries(_styles).forEach(([code, color]) => {
|
||||
const oriColor = colors[color] || '000'
|
||||
_openTags[code] = `color:#${oriColor}`
|
||||
_openTags[(parseInt(code) + 10).toString()] = `background:#${oriColor}`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
ansiHTML.reset()
|
||||
@@ -27,7 +27,7 @@ const WrapperToLoadLib = ({ children, id, lib }) => {
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const loadLib = async (lib) => {
|
||||
const loadLib = async () => {
|
||||
try {
|
||||
await import(lib)
|
||||
} finally {
|
||||
|
||||
@@ -87,19 +87,22 @@ const FormStepper = ({ steps = [], schema, onSubmit }) => {
|
||||
const totalErrors = Object.keys(errorsByPath).length
|
||||
|
||||
totalErrors > 0
|
||||
? setError(id, {
|
||||
? setError(stepId, {
|
||||
type: 'manual',
|
||||
message: [T.ErrorsOcurred, totalErrors],
|
||||
})
|
||||
: setError(id, rest)
|
||||
: setError(stepId, rest)
|
||||
|
||||
inner?.forEach(({ path, type, errors: message }) => {
|
||||
if (isDevelopment()) {
|
||||
// the package @hookform/devtools requires message as string
|
||||
const [key, ...values] = [message].flat()
|
||||
setError(`${id}.${path}`, { type, message: sprintf(key, ...values) })
|
||||
setError(`${stepId}.${path}`, {
|
||||
type,
|
||||
message: sprintf(key, ...values),
|
||||
})
|
||||
} else {
|
||||
setError(`${id}.${path}`, { type, message })
|
||||
setError(`${stepId}.${path}`, { type, message })
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -160,7 +163,7 @@ const FormStepper = ({ steps = [], schema, onSubmit }) => {
|
||||
[activeStep]
|
||||
)
|
||||
|
||||
const { id, content: Content } = useMemo(
|
||||
const { id: stepId, content: Content } = useMemo(
|
||||
() => steps[activeStep],
|
||||
[formData, activeStep]
|
||||
)
|
||||
@@ -195,10 +198,10 @@ const FormStepper = ({ steps = [], schema, onSubmit }) => {
|
||||
errors={errors}
|
||||
/>
|
||||
),
|
||||
[isLoading, isMobile, activeStep, errors[id]]
|
||||
[isLoading, isMobile, activeStep, errors[stepId]]
|
||||
)}
|
||||
{/* FORM CONTENT */}
|
||||
{Content && <Content data={formData[id]} setFormData={setFormData} />}
|
||||
{Content && <Content data={formData[stepId]} setFormData={setFormData} />}
|
||||
|
||||
{isDevelopment() && <DevTool control={control} placement="top-left" />}
|
||||
</>
|
||||
|
||||
@@ -33,14 +33,12 @@ const StyledLegend = styled((props) => (
|
||||
}))
|
||||
|
||||
const Legend = memo(
|
||||
({ title, tooltip }) => {
|
||||
return (
|
||||
<StyledLegend tooltip={tooltip}>
|
||||
{labelCanBeTranslated(title) ? Tr(title) : title}
|
||||
{!!tooltip && <AdornmentWithTooltip title={tooltip} />}
|
||||
</StyledLegend>
|
||||
)
|
||||
},
|
||||
({ title, tooltip }) => (
|
||||
<StyledLegend tooltip={tooltip}>
|
||||
{labelCanBeTranslated(title) ? Tr(title) : title}
|
||||
{!!tooltip && <AdornmentWithTooltip title={tooltip} />}
|
||||
</StyledLegend>
|
||||
),
|
||||
(prev, next) => prev.title === next.title && prev.tooltip === next.tooltip
|
||||
)
|
||||
|
||||
|
||||
@@ -22,9 +22,8 @@ import MarketplacesTable, {
|
||||
import { createSteps } from 'client/utils'
|
||||
|
||||
const Steps = createSteps([BasicConfiguration, MarketplacesTable], {
|
||||
transformInitialValue: (initialValues, schema) => {
|
||||
return schema.cast({ [BASIC_ID]: initialValues }, { stripUnknown: true })
|
||||
},
|
||||
transformInitialValue: (initialValues, schema) =>
|
||||
schema.cast({ [BASIC_ID]: initialValues }, { stripUnknown: true }),
|
||||
transformBeforeSubmit: (formData) => {
|
||||
const { [BASIC_ID]: configuration, [MARKET_ID]: [market] = [] } = formData
|
||||
|
||||
|
||||
+7
-9
@@ -25,15 +25,13 @@ import { T } from 'client/constants'
|
||||
|
||||
export const STEP_ID = 'configuration'
|
||||
|
||||
const Content = ({ isUpdate }) => {
|
||||
return (
|
||||
<FormWithSchema
|
||||
cy="form-provider"
|
||||
id={STEP_ID}
|
||||
fields={FORM_FIELDS({ isUpdate })}
|
||||
/>
|
||||
)
|
||||
}
|
||||
const Content = ({ isUpdate }) => (
|
||||
<FormWithSchema
|
||||
cy="form-provider"
|
||||
id={STEP_ID}
|
||||
fields={FORM_FIELDS({ isUpdate })}
|
||||
/>
|
||||
)
|
||||
|
||||
const BasicConfiguration = ({ isUpdate }) => ({
|
||||
id: STEP_ID,
|
||||
|
||||
+6
-3
@@ -75,7 +75,7 @@ const Content = ({ data, setFormData }) => {
|
||||
() => templateSelected?.plain?.provision_type ?? provisionTypes[0]
|
||||
)
|
||||
|
||||
const [templatesByProvisionSelected, providerTypes, description] =
|
||||
const [templatesByProvisionSelected, providerTypes, providerDescription] =
|
||||
useMemo(() => {
|
||||
const templates = Object.values(
|
||||
provisionTemplates[provisionSelected]?.providers
|
||||
@@ -194,8 +194,11 @@ const Content = ({ data, setFormData }) => {
|
||||
|
||||
{/* -- DESCRIPTION -- */}
|
||||
{useMemo(
|
||||
() => description && <RenderDescription description={description} />,
|
||||
[description]
|
||||
() =>
|
||||
providerDescription && (
|
||||
<RenderDescription description={providerDescription} />
|
||||
),
|
||||
[providerDescription]
|
||||
)}
|
||||
|
||||
<Divider style={{ margin: '1rem 0' }} />
|
||||
|
||||
@@ -71,12 +71,11 @@ const Inputs = () => ({
|
||||
|
||||
// MERGE INPUTS provision template + PROVISION_BODY.inputs (provider fetch)
|
||||
inputs = templateInputs.map((templateInput) => {
|
||||
const providerInput =
|
||||
PROVISION_BODY.inputs?.find(
|
||||
(providerInput) => providerInput.name === templateInput.name
|
||||
) ?? {}
|
||||
const providerInput = PROVISION_BODY.inputs?.find(
|
||||
(input) => input.name === templateInput.name
|
||||
)
|
||||
|
||||
return deepmerge(templateInput, providerInput)
|
||||
return deepmerge(templateInput, providerInput ?? {})
|
||||
})
|
||||
|
||||
setFields(FORM_FIELDS(inputs))
|
||||
|
||||
+6
-3
@@ -78,7 +78,7 @@ const Template = () => ({
|
||||
() => templateSelected?.provision_type ?? provisionTypes[0]
|
||||
)
|
||||
|
||||
const [templatesByProvisionSelected, providerTypes, description] =
|
||||
const [templatesByProvisionSelected, providerTypes, providerDescription] =
|
||||
useMemo(() => {
|
||||
const templates = Object.values(
|
||||
provisionTemplates[provisionSelected]?.provisions
|
||||
@@ -209,8 +209,11 @@ const Template = () => ({
|
||||
|
||||
{/* -- DESCRIPTION -- */}
|
||||
{useMemo(
|
||||
() => description && <RenderDescription description={description} />,
|
||||
[description]
|
||||
() =>
|
||||
providerDescription && (
|
||||
<RenderDescription description={providerDescription} />
|
||||
),
|
||||
[providerDescription]
|
||||
)}
|
||||
|
||||
<Divider style={{ margin: '1rem 0' }} />
|
||||
|
||||
+26
-30
@@ -69,38 +69,34 @@ export const FIELDS = (vm) => [...COMMON_FIELDS(vm), ...RELATIVE_FIELDS]
|
||||
export const SCHEMA = yup
|
||||
.object(getValidationFromFields(RELATIVE_FIELDS))
|
||||
.concat(COMMON_SCHEMA)
|
||||
.transform((value) => {
|
||||
const {
|
||||
[PERIOD_FIELD.name]: PERIOD,
|
||||
[TIME_FIELD.name]: TIME,
|
||||
...rest
|
||||
} = value
|
||||
.transform(
|
||||
({ [PERIOD_FIELD.name]: PERIOD, [TIME_FIELD.name]: TIME, ...rest }) => {
|
||||
if (String(TIME).includes('+')) {
|
||||
const allPeriods = {
|
||||
[PERIOD_TYPES.YEARS]: TIME / 365 / 24 / 3600,
|
||||
[PERIOD_TYPES.MONTHS]: TIME / 30 / 24 / 3600,
|
||||
[PERIOD_TYPES.WEEKS]: TIME / 7 / 24 / 3600,
|
||||
[PERIOD_TYPES.DAYS]: TIME / 24 / 3600,
|
||||
[PERIOD_TYPES.HOURS]: TIME / 3600,
|
||||
[PERIOD_TYPES.MINUTES]: TIME / 60,
|
||||
}
|
||||
|
||||
if (String(TIME).includes('+')) {
|
||||
const allPeriods = {
|
||||
[PERIOD_TYPES.YEARS]: TIME / 365 / 24 / 3600,
|
||||
[PERIOD_TYPES.MONTHS]: TIME / 30 / 24 / 3600,
|
||||
[PERIOD_TYPES.WEEKS]: TIME / 7 / 24 / 3600,
|
||||
[PERIOD_TYPES.DAYS]: TIME / 24 / 3600,
|
||||
[PERIOD_TYPES.HOURS]: TIME / 3600,
|
||||
[PERIOD_TYPES.MINUTES]: TIME / 60,
|
||||
const [period, time] = Object.entries(allPeriods).find(
|
||||
([_, value]) => value >= 1
|
||||
)
|
||||
|
||||
return { ...rest, [PERIOD_FIELD.name]: period, [TIME_FIELD.name]: time }
|
||||
}
|
||||
|
||||
const [period, time] = Object.entries(allPeriods).find(
|
||||
([_, time]) => time >= 1
|
||||
)
|
||||
const timeInMilliseconds = {
|
||||
[PERIOD_TYPES.YEARS]: TIME * 365 * 24 * 3600,
|
||||
[PERIOD_TYPES.MONTHS]: TIME * 30 * 24 * 3600,
|
||||
[PERIOD_TYPES.WEEKS]: TIME * 7 * 24 * 3600,
|
||||
[PERIOD_TYPES.DAYS]: TIME * 24 * 3600,
|
||||
[PERIOD_TYPES.HOURS]: TIME * 3600,
|
||||
[PERIOD_TYPES.MINUTES]: TIME * 60,
|
||||
}[PERIOD]
|
||||
|
||||
return { ...rest, [PERIOD_FIELD.name]: period, [TIME_FIELD.name]: time }
|
||||
return { ...rest, [TIME_FIELD.name]: timeInMilliseconds }
|
||||
}
|
||||
|
||||
const timeInMilliseconds = {
|
||||
[PERIOD_TYPES.YEARS]: TIME * 365 * 24 * 3600,
|
||||
[PERIOD_TYPES.MONTHS]: TIME * 30 * 24 * 3600,
|
||||
[PERIOD_TYPES.WEEKS]: TIME * 7 * 24 * 3600,
|
||||
[PERIOD_TYPES.DAYS]: TIME * 24 * 3600,
|
||||
[PERIOD_TYPES.HOURS]: TIME * 3600,
|
||||
[PERIOD_TYPES.MINUTES]: TIME * 60,
|
||||
}[PERIOD]
|
||||
|
||||
return { ...rest, [TIME_FIELD.name]: timeInMilliseconds }
|
||||
})
|
||||
)
|
||||
+9
-3
@@ -70,7 +70,9 @@ const BootItemDraggable = styled('div')(({ theme, disabled }) => ({
|
||||
*/
|
||||
export const reorderBootAfterRemove = (id, list, currentBootOrder) => {
|
||||
const type = String(id).toLowerCase().replace(/\d+/g, '') // nic | disk
|
||||
const getIndexFromId = (id) => String(id).toLowerCase().replace(type, '')
|
||||
|
||||
const getIndexFromId = (bootId) => `${bootId}`.toLowerCase().replace(type, '')
|
||||
|
||||
const idxToRemove = getIndexFromId(id)
|
||||
|
||||
const otherIds = list
|
||||
@@ -195,12 +197,16 @@ const BootOrder = () => {
|
||||
draggableId={ID}
|
||||
index={idx}
|
||||
>
|
||||
{({ draggableProps, dragHandleProps, innerRef }) => (
|
||||
{({
|
||||
draggableProps,
|
||||
dragHandleProps,
|
||||
innerRef: dragRef,
|
||||
}) => (
|
||||
<BootItemDraggable
|
||||
{...draggableProps}
|
||||
{...dragHandleProps}
|
||||
disabled={disabled}
|
||||
ref={innerRef}
|
||||
ref={dragRef}
|
||||
>
|
||||
<Checkbox
|
||||
checked={!disabled}
|
||||
|
||||
+7
-9
@@ -27,15 +27,13 @@ import { T } from 'client/constants'
|
||||
|
||||
export const TAB_ID = ['CONTEXT', USER_INPUTS_ID]
|
||||
|
||||
const Context = (props) => {
|
||||
return (
|
||||
<>
|
||||
<ConfigurationSection />
|
||||
<FilesSection {...props} />
|
||||
<UserInputsSection />
|
||||
</>
|
||||
)
|
||||
}
|
||||
const Context = (props) => (
|
||||
<>
|
||||
<ConfigurationSection />
|
||||
<FilesSection {...props} />
|
||||
<UserInputsSection />
|
||||
</>
|
||||
)
|
||||
|
||||
Context.propTypes = {
|
||||
data: PropTypes.any,
|
||||
|
||||
+7
-7
@@ -40,7 +40,7 @@ const {
|
||||
boolean: uiBoolean,
|
||||
} = USER_INPUT_TYPES
|
||||
|
||||
const { array: _, ...userInputTypes } = USER_INPUT_TYPES
|
||||
const { array: __, ...userInputTypes } = USER_INPUT_TYPES
|
||||
|
||||
/** @type {UserInputType[]} User inputs types */
|
||||
const valuesOfUITypes = Object.values(userInputTypes)
|
||||
@@ -169,17 +169,17 @@ const DEFAULT_VALUE = {
|
||||
validation: string()
|
||||
.trim()
|
||||
.default(() => undefined)
|
||||
.when([TYPE.name, OPTIONS.name], (type, options = [], schema) => {
|
||||
return (
|
||||
{
|
||||
.when(
|
||||
[TYPE.name, OPTIONS.name],
|
||||
(type, options = [], schema) =>
|
||||
({
|
||||
[uiList]: schema.oneOf(options).notRequired(),
|
||||
[uiListMultiple]: schema.includesInOptions(options),
|
||||
[uiRange]: number().min(ref(MIN.name)).max(ref(MAX.name)).integer(),
|
||||
[uiRangeFloat]: number().min(ref(MIN.name)).max(ref(MAX.name)),
|
||||
[uiPassword]: schema.strip().notRequired(),
|
||||
}[type] ?? schema
|
||||
)
|
||||
}),
|
||||
}[type] ?? schema)
|
||||
),
|
||||
grid: { sm: 6, md: 4 },
|
||||
}
|
||||
|
||||
|
||||
+14
-7
@@ -40,7 +40,7 @@ const getPciAttributes = (pciDevice = '') => {
|
||||
}
|
||||
|
||||
/** @type {Field} Name PCI device field */
|
||||
const DEVICE_NAME = {
|
||||
const NAME_FIELD = {
|
||||
name: 'DEVICE_NAME',
|
||||
label: T.DeviceName,
|
||||
notOnHypervisors: [vcenter, lxc, firecracker],
|
||||
@@ -63,7 +63,7 @@ const commonFieldProps = (name) => ({
|
||||
name,
|
||||
notOnHypervisors: [vcenter, lxc, firecracker],
|
||||
type: INPUT_TYPES.TEXT,
|
||||
dependOf: DEVICE_NAME.name,
|
||||
dependOf: NAME_FIELD.name,
|
||||
watcher: (pciDevice) => {
|
||||
if (pciDevice) {
|
||||
const { [name]: attribute } = getPciAttributes(pciDevice)
|
||||
@@ -77,23 +77,30 @@ const commonFieldProps = (name) => ({
|
||||
})
|
||||
|
||||
/** @type {Field} PCI device field */
|
||||
const DEVICE = { label: T.Device, ...commonFieldProps('DEVICE') }
|
||||
const DEVICE_FIELD = { label: T.Device, ...commonFieldProps('DEVICE') }
|
||||
|
||||
/** @type {Field} PCI device field */
|
||||
const VENDOR = { label: T.Vendor, ...commonFieldProps('VENDOR') }
|
||||
const VENDOR_FIELD = { label: T.Vendor, ...commonFieldProps('VENDOR') }
|
||||
|
||||
/** @type {Field} PCI device field */
|
||||
const CLASS = { label: T.Class, ...commonFieldProps('CLASS') }
|
||||
const CLASS_FIELD = { label: T.Class, ...commonFieldProps('CLASS') }
|
||||
|
||||
/**
|
||||
* @param {string} [hypervisor] - VM hypervisor
|
||||
* @returns {Field[]} List of Graphic inputs fields
|
||||
*/
|
||||
export const PCI_FIELDS = (hypervisor) =>
|
||||
filterFieldsByHypervisor([DEVICE_NAME, DEVICE, VENDOR, CLASS], hypervisor)
|
||||
filterFieldsByHypervisor(
|
||||
[NAME_FIELD, DEVICE_FIELD, VENDOR_FIELD, CLASS_FIELD],
|
||||
hypervisor
|
||||
)
|
||||
|
||||
/** @type {ObjectSchema} PCI devices object schema */
|
||||
export const PCI_SCHEMA = getObjectSchemaFromFields([DEVICE, VENDOR, CLASS])
|
||||
export const PCI_SCHEMA = getObjectSchemaFromFields([
|
||||
DEVICE_FIELD,
|
||||
VENDOR_FIELD,
|
||||
CLASS_FIELD,
|
||||
])
|
||||
|
||||
/** @type {ObjectSchema} PCI devices schema */
|
||||
export const PCI_DEVICES_SCHEMA = object({
|
||||
|
||||
+14
-16
@@ -28,22 +28,20 @@ import { T } from 'client/constants'
|
||||
|
||||
export const TAB_ID = 'NUMA'
|
||||
|
||||
const Numa = ({ hypervisor }) => {
|
||||
return (
|
||||
<>
|
||||
<FormWithSchema
|
||||
cy={`${EXTRA_ID}.vcpu`}
|
||||
fields={[VCPU_FIELD]}
|
||||
id={GENERAL_ID}
|
||||
/>
|
||||
<FormWithSchema
|
||||
cy={`${EXTRA_ID}.numa`}
|
||||
fields={NUMA_FIELDS(hypervisor)}
|
||||
id={EXTRA_ID}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
const Numa = ({ hypervisor }) => (
|
||||
<>
|
||||
<FormWithSchema
|
||||
cy={`${EXTRA_ID}.vcpu`}
|
||||
fields={[VCPU_FIELD]}
|
||||
id={GENERAL_ID}
|
||||
/>
|
||||
<FormWithSchema
|
||||
cy={`${EXTRA_ID}.numa`}
|
||||
fields={NUMA_FIELDS(hypervisor)}
|
||||
id={EXTRA_ID}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
|
||||
Numa.propTypes = {
|
||||
data: PropTypes.any,
|
||||
|
||||
+12
-14
@@ -28,26 +28,24 @@ import {
|
||||
} from 'client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/placement/schema'
|
||||
import { T } from 'client/constants'
|
||||
|
||||
const Placement = () => {
|
||||
const Placement = () => (
|
||||
// TODO - Host requirements: add button to select HOST in list => ID="<id>"
|
||||
// TODO - Host policy options: Packing|Stripping|Load-aware
|
||||
|
||||
// TODO - DS requirements: add button to select DATASTORE in list => ID="<id>"
|
||||
// TODO - DS policy options: Packing|Stripping
|
||||
|
||||
return (
|
||||
<>
|
||||
{SECTIONS.map(({ id, ...section }) => (
|
||||
<FormWithSchema
|
||||
key={id}
|
||||
id={EXTRA_ID}
|
||||
cy={`${EXTRA_ID}.${id}`}
|
||||
{...section}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
<>
|
||||
{SECTIONS.map(({ id, ...section }) => (
|
||||
<FormWithSchema
|
||||
key={id}
|
||||
id={EXTRA_ID}
|
||||
cy={`${EXTRA_ID}.${id}`}
|
||||
{...section}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
|
||||
Placement.propTypes = {
|
||||
data: PropTypes.any,
|
||||
|
||||
@@ -43,7 +43,7 @@ const Steps = createSteps(
|
||||
{ stripUnknown: true }
|
||||
),
|
||||
}),
|
||||
transformBeforeSubmit: (formData) => {
|
||||
transformBeforeSubmit: (formData, vmTemplate) => {
|
||||
const {
|
||||
[TEMPLATE_ID]: [templateSelected] = [],
|
||||
[BASIC_ID]: { name, instances, hold, persistent, ...restOfConfig } = {},
|
||||
@@ -59,7 +59,7 @@ const Steps = createSteps(
|
||||
...data,
|
||||
}))
|
||||
|
||||
return [templateSelected, templates]
|
||||
return [templateSelected ?? vmTemplate, templates]
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -44,7 +44,9 @@ const InstantiateForm = ({ template, onSubmit }) => {
|
||||
<FormStepper
|
||||
steps={steps}
|
||||
schema={resolver}
|
||||
onSubmit={(data) => onSubmit(transformBeforeSubmit?.(data) ?? data)}
|
||||
onSubmit={(data) =>
|
||||
onSubmit(transformBeforeSubmit?.(data, template) ?? data)
|
||||
}
|
||||
/>
|
||||
</FormProvider>
|
||||
)
|
||||
|
||||
@@ -70,9 +70,8 @@ const ButtonGroup = memo(
|
||||
const Group = () => {
|
||||
const { user, groups } = useAuth()
|
||||
|
||||
const sortGroupAsMainFirst = (a, b) => {
|
||||
return a.ID === user?.GUID ? -1 : b.ID === user?.GUID ? 1 : 0
|
||||
}
|
||||
const sortGroupAsMainFirst = (a, b) =>
|
||||
a.ID === user?.GUID ? -1 : b.ID === user?.GUID ? 1 : 0
|
||||
|
||||
const sortMainGroupFirst = useMemo(
|
||||
() =>
|
||||
|
||||
@@ -16,16 +16,14 @@
|
||||
import { memo } from 'react'
|
||||
import { number, string, oneOfType } from 'prop-types'
|
||||
|
||||
const DockerLogo = memo(({ viewBox, width, height, color, ...props }) => {
|
||||
return (
|
||||
<svg viewBox={viewBox} width={width} height={height} {...props}>
|
||||
<path
|
||||
fill={color}
|
||||
d="M296 245h42v-38h-42zm-50 0h42v-38h-42zm-49 0h42v-38h-42zm-49 0h41v-38h-41zm-50 0h42v-38H98zm50-46h41v-38h-41zm49 0h42v-38h-42zm49 0h42v-38h-42zm0-46h42v-38h-42zm226 75s-18-17-55-11c-4-29-35-46-35-46s-29 35-8 74c-6 3-16 7-31 7H68c-5 19-5 145 133 145 99 0 173-46 208-130 52 4 63-39 63-39z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
})
|
||||
const DockerLogo = memo(({ viewBox, width, height, color, ...props }) => (
|
||||
<svg viewBox={viewBox} width={width} height={height} {...props}>
|
||||
<path
|
||||
fill={color}
|
||||
d="M296 245h42v-38h-42zm-50 0h42v-38h-42zm-49 0h42v-38h-42zm-49 0h41v-38h-41zm-50 0h42v-38H98zm50-46h41v-38h-41zm49 0h42v-38h-42zm49 0h42v-38h-42zm0-46h42v-38h-42zm226 75s-18-17-55-11c-4-29-35-46-35-46s-29 35-8 74c-6 3-16 7-31 7H68c-5 19-5 145 133 145 99 0 173-46 208-130 52 4 63-39 63-39z"
|
||||
/>
|
||||
</svg>
|
||||
))
|
||||
|
||||
DockerLogo.propTypes = {
|
||||
width: oneOfType([number, string]).isRequired,
|
||||
|
||||
@@ -75,8 +75,8 @@ const SidebarCollapseItem = ({ label = '', routes = [], icon: Icon }) => {
|
||||
<List component="div" disablePadding>
|
||||
{routes
|
||||
?.filter(
|
||||
({ sidebar = false, label }) =>
|
||||
sidebar && typeof label === 'string'
|
||||
({ sidebar = false, ...route }) =>
|
||||
sidebar && typeof route.label === 'string'
|
||||
)
|
||||
?.map((subItem, index) => (
|
||||
<SidebarLink key={`subitem-${index}`} isSubItem {...subItem} />
|
||||
|
||||
@@ -57,18 +57,18 @@ const CategoryFilter = ({
|
||||
|
||||
// Calculate the options for filtering using the preFilteredRows
|
||||
const options = useMemo(() => {
|
||||
const options = {}
|
||||
const filteredOptions = {}
|
||||
|
||||
preFilteredRows?.forEach((row) => {
|
||||
const value = row.values[id]
|
||||
|
||||
if (!value) return
|
||||
|
||||
const count = options[value[accessorOption] ?? value] || 0
|
||||
options[value[accessorOption] ?? value] = count + 1
|
||||
const count = filteredOptions[value[accessorOption] ?? value] || 0
|
||||
filteredOptions[value[accessorOption] ?? value] = count + 1
|
||||
})
|
||||
|
||||
return options
|
||||
return filteredOptions
|
||||
}, [id, preFilteredRows])
|
||||
|
||||
const handleSelect = (value) => {
|
||||
|
||||
@@ -92,7 +92,7 @@ const ActionItem = memo(
|
||||
buttonProps={buttonProps}
|
||||
options={options?.map((option) => {
|
||||
const {
|
||||
accessor,
|
||||
accessor: optionAccessor,
|
||||
form,
|
||||
onSubmit,
|
||||
dialogProps,
|
||||
@@ -102,7 +102,7 @@ const ActionItem = memo(
|
||||
|
||||
return {
|
||||
...option,
|
||||
cy: accessor && `action.${accessor}`,
|
||||
cy: optionAccessor && `action-${optionAccessor}`,
|
||||
disabled:
|
||||
typeof optionDisabled === 'function'
|
||||
? optionDisabled(selectedRows)
|
||||
|
||||
@@ -78,8 +78,8 @@ const GlobalFilter = ({ useTableProps, className }) => {
|
||||
|
||||
const handleChange = useCallback(
|
||||
// Set undefined to remove the filter entirely
|
||||
debounce((value) => {
|
||||
setGlobalFilter(value || undefined)
|
||||
debounce((newFilter) => {
|
||||
setGlobalFilter(newFilter || undefined)
|
||||
}, 200)
|
||||
)
|
||||
|
||||
|
||||
@@ -65,15 +65,15 @@ const LabelFilter = ({ title, column }) => {
|
||||
useEffect(() => () => setFilter([]), [])
|
||||
|
||||
const labels = useMemo(() => {
|
||||
const labels = new Set()
|
||||
const uniqueLabels = new Set()
|
||||
|
||||
preFilteredRows?.forEach((row) => {
|
||||
const labelsFromTemplate = row.values[id]
|
||||
|
||||
labelsFromTemplate.forEach(labels.add, labels)
|
||||
labelsFromTemplate.forEach(uniqueLabels.add, uniqueLabels)
|
||||
})
|
||||
|
||||
return [...labels.values()]
|
||||
return [...uniqueLabels.values()]
|
||||
}, [id, preFilteredRows])
|
||||
|
||||
const tree = useMemo(() => buildTree(labels), [labels])
|
||||
@@ -87,8 +87,8 @@ const LabelFilter = ({ title, column }) => {
|
||||
|
||||
const isFiltered = useMemo(() => filterValue?.length > 0, [filterValue])
|
||||
|
||||
const renderTree = ({ id, name, children }) => (
|
||||
<TreeItem key={id} nodeId={id} label={name}>
|
||||
const renderTree = ({ id: treeId, name, children }) => (
|
||||
<TreeItem key={treeId} nodeId={treeId} label={name}>
|
||||
{Array.isArray(children)
|
||||
? children.map((node) => renderTree(node))
|
||||
: null}
|
||||
|
||||
@@ -72,7 +72,7 @@ const Attribute = memo(
|
||||
const handleActiveEditForm = async () => {
|
||||
const response = (await handleGetOptionList?.()) ?? []
|
||||
const isFormatValid = response?.every?.(
|
||||
({ text, value } = {}) => !!text && !!value
|
||||
({ text, value: optionValue } = {}) => !!text && !!optionValue
|
||||
)
|
||||
|
||||
if (!handleGetOptionList || isFormatValid) {
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
* ------------------------------------------------------------------------- */
|
||||
/* eslint-disable jsdoc/require-jsdoc */
|
||||
|
||||
const VmLogTab = (data) => {
|
||||
return (
|
||||
<div>
|
||||
<p>WIP - LOG</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const VmLogTab = (data) => (
|
||||
<div>
|
||||
<p>WIP - LOG</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
VmLogTab.displayName = 'VmLogTab'
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* ------------------------------------------------------------------------- *
|
||||
* Copyright 2002-2021, 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 { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { styled, useMediaQuery } from '@mui/material'
|
||||
import Typography from '@mui/material/Typography'
|
||||
|
||||
import MultipleTags from 'client/components/MultipleTags'
|
||||
|
||||
import { Translate } from 'client/components/HOC'
|
||||
import { T } from 'client/constants'
|
||||
|
||||
const DATACY_ALIAS = 'alias-'
|
||||
|
||||
const Row = styled('div')({
|
||||
display: 'flex',
|
||||
width: '100%',
|
||||
gap: '0.5em',
|
||||
alignItems: 'center',
|
||||
flexWrap: 'nowrap',
|
||||
})
|
||||
|
||||
const Labels = styled('span')({
|
||||
display: 'inline-flex',
|
||||
gap: '0.5em',
|
||||
alignItems: 'center',
|
||||
})
|
||||
|
||||
const Alias = memo(({ alias, isPciDevice, detachAction }) => {
|
||||
const isMobile = useMediaQuery((theme) => theme.breakpoints.down('md'))
|
||||
const { NIC_ID, NETWORK, IP, MAC, BRIDGE } = alias
|
||||
|
||||
const tags = [
|
||||
{
|
||||
text: IP,
|
||||
dataCy: `${DATACY_ALIAS}ip`,
|
||||
},
|
||||
{
|
||||
text: MAC,
|
||||
dataCy: `${DATACY_ALIAS}mac`,
|
||||
},
|
||||
{
|
||||
text: BRIDGE && `BRIDGE - ${BRIDGE}`,
|
||||
dataCy: `${DATACY_ALIAS}bridge`,
|
||||
},
|
||||
].filter(({ text } = {}) => Boolean(text))
|
||||
|
||||
return (
|
||||
<Row key={NIC_ID} data-cy={`${DATACY_ALIAS}${NIC_ID}`}>
|
||||
<Typography noWrap variant="body2" data-cy={`${DATACY_ALIAS}name`}>
|
||||
<Translate word={T.Alias} />
|
||||
{`${NIC_ID} | ${NETWORK}`}
|
||||
</Typography>
|
||||
<Labels>
|
||||
<MultipleTags clipboard limitTags={isMobile ? 1 : 3} tags={tags} />
|
||||
</Labels>
|
||||
{!isMobile && !isPciDevice && detachAction(NIC_ID, true)}
|
||||
</Row>
|
||||
)
|
||||
})
|
||||
|
||||
Alias.displayName = 'Alias'
|
||||
|
||||
Alias.propTypes = {
|
||||
alias: PropTypes.shape({
|
||||
NIC_ID: PropTypes.string,
|
||||
NETWORK: PropTypes.string,
|
||||
IP: PropTypes.string,
|
||||
MAC: PropTypes.string,
|
||||
BRIDGE: PropTypes.string,
|
||||
}),
|
||||
isPciDevice: PropTypes.bool,
|
||||
detachAction: PropTypes.func,
|
||||
}
|
||||
|
||||
export default Alias
|
||||
@@ -33,13 +33,13 @@ import { TabContext } from 'client/components/Tabs/TabProvider'
|
||||
import { Action } from 'client/components/Cards/SelectCard'
|
||||
import { DialogConfirmation } from 'client/components/Dialogs'
|
||||
import MultipleTags from 'client/components/MultipleTags'
|
||||
import Alias from 'client/components/Tabs/Vm/Network/Alias'
|
||||
import SecGroup from 'client/components/Tabs/Vm/Network/SecGroup'
|
||||
|
||||
import { Translate } from 'client/components/HOC'
|
||||
import { T, VM_ACTIONS } from 'client/constants'
|
||||
|
||||
const DATACYSECURITY = 'securitygroup-'
|
||||
const DATACYNETWORK = 'network-'
|
||||
const DATACYALIAS = 'alias-'
|
||||
const DATACY_NETWORK = 'network-'
|
||||
|
||||
const Accordion = styled((props) => (
|
||||
<MAccordion disableGutters elevation={0} square {...props} />
|
||||
@@ -133,24 +133,24 @@ const NetworkItem = ({ nic = {}, actions }) => {
|
||||
const tags = [
|
||||
{
|
||||
text: IP,
|
||||
dataCy: `${DATACYNETWORK}ip`,
|
||||
dataCy: `${DATACY_NETWORK}ip`,
|
||||
},
|
||||
{
|
||||
text: MAC,
|
||||
dataCy: `${DATACYNETWORK}mac`,
|
||||
dataCy: `${DATACY_NETWORK}mac`,
|
||||
},
|
||||
{
|
||||
text: ADDRESS,
|
||||
dataCy: `${DATACYNETWORK}address`,
|
||||
dataCy: `${DATACY_NETWORK}address`,
|
||||
},
|
||||
].filter(({ text } = {}) => Boolean(text))
|
||||
|
||||
return (
|
||||
<>
|
||||
<Accordion data-cy={`${DATACYNETWORK}${NIC_ID}`}>
|
||||
<Accordion data-cy={`${DATACY_NETWORK}${NIC_ID}`}>
|
||||
<Summary {...(hasDetails && { expandIcon: <ExpandIcon /> })}>
|
||||
<Row>
|
||||
<Typography noWrap data-cy={`${DATACYNETWORK}name`}>
|
||||
<Typography noWrap data-cy={`${DATACY_NETWORK}name`}>
|
||||
{`${NIC_ID} | ${NETWORK}`}
|
||||
</Typography>
|
||||
<Labels>
|
||||
@@ -165,108 +165,27 @@ const NetworkItem = ({ nic = {}, actions }) => {
|
||||
</Summary>
|
||||
{hasDetails && (
|
||||
<Details>
|
||||
{ALIAS?.map(({ NIC_ID, NETWORK = '-', BRIDGE, IP, MAC }) => {
|
||||
const tags = [
|
||||
{
|
||||
text: IP,
|
||||
dataCy: `${DATACYALIAS}ip`,
|
||||
},
|
||||
{
|
||||
text: MAC,
|
||||
dataCy: `${DATACYALIAS}mac`,
|
||||
},
|
||||
{
|
||||
text: BRIDGE && `BRIDGE - ${BRIDGE}`,
|
||||
dataCy: `${DATACYALIAS}bridge`,
|
||||
},
|
||||
].filter(({ text } = {}) => Boolean(text))
|
||||
|
||||
return (
|
||||
<Row key={NIC_ID} data-cy={`${DATACYALIAS}${NIC_ID}`}>
|
||||
<Typography
|
||||
noWrap
|
||||
variant="body2"
|
||||
data-cy={`${DATACYALIAS}name`}
|
||||
>
|
||||
<Translate word={T.Alias} />
|
||||
{`${NIC_ID} | ${NETWORK}`}
|
||||
</Typography>
|
||||
<Labels>
|
||||
<MultipleTags
|
||||
clipboard
|
||||
limitTags={isMobile ? 1 : 3}
|
||||
tags={tags}
|
||||
/>
|
||||
</Labels>
|
||||
{!isMobile && !isPciDevice && detachAction(NIC_ID, true)}
|
||||
</Row>
|
||||
)
|
||||
})}
|
||||
{ALIAS?.map((alias) => (
|
||||
<Alias
|
||||
key={alias?.NIC_ID}
|
||||
alias={alias}
|
||||
isPciDevice={isPciDevice}
|
||||
detachAction={detachAction}
|
||||
/>
|
||||
))}
|
||||
{!!SECURITY_GROUPS?.length && (
|
||||
<SecGroups variant="outlined">
|
||||
<Typography variant="body1">
|
||||
<Translate word={T.SecurityGroups} />
|
||||
</Typography>
|
||||
|
||||
{SECURITY_GROUPS?.map(
|
||||
(
|
||||
{
|
||||
ID,
|
||||
SECURITY_GROUP_ID,
|
||||
NAME,
|
||||
PROTOCOL,
|
||||
RULE_TYPE,
|
||||
ICMP_TYPE,
|
||||
RANGE,
|
||||
NETWORK_ID,
|
||||
},
|
||||
idx
|
||||
) => {
|
||||
const tags = [
|
||||
{
|
||||
text: PROTOCOL,
|
||||
dataCy: `${DATACYSECURITY}protocol`,
|
||||
},
|
||||
{
|
||||
text: RULE_TYPE,
|
||||
dataCy: `${DATACYSECURITY}ruletype`,
|
||||
},
|
||||
{
|
||||
text: RANGE,
|
||||
dataCy: `${DATACYSECURITY}range`,
|
||||
},
|
||||
{
|
||||
text: NETWORK_ID,
|
||||
dataCy: `${DATACYSECURITY}networkid`,
|
||||
},
|
||||
{
|
||||
text: ICMP_TYPE,
|
||||
dataCy: `${DATACYSECURITY}icmp_type`,
|
||||
},
|
||||
].filter(({ text } = {}) => Boolean(text))
|
||||
|
||||
return (
|
||||
<Row
|
||||
key={`${idx}-${NAME}`}
|
||||
data-cy={`${DATACYSECURITY}${idx}`}
|
||||
>
|
||||
<Typography
|
||||
noWrap
|
||||
variant="body2"
|
||||
data-cy={`${DATACYSECURITY}name`}
|
||||
>
|
||||
{`${ID} | ${NAME}`}
|
||||
</Typography>
|
||||
<Labels>
|
||||
<MultipleTags
|
||||
limitTags={isMobile ? 2 : 5}
|
||||
tags={tags}
|
||||
/>
|
||||
</Labels>
|
||||
</Row>
|
||||
)
|
||||
}
|
||||
)}
|
||||
{SECURITY_GROUPS?.map((securityGroup, idx) => (
|
||||
<SecGroup
|
||||
key={`${idx}-${securityGroup.NAME}`}
|
||||
index={idx}
|
||||
securityGroup={securityGroup}
|
||||
/>
|
||||
))}
|
||||
</SecGroups>
|
||||
)}
|
||||
</Details>
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/* ------------------------------------------------------------------------- *
|
||||
* Copyright 2002-2021, 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 { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { styled, useMediaQuery } from '@mui/material'
|
||||
import Typography from '@mui/material/Typography'
|
||||
|
||||
import MultipleTags from 'client/components/MultipleTags'
|
||||
|
||||
const DATACY_SECGROUP = 'securitygroup-'
|
||||
|
||||
const Row = styled('div')({
|
||||
display: 'flex',
|
||||
width: '100%',
|
||||
gap: '0.5em',
|
||||
alignItems: 'center',
|
||||
flexWrap: 'nowrap',
|
||||
})
|
||||
|
||||
const Labels = styled('span')({
|
||||
display: 'inline-flex',
|
||||
gap: '0.5em',
|
||||
alignItems: 'center',
|
||||
})
|
||||
|
||||
const SecGroup = memo(({ index, securityGroup }) => {
|
||||
const isMobile = useMediaQuery((theme) => theme.breakpoints.down('md'))
|
||||
|
||||
const { ID, NAME, PROTOCOL, RULE_TYPE, ICMP_TYPE, RANGE, NETWORK_ID } =
|
||||
securityGroup
|
||||
|
||||
const tags = [
|
||||
{
|
||||
text: PROTOCOL,
|
||||
dataCy: `${DATACY_SECGROUP}protocol`,
|
||||
},
|
||||
{
|
||||
text: RULE_TYPE,
|
||||
dataCy: `${DATACY_SECGROUP}ruletype`,
|
||||
},
|
||||
{
|
||||
text: RANGE,
|
||||
dataCy: `${DATACY_SECGROUP}range`,
|
||||
},
|
||||
{
|
||||
text: NETWORK_ID,
|
||||
dataCy: `${DATACY_SECGROUP}networkid`,
|
||||
},
|
||||
{
|
||||
text: ICMP_TYPE,
|
||||
dataCy: `${DATACY_SECGROUP}icmp_type`,
|
||||
},
|
||||
].filter(({ text } = {}) => Boolean(text))
|
||||
|
||||
return (
|
||||
<Row data-cy={`${DATACY_SECGROUP}${index}`}>
|
||||
<Typography noWrap variant="body2" data-cy={`${DATACY_SECGROUP}name`}>
|
||||
{`${ID} | ${NAME}`}
|
||||
</Typography>
|
||||
<Labels>
|
||||
<MultipleTags limitTags={isMobile ? 2 : 5} tags={tags} />
|
||||
</Labels>
|
||||
</Row>
|
||||
)
|
||||
})
|
||||
|
||||
SecGroup.displayName = 'SecGroup'
|
||||
|
||||
SecGroup.propTypes = {
|
||||
index: PropTypes.number,
|
||||
securityGroup: PropTypes.shape({
|
||||
ID: PropTypes.string,
|
||||
SECURITY_GROUP_ID: PropTypes.string,
|
||||
NAME: PropTypes.string,
|
||||
PROTOCOL: PropTypes.string,
|
||||
RULE_TYPE: PropTypes.string,
|
||||
ICMP_TYPE: PropTypes.string,
|
||||
RANGE: PropTypes.string,
|
||||
NETWORK_ID: PropTypes.string,
|
||||
}),
|
||||
}
|
||||
|
||||
export default SecGroup
|
||||
@@ -196,7 +196,7 @@ const CharterAction = memo(() => {
|
||||
}
|
||||
|
||||
const [period, parsedTime] = Object.entries(allPeriods).find(
|
||||
([_, time]) => time >= 1
|
||||
([_, value]) => value >= 1
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
@@ -73,18 +73,16 @@ const Tabs = ({
|
||||
}}
|
||||
{...tabsProps}
|
||||
>
|
||||
{tabs.map(({ value, name, label, error, icon: Icon }, idx) => {
|
||||
return (
|
||||
<MTab
|
||||
key={`tab-${name}`}
|
||||
id={`tab-${name}`}
|
||||
icon={error ? <WarningIcon /> : Icon && <Icon />}
|
||||
value={value ?? idx}
|
||||
label={label ?? name}
|
||||
data-cy={`tab-${name}`}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
{tabs.map(({ value, name, label, error, icon: Icon }, idx) => (
|
||||
<MTab
|
||||
key={`tab-${name}`}
|
||||
id={`tab-${name}`}
|
||||
icon={error ? <WarningIcon /> : Icon && <Icon />}
|
||||
value={value ?? idx}
|
||||
label={label ?? name}
|
||||
data-cy={`tab-${name}`}
|
||||
/>
|
||||
))}
|
||||
</MTabs>
|
||||
),
|
||||
[tabs, tabSelected]
|
||||
|
||||
@@ -50,13 +50,13 @@ const DialogInfo = ({ info, handleClose }) => {
|
||||
scrollButtons="auto"
|
||||
onChange={(_, tab) => setTab(tab)}
|
||||
>
|
||||
{TABS.map(({ name, icon: Icon }, idx) => (
|
||||
{TABS.map(({ name: tabName, icon: Icon }, idx) => (
|
||||
<Tab
|
||||
key={`tab-${name}`}
|
||||
id={`tab-${name}`}
|
||||
key={`tab-${tabName}`}
|
||||
id={`tab-${tabName}`}
|
||||
icon={<Icon />}
|
||||
value={idx}
|
||||
label={String(name).toUpperCase()}
|
||||
label={String(tabName).toUpperCase()}
|
||||
/>
|
||||
))}
|
||||
</Tabs>
|
||||
@@ -70,18 +70,18 @@ const DialogInfo = ({ info, handleClose }) => {
|
||||
{renderTabs}
|
||||
{useMemo(
|
||||
() =>
|
||||
TABS.map(({ name, content: Content }, idx) => (
|
||||
TABS.map(({ name: tabName, content: Content }, idx) => (
|
||||
<Box
|
||||
p={2}
|
||||
height={1}
|
||||
overflow="auto"
|
||||
key={`tab-${name}`}
|
||||
key={`tab-${tabName}`}
|
||||
hidden={tabSelected !== idx}
|
||||
>
|
||||
{Content !== undefined ? (
|
||||
<Content info={info} />
|
||||
) : (
|
||||
<h1>{name}</h1>
|
||||
<h1>{tabName}</h1>
|
||||
)}
|
||||
</Box>
|
||||
)),
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import { WarningCircledOutline as WarningIcon } from 'iconoir-react'
|
||||
import FormWithSchema from 'client/components/Forms/FormWithSchema'
|
||||
import { T } from 'client/constants'
|
||||
|
||||
import { ID, FORM_FIELDS, STEP_FORM_SCHEMA } from './schema'
|
||||
import { ID_FIELD, FORM_FIELDS, STEP_FORM_SCHEMA } from './schema'
|
||||
|
||||
export const STEP_ID = 'tiers'
|
||||
|
||||
@@ -78,7 +78,7 @@ const Tiers = ({ tiers, vmTemplates }) => {
|
||||
<div key={id} hidden={tabSelected !== id}>
|
||||
<FormWithSchema
|
||||
cy="deploy-tiers-id"
|
||||
fields={[ID]}
|
||||
fields={[ID_FIELD]}
|
||||
id={`${STEP_ID}[${index}]`}
|
||||
/>
|
||||
<FormWithSchema
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import { v4 as uuidv4 } from 'uuid'
|
||||
import { INPUT_TYPES } from 'client/constants'
|
||||
import { getValidationFromFields } from 'client/utils'
|
||||
|
||||
export const ID = {
|
||||
export const ID_FIELD = {
|
||||
name: 'id',
|
||||
label: 'ID',
|
||||
type: INPUT_TYPES.TEXT,
|
||||
@@ -167,7 +167,7 @@ export const STEP_FORM_SCHEMA = ({ tiers, vmTemplates }) => {
|
||||
.array(
|
||||
yup.lazy((value) =>
|
||||
yup.object({
|
||||
...getValidationFromFields([ID]),
|
||||
...getValidationFromFields([ID_FIELD]),
|
||||
user_inputs_values: schemasUI[value?.id],
|
||||
})
|
||||
)
|
||||
|
||||
@@ -114,9 +114,9 @@ const ResponseForm = ({
|
||||
/>
|
||||
))
|
||||
}
|
||||
renderInput={(params) => (
|
||||
renderInput={(inputProps) => (
|
||||
<TextField
|
||||
{...params}
|
||||
{...inputProps}
|
||||
fullWidth
|
||||
label={paramName}
|
||||
color="secondary"
|
||||
|
||||
@@ -25,13 +25,12 @@ import { isDevelopment } from 'client/utils'
|
||||
|
||||
function InstantiateVmTemplate() {
|
||||
const history = useHistory()
|
||||
const { state: template = {} } = useLocation()
|
||||
const { ID: templateId } = template ?? {}
|
||||
const { state: { ID: templateId } = {} } = useLocation()
|
||||
|
||||
const { enqueueInfo } = useGeneralApi()
|
||||
const { instantiate } = useVmTemplateApi()
|
||||
|
||||
const onSubmit = async ([templateSelected = template, templates]) => {
|
||||
const onSubmit = async ([templateSelected, templates]) => {
|
||||
try {
|
||||
const { ID, NAME } = templateSelected
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ const { name, actions, reducer } = createSlice({
|
||||
(_, { error }) => ({ ...initial(), error })
|
||||
)
|
||||
.addMatcher(
|
||||
({ type }) => {
|
||||
return [
|
||||
({ type }) =>
|
||||
[
|
||||
changeFilter.type,
|
||||
login.fulfilled.type,
|
||||
getUser.fulfilled.type,
|
||||
@@ -76,8 +76,7 @@ const { name, actions, reducer } = createSlice({
|
||||
getSunstoneViews.fulfilled.type,
|
||||
getSunstoneConfig.fulfilled.type,
|
||||
changeView.type,
|
||||
].includes(type)
|
||||
},
|
||||
].includes(type),
|
||||
(state, { payload }) => ({ ...state, ...payload })
|
||||
)
|
||||
.addMatcher(
|
||||
|
||||
@@ -37,23 +37,27 @@ const { name, reducer } = createSlice({
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
/* UI ACTIONS */
|
||||
.addCase(actions.fixMenu, (state, { payload }) => {
|
||||
return { ...state, isFixMenu: !!payload }
|
||||
})
|
||||
.addCase(actions.changeLoading, (state, { payload }) => {
|
||||
return { ...state, isLoading: !!payload }
|
||||
})
|
||||
.addCase(actions.changeTitle, (state, { payload }) => {
|
||||
return { ...state, title: payload }
|
||||
})
|
||||
.addCase(actions.fixMenu, (state, { payload }) => ({
|
||||
...state,
|
||||
isFixMenu: !!payload,
|
||||
}))
|
||||
.addCase(actions.changeLoading, (state, { payload }) => ({
|
||||
...state,
|
||||
isLoading: !!payload,
|
||||
}))
|
||||
.addCase(actions.changeTitle, (state, { payload }) => ({
|
||||
...state,
|
||||
title: payload,
|
||||
}))
|
||||
.addCase(actions.changeAppTitle, (state, { payload }) => {
|
||||
const isBeta = APPS_IN_BETA?.includes(String(payload).toLowerCase())
|
||||
|
||||
return { ...state, appTitle: payload, isBeta }
|
||||
})
|
||||
.addCase(actions.changeZone, (state, { payload }) => {
|
||||
return { ...state, zone: payload }
|
||||
})
|
||||
.addCase(actions.changeZone, (state, { payload }) => ({
|
||||
...state,
|
||||
zone: payload,
|
||||
}))
|
||||
|
||||
/* NOTIFICATION ACTIONS */
|
||||
.addCase(actions.enqueueSnackbar, (state, { payload }) => {
|
||||
|
||||
@@ -17,7 +17,5 @@ import { createAction } from '@reduxjs/toolkit'
|
||||
|
||||
export const updateResourceFromFetch = createAction(
|
||||
'update-resource-from-fetch',
|
||||
({ data, resource }) => {
|
||||
return { payload: { type: resource, data } }
|
||||
}
|
||||
({ data, resource }) => ({ payload: { type: resource, data } })
|
||||
)
|
||||
@@ -46,9 +46,8 @@ export const provisionService = {
|
||||
*
|
||||
* @returns {Promise} TODO
|
||||
*/
|
||||
createProvisionTemplate: () => {
|
||||
return Promise.resolve().then((res) => res?.data?.DOCUMENT ?? {})
|
||||
},
|
||||
createProvisionTemplate: () =>
|
||||
Promise.resolve().then((res) => res?.data?.DOCUMENT ?? {}),
|
||||
|
||||
// --------------------------------------------
|
||||
// PROVISION requests
|
||||
|
||||
@@ -105,13 +105,14 @@ const { name, actions, reducer } = createSlice({
|
||||
type.includes('/detail'))),
|
||||
(state, { payload, type }) => {
|
||||
// TYPE and DATA can be force by payload
|
||||
const name = getNameListFromType(payload?.type ?? type)
|
||||
const listName = getNameListFromType(payload?.type ?? type)
|
||||
|
||||
const newList = updateResourceList(
|
||||
state[name],
|
||||
state[listName],
|
||||
payload?.data ?? payload
|
||||
)
|
||||
|
||||
return { ...state, [name]: newList }
|
||||
return { ...state, [listName]: newList }
|
||||
}
|
||||
)
|
||||
.addMatcher(
|
||||
|
||||
@@ -52,7 +52,8 @@ export const useVmApi = () => {
|
||||
unresched: (id) => unwrapDispatch(actions.unresched({ id })),
|
||||
updateUserTemplate: (id, template, replace) =>
|
||||
unwrapDispatch(actions.updateUserTemplate({ id, template, replace })),
|
||||
rename: (id, name) => unwrapDispatch(actions.rename({ id, name })),
|
||||
rename: (id, newName) =>
|
||||
unwrapDispatch(actions.rename({ id, name: newName })),
|
||||
resize: (id, data) => unwrapDispatch(actions.resize({ id, ...data })),
|
||||
changePermissions: (id, permissions) =>
|
||||
unwrapDispatch(actions.changePermissions({ id, permissions })),
|
||||
|
||||
@@ -47,7 +47,8 @@ export const useVmTemplateApi = () => {
|
||||
unwrapDispatch(actions.changePermissions({ id, ...data })),
|
||||
changeOwnership: (id, ownership) =>
|
||||
unwrapDispatch(actions.changeOwnership({ id, ownership })),
|
||||
rename: (id, name) => unwrapDispatch(actions.rename({ id, name })),
|
||||
rename: (id, newName) =>
|
||||
unwrapDispatch(actions.rename({ id, name: newName })),
|
||||
lock: (id, data) => unwrapDispatch(actions.lock({ id, ...data })),
|
||||
unlock: (id) => unwrapDispatch(actions.unlock({ id })),
|
||||
}
|
||||
|
||||
@@ -79,13 +79,10 @@ export const getCapacityInfo = ({ TOTAL_MB, USED_MB } = {}) => {
|
||||
* @param {object} oneConfig - One config from redux
|
||||
* @returns {boolean} - Datastore supports to export
|
||||
*/
|
||||
export const isMarketExportSupport = ({ NAME } = {}, oneConfig) => {
|
||||
export const isMarketExportSupport = ({ NAME } = {}, oneConfig) =>
|
||||
// When in doubt, allow the action and let oned return failure
|
||||
return (
|
||||
!NAME ||
|
||||
oneConfig?.DS_MAD_CONF?.some(
|
||||
(dsMad) =>
|
||||
dsMad?.NAME === NAME && dsMad?.MARKETPLACE_ACTIONS?.includes?.('export')
|
||||
)
|
||||
!NAME ||
|
||||
oneConfig?.DS_MAD_CONF?.some(
|
||||
(dsMad) =>
|
||||
dsMad?.NAME === NAME && dsMad?.MARKETPLACE_ACTIONS?.includes?.('export')
|
||||
)
|
||||
}
|
||||
@@ -305,12 +305,11 @@ export const getUserInputString = (userInput) => {
|
||||
* @param {object} userInputs - List of user inputs in string format
|
||||
* @returns {UserInputObject[]} User input object
|
||||
*/
|
||||
export const userInputsToArray = (userInputs = {}) => {
|
||||
return Object.entries(userInputs).map(([name, ui]) => ({
|
||||
export const userInputsToArray = (userInputs = {}) =>
|
||||
Object.entries(userInputs).map(([name, ui]) => ({
|
||||
name,
|
||||
...getUserInputParams(ui),
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of user inputs in format valid to forms.
|
||||
|
||||
@@ -194,9 +194,7 @@ export const getObjectSchemaFromFields = (fields) =>
|
||||
return getSchemaByPath(path, sumSchemas(nextPath, nextIdx))
|
||||
}
|
||||
|
||||
schema = schema.concat(sumSchemas())
|
||||
|
||||
return schema
|
||||
return schema.concat(sumSchemas())
|
||||
}, object())
|
||||
|
||||
/**
|
||||
@@ -265,7 +263,7 @@ export const get = (obj, path, defaultValue = undefined) => {
|
||||
* Set a value of property in object by his path.
|
||||
*
|
||||
* @param {object} obj - Object
|
||||
* @param {string} path - Path of property
|
||||
* @param {string|string[]} path - Path of property
|
||||
* @param {*} value - New value of property
|
||||
* @returns {object} Object with the new property
|
||||
*/
|
||||
@@ -273,20 +271,23 @@ export const set = (obj, path, value) => {
|
||||
if (Object(obj) !== obj) return obj // When obj is not an object
|
||||
|
||||
// If not yet an array, get the keys from the string-path
|
||||
if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []
|
||||
const arrayPath = !Array.isArray(path)
|
||||
? path.toString().match(/[^.[\]]+/g) || []
|
||||
: path
|
||||
|
||||
const result = path.slice(0, -1).reduce((res, key, idx) => {
|
||||
const result = arrayPath.slice(0, -1).reduce((res, key, idx) => {
|
||||
if (Object(res[key]) === res[key]) return res[key]
|
||||
|
||||
// If the next key is array-index,
|
||||
// then assign a new array object or new object
|
||||
res[key] = Math.abs(path[idx + 1]) >> 0 === +path[idx + 1] ? [] : {}
|
||||
res[key] =
|
||||
Math.abs(arrayPath[idx + 1]) >> 0 === +arrayPath[idx + 1] ? [] : {}
|
||||
|
||||
return res[key]
|
||||
}, obj)
|
||||
|
||||
// Assign the value to the last key
|
||||
result[path.at(-1)] = value
|
||||
result[arrayPath.at(-1)] = value
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -345,12 +346,12 @@ export const cleanEmptyObject = (obj) => {
|
||||
})
|
||||
|
||||
return entries?.length > 0
|
||||
? entries.reduce((cleanedObject, [key, value]) => {
|
||||
// `value == null` checks against undefined and null
|
||||
return value == null
|
||||
? cleanedObject
|
||||
: { ...cleanedObject, [key]: value }
|
||||
}, {})
|
||||
? entries.reduce(
|
||||
(cleanedObject, [key, value]) =>
|
||||
// `value == null` checks against undefined and null
|
||||
value == null ? cleanedObject : { ...cleanedObject, [key]: value },
|
||||
{}
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,10 @@ export const emptyTarget = (val) => (Array.isArray(val) ? [] : {})
|
||||
* @param {MergeOptions} options - Merge options
|
||||
* @returns {*} Returns the value as clone if required
|
||||
*/
|
||||
export const cloneIfNecessary = (value, options) => {
|
||||
return options?.clone === true && isMergeableObject(value)
|
||||
export const cloneIfNecessary = (value, options) =>
|
||||
options?.clone === true && isMergeableObject(value)
|
||||
? deepmerge(emptyTarget(value), value, options)
|
||||
: value
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array} target - Target
|
||||
|
||||
@@ -92,19 +92,17 @@ const parseTiers = (roles, networking) =>
|
||||
)
|
||||
|
||||
const scheduled = scheduledPolicies.map(
|
||||
({ id, recurrence, start_time: time, ...rest }) => {
|
||||
return {
|
||||
...JSON.parse(JSON.stringify(rest)),
|
||||
...(recurrence && {
|
||||
time_format: 'recurrence',
|
||||
time_expression: recurrence,
|
||||
}),
|
||||
...(time && {
|
||||
time_format: 'start_time',
|
||||
time_expression: time,
|
||||
}),
|
||||
}
|
||||
}
|
||||
({ id, recurrence, start_time: time, ...rest }) => ({
|
||||
...JSON.parse(JSON.stringify(rest)),
|
||||
...(recurrence && {
|
||||
time_format: 'recurrence',
|
||||
time_expression: recurrence,
|
||||
}),
|
||||
...(time && {
|
||||
time_format: 'start_time',
|
||||
time_expression: time,
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
return [
|
||||
|
||||
@@ -52,8 +52,8 @@ export const requestConfig = (data, command) => {
|
||||
|
||||
/* Spread 'from' values in current params */
|
||||
const mappedParams = Object.entries(params)?.reduce(
|
||||
(params, [paraName, { from }]) => ({
|
||||
...params,
|
||||
(result, [paraName, { from }]) => ({
|
||||
...result,
|
||||
[paraName]: { from, value: data[paraName] },
|
||||
}),
|
||||
{}
|
||||
|
||||
@@ -356,17 +356,17 @@ export const mapUserInputs = (userInputs = {}) =>
|
||||
/**
|
||||
* Converts a list of values to usable options.
|
||||
*
|
||||
* @param {any[]} array - List of option values
|
||||
* @param {any[]} list - List of option values
|
||||
* @param {object} [options] - Options to conversion
|
||||
* @param {boolean|string} [options.addEmpty] - If `true`, add an empty option
|
||||
* @param {function(any):any} [options.getText] - Function to get the text option
|
||||
* @param {function(any):any} [options.getValue] - Function to get the value option
|
||||
* @returns {SelectOption} Options
|
||||
*/
|
||||
export const arrayToOptions = (array = [], options = {}) => {
|
||||
export const arrayToOptions = (list = [], options = {}) => {
|
||||
const { addEmpty = true, getText = (o) => o, getValue = (o) => o } = options
|
||||
|
||||
const values = array.map((item) => ({
|
||||
const values = list.map((item) => ({
|
||||
text: getText(item),
|
||||
value: getValue(item),
|
||||
}))
|
||||
@@ -440,8 +440,8 @@ export const createForm =
|
||||
const schemaCallback = typeof schema === 'function' ? schema(props) : schema
|
||||
const fieldsCallback = typeof fields === 'function' ? fields(props) : fields
|
||||
|
||||
const defaultTransformInitialValue = (values, schema) =>
|
||||
schema.cast(values, { stripUnknown: true })
|
||||
const defaultTransformInitialValue = (values) =>
|
||||
schemaCallback.cast(values, { stripUnknown: true })
|
||||
|
||||
const { transformInitialValue = defaultTransformInitialValue } = extraParams
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ const getIV = () => iv
|
||||
const getUser = () => user
|
||||
|
||||
/**
|
||||
* Get user password openebula.
|
||||
* Get user password opennebula.
|
||||
*
|
||||
* @returns {string} get password user opennebula
|
||||
*/
|
||||
|
||||
@@ -250,16 +250,20 @@ const addOptionalCreateCommand = () => {
|
||||
* @returns {string} paths
|
||||
*/
|
||||
const findRecursiveFolder = (path = '', finder = '', rtn = false) => {
|
||||
let search = rtn
|
||||
|
||||
if (path && finder) {
|
||||
try {
|
||||
const dirs = readdirSync(path)
|
||||
|
||||
dirs.forEach((dir) => {
|
||||
const name = `${path}/${dir}`
|
||||
|
||||
if (statSync(name).isDirectory()) {
|
||||
if (basename(name) === finder) {
|
||||
rtn = name
|
||||
search = name
|
||||
} else {
|
||||
rtn = findRecursiveFolder(name, finder, rtn)
|
||||
search = findRecursiveFolder(name, finder, search)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -268,7 +272,7 @@ const findRecursiveFolder = (path = '', finder = '', rtn = false) => {
|
||||
}
|
||||
}
|
||||
|
||||
return rtn
|
||||
return search
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,9 +33,7 @@ const getSession = (username = '', token = '') => {
|
||||
global.users[username].tokens
|
||||
) {
|
||||
const session = global.users[username].tokens.find(
|
||||
(curr = {}, index = 0) => {
|
||||
return curr.token && curr.token === token
|
||||
}
|
||||
(curr = {}, index = 0) => curr.token && curr.token === token
|
||||
)
|
||||
|
||||
return session
|
||||
|
||||
@@ -102,7 +102,7 @@ router.all(
|
||||
/**
|
||||
* Instance of connection to opennebula.
|
||||
*
|
||||
* @param {string} user - opennegula user
|
||||
* @param {string} user - opennebula user
|
||||
* @param {string} password - opennebula pass
|
||||
* @returns {Function} opennebula executer calls to XMLRPC
|
||||
*/
|
||||
|
||||
@@ -512,8 +512,10 @@ const consoleParseToString = (stringConsole = '', excludeRegexs = []) => {
|
||||
const rtn = []
|
||||
if (stringConsole) {
|
||||
const lines = stringConsole.split(regexLine)
|
||||
|
||||
lines.forEach((line) => {
|
||||
let pass = true
|
||||
|
||||
if (Array.isArray(excludeRegexs)) {
|
||||
excludeRegexs.forEach((rex) => {
|
||||
if (rex.test(line)) {
|
||||
@@ -521,12 +523,14 @@ const consoleParseToString = (stringConsole = '', excludeRegexs = []) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
line = line
|
||||
|
||||
const cleanLine = line
|
||||
.replace(regexRemoveBlanks, ' ')
|
||||
.replace(regexANSIColor, '')
|
||||
.trim()
|
||||
if (line && pass) {
|
||||
rtn.push(line)
|
||||
|
||||
if (cleanLine && pass) {
|
||||
rtn.push(cleanLine)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -554,13 +558,11 @@ const consoleParseToJSON = (arrayConsole = [], regexHeader = '') => {
|
||||
if (row && i > 0) {
|
||||
const explodeRow = CSVtoArray(row)
|
||||
rtn.push(
|
||||
explodeRow.map((value, index) => {
|
||||
return {
|
||||
[header[index]]: stringWrappedBrakets.test(value)
|
||||
? CSVtoArray(value.replace(brakets, ''))
|
||||
: value,
|
||||
}
|
||||
})
|
||||
explodeRow.map((value, index) => ({
|
||||
[header[index]]: stringWrappedBrakets.test(value)
|
||||
? CSVtoArray(value.replace(brakets, ''))
|
||||
: value,
|
||||
}))
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -750,9 +750,9 @@ const getRequestFiles = (params = {}) => {
|
||||
params.constructor === Object
|
||||
) {
|
||||
const arrayParams = Object.keys(params)
|
||||
const fileParams = arrayParams.filter((key = '') => {
|
||||
return key && params[key] && params[key].from === 'files'
|
||||
})
|
||||
const fileParams = arrayParams.filter(
|
||||
(key = '') => key && params[key] && params[key].from === 'files'
|
||||
)
|
||||
|
||||
return fileParams
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user