Skip to content

Commit

Permalink
Refactor ApplicationForm
Browse files Browse the repository at this point in the history
Followup konveyor#1404 to update the way tags are updated to an existing
application.  Tags that are from an analysis need to be included with
the update payload or they will be removed.  This is different behavior
from archetype or assessment tags.  No updates to an application can
remove archetype or assessment tags.

Summary of changes and refactoring:
  - As form values, keep the tags using just the tag name as a string
  - Moved all data access/mutation code to hook `useApplicationFormData()`
    to logically divide concerns (data access v. UI handling)
  - Tags dropdown will only display/edit the application's "Manual tags"
  - `onSubmit()`'s payload building simplified using partially curried
    helper functions
  - Migrate to use `ItemsSelect` for handling the Tags

Update `useUpdateApplicationMutation()` to provide the mutation's
payload to the `onSuccess()` function.  This allows the `onSuccess()`
function to toast a message with the application's name.

Add utility functions to `model-utils.tsx`:
  - convert objects that look like `Ref` object into exactly a `Ref` object:
    - toRef()
    - toRefs()

  - Match a set of items that look like `Ref` objects against a (set of)
    values and the matching matches as exactly `Ref` objects:
    items into exactly `Ref` objects:
    - matchItemsToRef()
    - matchItemsToRefs()

Signed-off-by: Scott J Dickerson <sdickers@redhat.com>
  • Loading branch information
sjd78 committed Sep 28, 2023
1 parent 14e1a8e commit d8d5cb8
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 151 deletions.
Loading

0 comments on commit d8d5cb8

Please sign in to comment.