Skip to content

Commit

Permalink
Fix the 2 columns layout that may show hidden properties (#6268)
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H authored Jan 25, 2024
1 parent dd8c040 commit d019571
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions newIDE/app/src/PropertiesEditor/PropertiesMapToSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,32 @@ const uncapitalize = str => {
return str[0].toLowerCase() + str.substr(1);
};

/**
* Return true when the property exists and should be displayed.
*
* @param properties The properties
* @param name The property name
* @param deprecated `true` when only deprecated properties must be displayed
* and `false` when only not deprecated ones must be displayed
*/
const hasVisibleProperty = (
properties: gdMapStringPropertyDescriptor,
name: string,
deprecated: boolean
): boolean => {
if (!properties.has(name)) {
return false;
}
const property = properties.get(name);
return !property.isHidden() && property.isDeprecated() === deprecated;
};

/**
* Transform a MapStringPropertyDescriptor to a schema that can be used in PropertiesEditor.
*
* @param {gdMapStringPropertyDescriptor} properties The properties to use
* @param {*} getProperties The function called to read again the properties
* @param {*} onUpdateProperty The function called to update a property of an object
* @param properties The properties to use
* @param getProperties The function called to read again the properties
* @param onUpdateProperty The function called to update a property of an object
*/
const propertiesMapToSchema = (
properties: gdMapStringPropertyDescriptor,
Expand Down Expand Up @@ -288,7 +308,7 @@ const propertiesMapToSchema = (
name.replace(keyword, otherKeyword)
);
for (const rowPropertyName of rowAllPropertyNames) {
if (properties.has(rowPropertyName)) {
if (hasVisibleProperty(properties, rowPropertyName, deprecated)) {
rowPropertyNames.push(rowPropertyName);
}
}
Expand All @@ -299,7 +319,7 @@ const propertiesMapToSchema = (
name.replace(uncapitalizeKeyword, uncapitalize(otherKeyword))
);
for (const rowPropertyName of rowAllPropertyNames) {
if (properties.has(rowPropertyName)) {
if (hasVisibleProperty(properties, rowPropertyName, deprecated)) {
rowPropertyNames.push(rowPropertyName);
}
}
Expand Down

0 comments on commit d019571

Please sign in to comment.