INFRA-4059 | Saqib | Sends default value for existing manifests as well.

This commit is contained in:
Saqib Perwaiz
2025-01-06 17:29:36 +05:30
parent b127f5e362
commit 39c61bce3f
2 changed files with 9 additions and 6 deletions

View File

@@ -218,9 +218,9 @@ const Form = (props: any) => {
const pathKey = breached.limitPath;
if (Object.prototype.hasOwnProperty.call(defaultValues, pathKey)) {
setValueByPath(updatedManifest, path, defaultValues[pathKey]);
setValueByPath(updatedManifest, path, updatedManifest.id, defaultValues[pathKey]);
} else {
setValueByPath(updatedManifest, path);
setValueByPath(updatedManifest, path, updatedManifest.id);
}
});
}

View File

@@ -319,7 +319,7 @@ const getBreachedValues = (
return breaches;
};
function setValueByPath(obj, path, value = undefined): void {
function setValueByPath(obj, path, id, value = undefined): void {
if (!_.isArray(path) || path.length === 0) {
console.error('Invalid path');
return;
@@ -338,8 +338,11 @@ function setValueByPath(obj, path, value = undefined): void {
}
return acc[key];
}, obj);
if (_.isArray(target) && !isNaN(lastKey) && target[parseInt(lastKey, 10)] === undefined) {
if (
_.isArray(target) &&
!isNaN(lastKey) &&
(target[parseInt(lastKey, 10)] === undefined || id === undefined)
) {
if (value === undefined) {
target.splice(parseInt(lastKey, 10), 1);
} else {
@@ -348,7 +351,7 @@ function setValueByPath(obj, path, value = undefined): void {
} else if (
target !== undefined &&
!(_.isArray(target) && isNaN(lastKey)) &&
target[lastKey] === undefined
(target[lastKey] === undefined || id === undefined)
) {
target[lastKey] = value;
} else {