[AUTOWORK-206] Convert automation actions to an STI table like conditions - #25159
oliverguenther wants to merge 3 commits into
Conversation
b3103fc to
af72a75
Compare
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
375f43b to
93c2087
Compare
Generated by 🚫 Danger |
93c2087 to
d303be4
Compare
|
Caution The provided work package version does not match the core version Details:
Please make sure that:
|
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
d303be4 to
217c5ee
Compare
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
217c5ee to
c961300
Compare
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
dfriquet
left a comment
There was a problem hiding this comment.
I'm still working through this PR (quite dense, honestly), but here are my first UI findings.
| errors.add(:actions, :empty) if model.actions.empty? | ||
| model.actions.each { |action| action.validate(errors) } | ||
| live_actions = model.actions.reject(&:marked_for_destruction?) | ||
| errors.add(:actions, :empty) if live_actions.empty? |
There was a problem hiding this comment.
I18n::MissingTranslationData in Automations#update
Showing /home/dev/openproject/app/views/automations/edit.html.erb where line #45 raised:
Translation missing. Options considered were:
- en.activerecord.attributes.automation.actions
- en.attributes.actions
- en.activerecord.models.actions
| def write_raw_values(new_values) | ||
| self.options = options.is_a?(Hash) ? options.merge("values" => Array(new_values)) : { "values" => Array(new_values) } | ||
| end |
There was a problem hiding this comment.
I’ve got mixed feelings about this method.
In the first place, it could make good use of store_attribute:
| def write_raw_values(new_values) | |
| self.options = options.is_a?(Hash) ? options.merge("values" => Array(new_values)) : { "values" => Array(new_values) } | |
| end | |
| def write_raw_values(new_values) | |
| write_store_attribute(:options, :values, Array(new_values)) | |
| end |
As it is only expected to be called by subclasses, it should be protected. I even wonder if the subclasses should be allowed to call write_store_attribute themselves, and remove this method altogether.
| automation.actions.reject! { |a| a.key == key } | ||
| new_action = template.dup | ||
| new_action.values = values | ||
| automation.actions << new_action |
There was a problem hiding this comment.
When an automation is edited, a rejected update still persists newly added actions.
automation.actions << new_action inserts immediately on a persisted parent, but contract.validate runs afterwards with no transaction. So the new action is written to the DB whereas the the update is not successful because of a too long name for example.
| @@ -28,7 +28,7 @@ See COPYRIGHT and LICENSE files for more details. | |||
| ++#%> | |||
|
|
|||
| <% active_section_keys = @automation.actions.map(&:key) %> | |||
There was a problem hiding this comment.
actions does not exclude those marked for deletion, so on re-render after a validation error they come back as active 🧟
There was a problem hiding this comment.
This index breaks when an automation configures an action on a custom field and that same custom field is deleted afterwards.
Replaces actions which were inline YAML references with an STI table to match functionality of conditions, and add stronger type checking, allowing more flexibility for future automations work
https://community.openproject.org/work_packages/AUTOWORK-206