mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-04 11:17:02 +02:00
Updates the strategy change component used in change requests to have a "tab"-like functionality, where you can switch between "Change" (the rendered strategy) and "View diff" (the JSON diff). This is a tab switcher, so you navigate it with arrow keys if on a keyboard, and I've set selection to follow focus for now. This is my preference as it saves you extra space/enter taps, but we can remove it later if we want. Most of the changes in this PR is wrapping the existing strategy change components/sections in tab panels and tab context providers. Later changes in this project will remove the existing "view diff" hover link in favor of this view. There is some work to do on the design front (in terms of spacing, borders, etc), but this covers the core functionality. The pre-existing strategy change component has been moved into the "LegacyStrategyChange" file with no changes beyond a deprecation comment. The existing tests now test the new component instead with no breakage. (I anticipate breaking when we remove the view diff link, though) Change with strategy variants: <img width="991" alt="image" src="https://github.com/user-attachments/assets/ac28912f-5b08-4a9c-96da-81bfd0b2e68e" /> <img width="1005" alt="image" src="https://github.com/user-attachments/assets/4addaacc-101c-46cb-888f-95dc3b1cac25" /> ## Edge case: deleted strat with no reference strategy There is a case in the code where "reference strategy" can be undefined for a deleted strategy. It is defined as follows: ```ts const referenceStrategy = changeRequestState === 'Applied' ? change.payload.snapshot : currentStrategy; ``` I've decided to still show the "(no changes)" json diff in that setting, so that the tabs actually affect something. I don't know how often this happens, though: probably not anymore unless your CR is _ancient_, as we introduced the snapshot quite a while ago, and `currentStrategy` shouldn't really be undefined here, I should think. Deleted strategy with no reference strategy: Change: <img width="1013" alt="image" src="https://github.com/user-attachments/assets/352eaec9-c0ef-4d5a-b765-11304daf4474" /> Diff: <img width="1029" alt="image" src="https://github.com/user-attachments/assets/e69c81a6-1ef7-47ff-853a-9fb900b26303" /> |
||
---|---|---|
.. | ||
__mocks__ | ||
assets | ||
component | ||
constants | ||
contexts | ||
hooks | ||
interfaces | ||
openapi | ||
themes | ||
types | ||
utils | ||
index.tsx | ||
setupTests.ts | ||
vite-env.d.ts |