Repository navigation
fix(ui): keep tag addresses when editing a tag rule in the form - #1651
Open
AsperforMias wants to merge 1 commit into
Open
AsperforMias wants to merge 1 commit into
AsperforMias wants to merge 1 commit into
Conversation
The tag rule forms only read each tag's match and rebuilt tags from it, on save and when syncing the form to the YAML tab, so addresses were dropped. A tag without match also made the edit form throw while loading, and the tags after it were lost. Map tags to the form and back in one module that keeps both labels and addresses, use it in the edit and add forms, and open address-only tags in the address editor. Tag rule addresses have no exclusion operator, so the address editor offers only "=", and a new tag starts with it. A tag in the address editor no longer saves the label hidden by deleting the last one, since a label match takes precedence over the addresses. Fixes apache#1649
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Please provide a description of this PR:
Fixes #1649.
Editing a tag rule in the form, including turning it off, dropped the
addressesof its tags: the form only read each tag'smatchwhen loading and rebuilt tags fromnameandmatchon save. A tag withoutmatchalso made loading throw, so the tags after it were lost.The form → YAML tab sync of both the edit and the add form rebuilt tags the same way, so switching to the YAML tab also dropped the addresses.
Tags are now mapped to the form and back in
tagFormItem.ts, which keeps both labels and addresses. The edit form (loading, saving and the YAML tab sync) and the add form (loading from the YAML tab, the YAML tab sync and saving) use it. A tag that only has addresses opens in the address editor, and addresses typed with either,or,are split. Tag rule addresses have no exclusion operator, so the address editor offers only=(a new tag used to start with an empty operator, previewed as "不等于"). Deleting the last label switches a tag to the address editor but only hides that label; it is no longer saved there, because a label match takes precedence over the addresses in the tag router.Validation: unit tests for the mapping; the full vitest suite passes, prettier and type-check report nothing for the changed files, and eslint only reports the parse error that
addByFormView.vuealready has on develop. In the mock-mode UI, driven by a headless browser:{"name":"v1","match":[],"addresses":["192.168.1.1:20880","192.168.1.2:20880"]}and the second tag. On develop the page throwsCannot read properties of undefined (reading 'forEach')and saving sends{"name":"v1","match":[]}only.{"name":"gray","match":[],"addresses":["10.0.0.1:20880"]}. Without the change the preview says "地址 不等于" and the tag also carries the deleted empty label,"match":[{"key":"","value":{"":""}}].Edit form of a rule whose tags only have addresses:
To help us figure out who should review this PR, please put an X in all the areas that this PR affects.
Please check any characteristics that apply to this pull request.