Skip to content

feat(rules): implement Rule editing and copying #1620

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Apr 22, 2025

Welcome to Cryostat! 👋

Before contributing, make sure you have:

  • Read the contributing guidelines
  • Linked a relevant issue which this PR resolves
  • Linked any other relevant issues, PR's, or documentation, if any
  • Resolved all conflicts, if any
  • Rebased your branch PR on top of the latest upstream main branch
  • Attached at least one of the following labels to the PR: [chore, ci, docs, feat, fix, test]
  • Signed all commits using a GPG signature

To recreate commits with GPG signature git fetch upstream && git rebase --force --gpg-sign upstream/main


Depends on cryostatio/cryostat#888
Related to #1581

Description of the change:

  1. Adds router location state handling to the Rule creation form, similar to the Custom Recording Form. This allows navigation to the form with pre-filled form content based on the previous app context.
  2. Adds a Rule table action button for Editing existing Rules. This opens the Rule creation form with identical content to the actioned Rule, locks the Rule name field (which is often used to uniquely identify rules) while allowing editing of all other fields, and fires a PATCH request to Cryostat to update the Rule on submission.
  3. Adds a Rule table action button for Copying existing Rules. This opens the Rule creation form with identical content to the actioned Rule, but with _copy appended to the name, and will first a POST request to create a new rule on submission.

Motivation for the change:

Eases the user experience of managing Automated Rules. Currently the only way to create new Rules is to step through the form again and fill in everything, or else download the Rule as JSON and manually edit that and re-upload it. These two new actions allow users to use existing Rules (presets or their own definitions) as a base and adjust them as needed on the fly, or use them as a base for new and more refined Rules without needing to drop into manually editing JSON.

How to manually test:

  1. Check out and build alongside feat(rules): allow patching of all rule fields cryostat#888
  2. Go to Automated Rules
  3. Click the action overflow menu on one of the preset Rules, or create/upload your own.
  4. Click Edit. Verify that you are navigated to the Rule creation form, with the name field locked but all other fields editable. Make some changes, then click Update. Verify that you are navigated back to the Automated Rules view and the table content reflects your changes. If your Rule was previously enabled, verify that your edits are re-applied (ie recordings on matched targets are restarted with new settings).
  5. Click the overflow menu and click Copy. Verify that you are navigated to the Rule creation form, with the name field having _copy appended. Make any other adjustments you'd like, then click the Create button to submit the form. Verify that you are navigated back to the Automated Rules view and the table content reflects your new Rule.
  6. Repeat step 5 but remove _copy from the name. Try to submit the form and verify that an HTTP conflict notification appears and you are not navigated away. Change the rule name to a non-conflicting one and verify that creation now succeeds.
  7. Download a Rule as JSON. Edit the JSON manually, giving it a new unique name and setting enabled: true. Re-upload the Rule and ensure that the table content reflects the new content, but with enabled overridden to false. Ensure manually toggling the Rule to enable it works as expected.

@andrewazores andrewazores added feat New feature or request safe-to-test labels Apr 22, 2025
Copy link

This PR/issue depends on:

@andrewazores andrewazores changed the title feat(rules): implement Edit button for in-place editing of existing Rule feat(rules): implement Rule editing and copying Apr 23, 2025
@andrewazores andrewazores marked this pull request as ready for review April 23, 2025 20:04
@andrewazores andrewazores requested a review from a team April 23, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependent feat New feature or request safe-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant