mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] devtools: fix/imp env display
This commit first fixes how object prototype are detected so that it won't stop as soon as the constructor name of the object is "Object". This allows displaying every single prototype encountered and closes https://github.com/odoo/owl/issues/1467. This commit also improves how the env of a component is displayed by expanding its chain of prototypes by default while keeping its keys lit as long as it is their first occurence in the chain.
This commit is contained in:
committed by
Géry Debongnie
parent
c105c6da38
commit
8b1dc4c43d
+1
-1
@@ -47,7 +47,7 @@ export class ObjectTreeElement extends Component {
|
|||||||
|
|
||||||
classFor(object) {
|
classFor(object) {
|
||||||
// Prototype items will be dyed down to appear less important
|
// Prototype items will be dyed down to appear less important
|
||||||
if (object.path.some((item) => item?.type === "prototype")) {
|
if (object.path.some((item) => item?.type === "prototype") && !object.keepLit) {
|
||||||
return "attenuate";
|
return "attenuate";
|
||||||
}
|
}
|
||||||
// Same for subscription items which are not present in the keys while the keys will be bold
|
// Same for subscription items which are not present in the keys while the keys will be bold
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export const store = reactive({
|
|||||||
if (IS_FIREFOX) {
|
if (IS_FIREFOX) {
|
||||||
await evalInWindow("window.$0 = $0;", this.activeFrame);
|
await evalInWindow("window.$0 = $0;", this.activeFrame);
|
||||||
}
|
}
|
||||||
const [apps, component] = await evalFunctionInWindow(
|
const [apps, details] = await evalFunctionInWindow(
|
||||||
"getComponentsTree",
|
"getComponentsTree",
|
||||||
fromOld && this.activeComponent
|
fromOld && this.activeComponent
|
||||||
? [this.activeComponent.path, this.apps, this.activeComponent]
|
? [this.activeComponent.path, this.apps, this.activeComponent]
|
||||||
@@ -113,7 +113,8 @@ export const store = reactive({
|
|||||||
if (!fromOld && this.settings.expandByDefault) {
|
if (!fromOld && this.settings.expandByDefault) {
|
||||||
this.apps.forEach((tree) => expandNodes(tree, true));
|
this.apps.forEach((tree) => expandNodes(tree, true));
|
||||||
}
|
}
|
||||||
this.activeComponent = component;
|
keepEnvLit(details);
|
||||||
|
this.activeComponent = details;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Select a component by retrieving its details from the page based on its path
|
// Select a component by retrieving its details from the page based on its path
|
||||||
@@ -150,9 +151,11 @@ export const store = reactive({
|
|||||||
[component.path],
|
[component.path],
|
||||||
this.activeFrame
|
this.activeFrame
|
||||||
);
|
);
|
||||||
this.activeComponent = details;
|
if (!details) {
|
||||||
if (!this.activeComponent) {
|
|
||||||
await this.loadComponentsTree(false);
|
await this.loadComponentsTree(false);
|
||||||
|
} else {
|
||||||
|
keepEnvLit(details);
|
||||||
|
this.activeComponent = details;
|
||||||
}
|
}
|
||||||
if (this.page !== "ComponentsTab") {
|
if (this.page !== "ComponentsTab") {
|
||||||
this.switchTab("ComponentsTab");
|
this.switchTab("ComponentsTab");
|
||||||
@@ -887,6 +890,31 @@ function expandNodes(node, blacklist = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function transforms the env part of the details such that all env keys are not
|
||||||
|
// greyed out in the UI at their first occurence
|
||||||
|
function keepEnvLit(details) {
|
||||||
|
let alreadyMet = new Set();
|
||||||
|
for (let i = 0; i < details.env.children.length; i++) {
|
||||||
|
if (i < details.env.children.length - 1) {
|
||||||
|
alreadyMet.add(details.env.children[i].name);
|
||||||
|
} else {
|
||||||
|
let lastElement = details.env.children[i];
|
||||||
|
while (lastElement.children.at(-1).name === "[[Prototype]]") {
|
||||||
|
for (const [index, child] of lastElement.children.entries()) {
|
||||||
|
if (index < lastElement.children.length - 1) {
|
||||||
|
if (!alreadyMet.has(child.name)) {
|
||||||
|
child.keepLit = true;
|
||||||
|
alreadyMet.add(child.name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lastElement = child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fold the node given in entry and all of its children
|
// Fold the node given in entry and all of its children
|
||||||
function foldNodes(node) {
|
function foldNodes(node) {
|
||||||
node.toggled = false;
|
node.toggled = false;
|
||||||
|
|||||||
@@ -748,6 +748,9 @@
|
|||||||
child.contentType = "object";
|
child.contentType = "object";
|
||||||
child.content = this.serializer.serializeItem(Object.getPrototypeOf(parentObj), true);
|
child.content = this.serializer.serializeItem(Object.getPrototypeOf(parentObj), true);
|
||||||
child.hasChildren = true;
|
child.hasChildren = true;
|
||||||
|
if (!oldTree && type === "env") {
|
||||||
|
child.toggled = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "set entries":
|
case "set entries":
|
||||||
case "map entries":
|
case "map entries":
|
||||||
@@ -890,7 +893,7 @@
|
|||||||
const children = [];
|
const children = [];
|
||||||
depth = depth + 1;
|
depth = depth + 1;
|
||||||
let obj = this.getObjectProperty(path);
|
let obj = this.getObjectProperty(path);
|
||||||
let oldBranch = this.getObjectInOldTree(oldTree, path, objType);
|
let oldBranch = oldTree && this.getObjectInOldTree(oldTree, path, objType);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -905,7 +908,7 @@
|
|||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children[0],
|
oldBranch?.children[0],
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
children.push(mapKey);
|
children.push(mapKey);
|
||||||
@@ -915,7 +918,7 @@
|
|||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children[1],
|
oldBranch?.children[1],
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
children.push(mapValue);
|
children.push(mapValue);
|
||||||
@@ -926,7 +929,7 @@
|
|||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children[0],
|
oldBranch?.children[0],
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
children.push(setValue);
|
children.push(setValue);
|
||||||
@@ -947,7 +950,7 @@
|
|||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children[index],
|
oldBranch?.children[index],
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
if (child) {
|
if (child) {
|
||||||
@@ -962,7 +965,7 @@
|
|||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children[index],
|
oldBranch?.children[index],
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
if (child) {
|
if (child) {
|
||||||
@@ -979,7 +982,7 @@
|
|||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children[index],
|
oldBranch?.children[index],
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
if (entries) {
|
if (entries) {
|
||||||
@@ -993,7 +996,7 @@
|
|||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children[index],
|
oldBranch?.children[index],
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
if (child) {
|
if (child) {
|
||||||
@@ -1028,7 +1031,7 @@
|
|||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children[index],
|
oldBranch?.children[index],
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
if (child) children.push(child);
|
if (child) children.push(child);
|
||||||
@@ -1061,14 +1064,14 @@
|
|||||||
});
|
});
|
||||||
proto = Object.getPrototypeOf(proto);
|
proto = Object.getPrototypeOf(proto);
|
||||||
}
|
}
|
||||||
if (!(obj.constructor.name === "Object")) {
|
if (obj.__proto__) {
|
||||||
prototype = this.serializeObjectChild(
|
prototype = this.serializeObjectChild(
|
||||||
obj,
|
obj,
|
||||||
{ type: "prototype", childIndex: children.length },
|
{ type: "prototype", childIndex: children.length },
|
||||||
depth,
|
depth,
|
||||||
objType,
|
objType,
|
||||||
path,
|
path,
|
||||||
oldBranch.children.at(-1),
|
oldBranch?.children.at(-1),
|
||||||
oldTree
|
oldTree
|
||||||
);
|
);
|
||||||
children.push(prototype);
|
children.push(prototype);
|
||||||
|
|||||||
Reference in New Issue
Block a user