fix: properly update dependency map (#9169)

Properly update dependency map
This commit is contained in:
Favour Ohanekwu 2021-11-24 05:43:50 +01:00 committed by GitHub
parent 3f87f4959e
commit c98bbbe6ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 19 deletions

View File

@ -450,21 +450,7 @@ export default class DataTreeEvaluator {
entityName: string,
): DependencyMap {
const dependencies: DependencyMap = {};
if (isAction(entity) || isWidget(entity)) {
const dynamicBindingPathList = getEntityDynamicBindingPathList(entity);
if (dynamicBindingPathList.length) {
dynamicBindingPathList.forEach((dynamicPath) => {
const propertyPath = dynamicPath.key;
const unevalPropValue = _.get(entity, propertyPath);
const { jsSnippets } = getDynamicBindings(unevalPropValue);
const existingDeps =
dependencies[`${entityName}.${propertyPath}`] || [];
dependencies[`${entityName}.${propertyPath}`] = existingDeps.concat(
jsSnippets.filter((jsSnippet) => !!jsSnippet),
);
});
}
}
if (isWidget(entity)) {
// Make property dependant on the default property as any time the default changes
// the property needs to change
@ -518,6 +504,23 @@ export default class DataTreeEvaluator {
});
}
}
if (isAction(entity) || isWidget(entity)) {
const dynamicBindingPathList = getEntityDynamicBindingPathList(entity);
if (dynamicBindingPathList.length) {
dynamicBindingPathList.forEach((dynamicPath) => {
const propertyPath = dynamicPath.key;
const unevalPropValue = _.get(entity, propertyPath);
const { jsSnippets } = getDynamicBindings(unevalPropValue);
const existingDeps =
dependencies[`${entityName}.${propertyPath}`] || [];
dependencies[`${entityName}.${propertyPath}`] = existingDeps.concat(
jsSnippets.filter((jsSnippet) => !!jsSnippet),
);
});
}
}
return dependencies;
}

View File

@ -356,16 +356,16 @@ describe("DataTreeEvaluator", () => {
Text2: ["Text2.text"],
Text3: ["Text3.text"],
Text4: ["Text4.text"],
Table1: [
Table1: expect.arrayContaining([
"Table1.tableData",
"Table1.searchText",
"Table1.selectedRowIndex",
"Table1.selectedRowIndices",
],
Dropdown1: [
]),
Dropdown1: expect.arrayContaining([
"Dropdown1.selectedOptionValue",
"Dropdown1.selectedOptionValueArr",
],
]),
"Text2.text": ["Text1.text"],
"Text3.text": ["Text1.text"],
"Dropdown1.selectedOptionValue": [],