Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not remove documentation and execution listeners when template is removed #120

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jarekdanielak
Copy link

Closes #114

Proposed Changes

When removing template from element, documentation and execution listeners (and potentially more non-template properties in the future) are kept.

Screen.Recording.2024-08-28.at.12.39.23.mov

Checklist

To ensure you provided everything we need to look at your PR:

  • Brief textual description of the changes present
  • Visual demo attached
  • Steps to try out present, i.e. using the @bpmn-io/sr tool
  • Related issue linked via Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}

* @param {ModdleElement} sourceBusinessObject
* @param {ModdleElement} targetBusinessObject
*/
_copyNonTemplateProperties(sourceBusinessObject, targetBusinessObject) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great solution, in the appropriate place, I think.

[Q]: This handles both C7 and C8. Is the behavior applicable for C7? If so, the standard way would be to split both implementations, and and move the cloud one to cloud-element-templates.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As C7 and C8 templates work slightly differently I'd be fine to only implement this change for C8.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloud-element-templates actually use the same remove handler.

Should we introduce a place for common code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, element-templates is not the place for zeebe properties.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extracted some common code in a7b14c4

}

if (extensionElements && extensionElements.values) {
const exts = copy.copyProperty(extensionElements, targetBusinessObject, 'extensionElements');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q]: We copy all extension elements here, why don't we copy only the individual values that we want to keep?

[Q2]: Does it make sense to statically configure what we want to keep (in a variable)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't found a way to copy execution listeners with ModdleCopy#copyProperty directly.

Moreover, with isAny checking for either C7 or C8 type, there is one implementation that works for both and doesn't need to be aware of engine version.

Is there a smarter way to copy only execution listeners?

* @param {ModdleElement} sourceBusinessObject
* @param {ModdleElement} targetBusinessObject
*/
_copyNonTemplateProperties(sourceBusinessObject, targetBusinessObject) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As C7 and C8 templates work slightly differently I'd be fine to only implement this change for C8.

@jarekdanielak
Copy link
Author

jarekdanielak commented Sep 10, 2024

@nikku I moved the 2 command handlers shared between C7 and C8 to a common folder.

Is there any reason we shouldn't support C7?

@nikku
Copy link
Member

nikku commented Sep 12, 2024

Is there any reason we shouldn't support C7?

Camunda 7 works slightly differently, and we don't aim to touch (and potentially break) existing Camunda 7 behaviors.

@nikku
Copy link
Member

nikku commented Sep 12, 2024

Will have another look onto this PR shortly.

Copy link
Member

@nikku nikku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea to move shared things outside of element-templates / cloud-element-templates.

However the handler now still mixes both implementations, which I'd like to avoid. Thinking in terms of modularization I'd like to remove the element-templates folder, some day in the future, and all element template related code is gone. Same thing the other way around.

@nikku
Copy link
Member

nikku commented Sep 13, 2024

I'll give this PR another look and sketch the relevant changes :)

@barmac barmac requested a review from nikku September 25, 2024 07:19
@barmac
Copy link
Member

barmac commented Sep 25, 2024

I like the idea to move shared things outside of element-templates / cloud-element-templates.

However the handler now still mixes both implementations, which I'd like to avoid. Thinking in terms of modularization I'd like to remove the element-templates folder, some day in the future, and all element template related code is gone. Same thing the other way around.

I'll move the PR to draft until the change is implemented or we reconsider.

@barmac barmac marked this pull request as draft September 25, 2024 14:55
@bpmn-io-tasks bpmn-io-tasks bot added in progress Currently worked on and removed needs review Review pending labels Sep 25, 2024
@nikku nikku assigned nikku and unassigned jarekdanielak Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Currently worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When a template is removed, documentation and other non-templated properties are gone
3 participants