Inventory controllers uses lastCycle, if available, or the first cycle given #2070
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.
Any background context you want to provide?
There were rare cases where the inventory list, inventory map, and pairing pages did not load with a default Cycle.
See the attached issue for more details.
What's this PR do?
Refactors the logic that applies the last Cycle chosen on the inventory list, inventory map, and pairing pages to ensure a Cycle is always chosen.
Before, the logic for applying the last Cycle relied on there existing any "lastCycle" ID (whether or not that ID was for a Cycle known to that Organization). This PR updates that logic to always try to "find" the Cycle associated to the "lastCycle" ID provided before applying it. This validates whether it is, in fact, a Cycle associated to the current organization.
How should this be manually tested?
Go through the steps described in the relevant tickets, and see that a default Cycle is always chosen.
OR alternatively
Manually update the localStorage lastCycle entries to apply a random/invalid Cycle ID to your current org. Then, visit the inventory list, inventory map, or pairing page to see that a default Cycle is chosen regardless of that invalid ID.
What are the relevant tickets?
#2069