Skip to content

Commit

Permalink
feat: Render 'UNKNOWN' for missing port labels
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Oct 1, 2024
1 parent 2f27089 commit 3edfea6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion capellambse_context_diagrams/collectors/cable_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def _make_port_and_owner(
return box
port = makers.make_port(port_obj.uuid)
if self.diagram._display_port_labels:
port.labels = makers.make_label(port_obj.name)
text = port_obj.name or "UNKNOWN"
port.labels = makers.make_label(text)
box.ports.append(port)
self.ports[port_obj.uuid] = port
return box
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def __init__(
default_render_parameters: dict[str, t.Any],
) -> None:
default_render_parameters = {
"display_port_labels": False,
"display_port_labels": True,
"port_label_position": _elkjs.PORT_LABEL_POSITION.OUTSIDE.name,
} | default_render_parameters
super().__init__(
Expand Down
3 changes: 3 additions & 0 deletions capellambse_context_diagrams/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ class type that stores all previously named classes.
else:
attr_name = "labels"

if child.text == "UNKNOWN":
styleoverrides["text-fill"] = cdiagram.COLORS["red"]

if (
parent.port
and self._diagram._port_label_position
Expand Down

0 comments on commit 3edfea6

Please sign in to comment.