Skip to content

Commit

Permalink
MNT: make sure root page shows. match active run-pages as well (passi…
Browse files Browse the repository at this point in the history
…ve run-pages dne)
  • Loading branch information
tangkong committed Oct 28, 2023
1 parent 6920816 commit 1c55967
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 6 additions & 6 deletions atef/widgets/config/run_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,12 @@ def create_tree_from_file(
prepared_file: Optional[Union[PreparedFile, PreparedProcedureFile]] = None
):
# Is prepared_data really optional?...
root_item = TreeItem(data=data, prepared_data=prepared_file)
root_item = TreeItem()
if isinstance(data, ConfigurationFile):
create_passive_tree_items(data.root, root_item, prepared_file)
create_passive_tree_items(data, root_item, prepared_file)
return root_item
if isinstance(data, ProcedureFile):
create_active_tree_items(data.root, root_item, prepared_file)
create_active_tree_items(data, root_item, prepared_file)
return root_item

raise TypeError("Data was not a passive or active checkout file")
Expand All @@ -435,7 +435,7 @@ def create_passive_tree_items(
# Handle root if necessary
if hasattr(data, 'root'):
# top level, add root item.
item = TreeItem(data, prepared_data=[prepared_data])
item = TreeItem(data.root, prepared_data=[prepared_data.root])
create_passive_tree_items(data.root, item, prepared_data=prepared_data)
parent.addChild(item)

Expand Down Expand Up @@ -480,8 +480,8 @@ def create_active_tree_items(
# Handle root if necessary
if hasattr(data, 'root'):
# top level, add root item.
item = TreeItem(data, prepared_data=[prepared_data])
create_active_tree_items(data.root, item, prepared_file=prepared_data)
item = TreeItem(data.root, prepared_data=[prepared_data.root])
create_active_tree_items(data.root, item, prepared_data=prepared_data)
parent.addChild(item)

# ProcedureGroup
Expand Down
8 changes: 6 additions & 2 deletions atef/widgets/config/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,13 @@ def __init__(
# TODO: when we redo tree construction, this may need looking at
# ugly and dumb as is, but we need to make sure pages match tree items
for new_it in walk_tree_items(self.root_item):
if new_it._data is None: # Skip the empty root
continue
logger.debug(f'attempting to match {type(new_it._data)}')
for old_it in walk_tree_widget_items(self.tree_widget):
# match precisely the edit-mode dataclass
if old_it.widget.data is new_it._data:
# match precisely the edit-mode dataclass, wherever it is
if new_it._data in (old_it.widget.data,
getattr(old_it.widget.data, 'origin', None)):
# assign widget to item
new_it.widget = old_it.widget
break
Expand Down

0 comments on commit 1c55967

Please sign in to comment.