INFRA-4059 | Saqib | Sends default value for existing manifests as well.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user