Skip to content

Conversation

@mandyparson
Copy link
Contributor

Overview

What is the feature?

  1. Users receive feedback when clicking 'yes' on the delete association modal
  2. Page auto refreshes after deletion every time.
  3. When creating an association, users should be redirected back to the /collection-association page with the newest data.
  4. Pagination and its messaging is consistent across collection association forms
  5. Collections that have already been associated to should be disabled when searching for more collections to associate.

What is the Solution?

1 & 2: Created an isDeleting state variable that toggles on and off for user feedback as well as for initiating a page refresh
3: ManageCollectionAssociation page now has a fetch policy of 'network-only'. This eliminates the need to mess around with caches as this data is changed.
4. Now using ControlledPagination
5. Similar with 3, using a 'network-only' fetch policy.

What areas of the application does this impact?

CollectionAssociationForm
ManageCollectionAssociation

Testing

Reproduction steps

  • **Environment for testing: SIT
  • **Collection to test with: any
  1. Go to any published concept that can be associated with a collection and click 'Collection Associations'.
  2. Delete one or a few associations and make sure the delete modal responses to your yes or no clicks. Then make sure the page auto-refreshes with latest data. ie: if you had 6 associations, you should now have 5 without needing to refresh the page.
  3. Go to 'add collection associations'. For search field you can use Entry Title and for the next search field you can use '*'. Click 'Search for Collections' and the button should disable as the table loads.
  4. Once the table loads, make sure any previously associated collections are disabled rows. Also ensure that the pagination/sort keys work.
  5. Click on checkboxes and create associations. You'll want to create more than 20 associations so you can check the pagination in the next step. Page should automatically navigate back to manageCollecitonAssociations page and have auto-updated. ie. if you had 5 associations, you should now have 6 associations.
  6. Make sure the pagination/sortKeys work here as well.
  7. Do steps 2-6 again just to be sure that it is always grabbing the freshest data and not a cached data.

Attachments

N/A

Checklist

  • I have added automated tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings -- created new ticket here: https://bugs.earthdata.nasa.gov/browse/MMT-4095 for 'act' warnings.

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.10%. Comparing base (c9e4b80) to head (20bc113).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1418      +/-   ##
==========================================
- Coverage   98.13%   98.10%   -0.04%     
==========================================
  Files         422      422              
  Lines        6812     6796      -16     
  Branches     1436     1432       -4     
==========================================
- Hits         6685     6667      -18     
- Misses        126      128       +2     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@cgokey cgokey left a comment

Choose a reason for hiding this comment

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

PR looks good to me. Added a couple of minor suggestions if you find the refresh just still isn't working right, as something you can try.


// Handles deleting selected collection
// if no collections selected, returns an error notification
const handleDeleteAssociation = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

May want to surface an error if can't delete -- const handleDeleteAssociation = () => {

Suggested change
const handleDeleteAssociation = () => {
const handleDeleteAssociation = () => {
setIsDeleting(true);
deleteAssociationMutation({
variables: {
conceptId,
associatedConceptIds: collectionConceptIds
}
}).catch((error) => {
// Handle error
console.error('Failed to delete association:', error);
addNotification({
message: 'Failed to delete association',
variant: 'danger'
});
}).finally(() => {
setIsDeleting(false);
});
};```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done in deleteAssociationMutation's onError

setCollectionConceptIds([])

// Gives time for CMR to update data
setTimeout(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

One pattern I found for handling this that could be implemented is below:

Suggested change
setTimeout(() => {
setTimeout(() => {
const pollForChanges = (attempts = 0) => {
  if (attempts > 5) {
    addNotification({
      message: 'Unable to confirm update. Please refresh manually.',
      variant: 'warning'
    })
    return
  }

  refetch().then((result) => {
    if (/* check if data is updated */) {
      // Data updated successfully
    } else {
      setTimeout(() => pollForChanges(attempts + 1), 1000)
    }
  })
}

onCompleted: () => {
  setShowDeleteModal(false)
  addNotification({
    message: 'Collection Associations Deleted Successfully!',
    variant: 'success'
  })
  setCollectionConceptIds([])
  pollForChanges()
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In 10 attempts, the setTimeout appears to work each time. Though I do think we should consider polling for future CMR lag issues.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I think we can probably come up with a generic component too

})
})

describe('when rendering the CollectionAssociationForm', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we remove the test here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't pass props to CollectionAssociationForm anymore.

th:first-child,
td:first-child {
position: sticky;
z-index: 1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

we should ensure this doesn't break other things as this is applied to alot of components if we are going to use this change alternatively we could bump up the Z index for a specific table

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked and didn't see any issues there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked around but was unable to find a situation in which the top-left cell of a table needed to be at a z-index of 1000.

@mandyparson mandyparson merged commit e5f1f44 into main Oct 17, 2025
7 checks passed
@mandyparson mandyparson deleted the MMT-4089 branch October 17, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants