Skip to content

Commit

Permalink
Merge pull request #18060 from ElectronicBlueberry/fix-comments-lost-…
Browse files Browse the repository at this point in the history
…on-import

[24.0] Fix comments lost on import
  • Loading branch information
mvdbeek authored Apr 29, 2024
2 parents 21a57d2 + 69fb6ce commit 984c53e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7705,6 +7705,25 @@ def copy(self, user=None):
for old_step, new_step in zip(self.steps, copied_steps):
old_step.copy_to(new_step, step_mapping, user=user)
copied_workflow.steps = copied_steps

copied_comments = [comment.copy() for comment in self.comments]
steps_by_id = {s.order_index: s for s in copied_workflow.steps}
comments_by_id = {c.order_index: c for c in copied_comments}

# copy comment relationships
for old_comment, new_comment in zip(self.comments, copied_comments):
for step_id in [step.order_index for step in old_comment.child_steps]:
child_step = steps_by_id.get(step_id)
if child_step:
child_step.parent_comment = new_comment

for comment_id in [comment.order_index for comment in old_comment.child_comments]:
child_comment = comments_by_id.get(comment_id)
if child_comment:
child_comment.parent_comment = new_comment

copied_workflow.comments = copied_comments

return copied_workflow

@property
Expand Down Expand Up @@ -8264,6 +8283,17 @@ def from_dict(dict):
comment.data = dict.get("data", None)
return comment

def copy(self):
comment = WorkflowComment()
comment.order_index = self.order_index
comment.type = self.type
comment.position = self.position
comment.size = self.size
comment.color = self.color
comment.data = self.data

return comment


class StoredWorkflowUserShareAssociation(Base, UserShareAssociation):
__tablename__ = "stored_workflow_user_share_connection"
Expand Down

0 comments on commit 984c53e

Please sign in to comment.