🐛 fix(types.py): add missing error field to component template in build_invalid_menu function

🐛 fix(base.py): add missing error field to FrontendNode class to match the template structure
This commit is contained in:
gustavoschaedler 2023-07-28 16:58:04 +01:00
commit 36772dac99
2 changed files with 4 additions and 1 deletions

View file

@ -305,8 +305,8 @@ def load_files_from_path(path: str):
def build_and_validate_all_files(reader, file_list):
"""Build and validate all files"""
data = reader.build_component_menu_list(file_list)
valid_components = reader.filter_loaded_components(data=data, with_errors=False)
valid_components = reader.filter_loaded_components(data=data, with_errors=False)
invalid_components = reader.filter_loaded_components(data=data, with_errors=True)
return valid_components, invalid_components
@ -359,6 +359,7 @@ def build_invalid_menu(invalid_components):
.get(type(CustomComponent()).__name__)
)
component_template["error"] = component.get("error", "")
component_template.get("template").get("code")["value"] = component_code
invalid_menu[menu_name][component_name] = component_template

View file

@ -53,6 +53,7 @@ class FrontendNode(BaseModel):
output_types: List[str] = []
field_formatters: FieldFormatters = Field(default_factory=FieldFormatters)
beta: bool = False
error: str = ""
# field formatters is an instance attribute but it is not used in the class
# so we need to create a method to get it
@ -85,6 +86,7 @@ class FrontendNode(BaseModel):
"output_types": self.output_types,
"documentation": self.documentation,
"beta": self.beta,
"error": self.error,
},
}