Skip to content

Commit

Permalink
Merge pull request #1268 from yaacov/save-ints
Browse files Browse the repository at this point in the history
🐞 [UI] max_vm_inflight parameter is not setting
  • Loading branch information
yaacov authored Jul 15, 2024
2 parents d854c84 + cd82e94 commit 3373c37
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { EditModal, ModalInputComponentType } from 'src/modules/Providers/modals';
import { defaultOnConfirmWithIntValue } from 'src/modules/Providers/modals/EditModal/utils/defaultOnConfirm';
import { useForkliftTranslation } from 'src/utils/i18n';

import { ForkliftControllerModel } from '@kubev2v/types';
Expand Down Expand Up @@ -40,6 +41,7 @@ export const EditMaxVMInFlightModal: React.FC<EditSettingsModalProps> = (props)
'Please enter the maximum number of concurrent VM migrations, if empty default value will be used.',
)}
InputComponent={MaxVMInFlightNumberInput}
onConfirmHook={defaultOnConfirmWithIntValue}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { EditModal, ModalInputComponentType } from 'src/modules/Providers/modals';
import { defaultOnConfirmWithIntValue } from 'src/modules/Providers/modals/EditModal/utils/defaultOnConfirm';
import { useForkliftTranslation } from 'src/utils/i18n';

import { ForkliftControllerModel } from '@kubev2v/types';
Expand Down Expand Up @@ -43,6 +44,7 @@ export const EditPreCopyIntervalModal: React.FC<EditSettingsModalProps> = (props
'Please enter the interval in minutes for precopy, if empty default value will be used.',
)}
InputComponent={PrecopyIntervalSelect}
onConfirmHook={defaultOnConfirmWithIntValue}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { EditModal, ModalInputComponentType } from 'src/modules/Providers/modals';
import { defaultOnConfirmWithIntValue } from 'src/modules/Providers/modals/EditModal/utils/defaultOnConfirm';
import { useForkliftTranslation } from 'src/utils/i18n';

import { ForkliftControllerModel } from '@kubev2v/types';
Expand Down Expand Up @@ -43,6 +44,7 @@ export const EditSnapshotPoolingIntervalModal: React.FC<EditSettingsModalProps>
'Please enter the interval in seconds for snapshot pooling, if empty default value will be used.',
)}
InputComponent={SnapshotPoolingIntervalSelect}
onConfirmHook={defaultOnConfirmWithIntValue}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { getValueByJsonPath, jsonPathToPatch } from 'src/modules/Providers/utils';

import { k8sPatch } from '@openshift-console/dynamic-plugin-sdk';
import { k8sPatch, K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk';

/**
* Patches a Kubernetes resource with a new value.
*/
export const defaultOnConfirm = async ({ resource, jsonPath, model, newValue: value }) => {
const op = getValueByJsonPath(resource, jsonPath) ? 'replace' : 'add';

await k8sPatch({
return await k8sPatch<K8sResourceCommon>({
model: model,
resource: resource,
data: [
Expand All @@ -17,3 +20,14 @@ export const defaultOnConfirm = async ({ resource, jsonPath, model, newValue: va
],
});
};

/**
* Wraps the defaultOnConfirm method to convert the newValue from string to int before patching.
*/
export const defaultOnConfirmWithIntValue = async ({ resource, jsonPath, model, newValue }) => {
// Convert the newValue from string to int
const intValue = parseInt(newValue.toString(), 10);

// Call the original method with the converted value
return await defaultOnConfirm({ resource, jsonPath, model, newValue: intValue });
};

0 comments on commit 3373c37

Please sign in to comment.