1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-04 11:17:02 +02:00
unleash.unleash/frontend/src
Thomas Heartman 8ade5b5dbb
feat: add tab switcher for change to json diff view in CR (#10179)
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"
/>
2025-06-30 11:04:44 +02:00
..
__mocks__
assets fix: appropriately size case icon for non-editing constraints (#9869) 2025-04-30 08:37:16 +00:00
component feat: add tab switcher for change to json diff view in CR (#10179) 2025-06-30 11:04:44 +02:00
constants delete legacy constraint accordion (#10110) 2025-06-11 12:22:55 +02:00
contexts feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
hooks Feat: impact metrics fronted (#10182) 2025-06-30 09:48:00 +02:00
interfaces Feat: impact metrics fronted (#10182) 2025-06-30 09:48:00 +02:00
openapi chore(1-3811): use real data for lifecycle trends (#10117) 2025-06-12 13:52:10 +02:00
themes chore(1-3832): clean up flag overview redesign (#10140) 2025-06-13 10:41:08 +00:00
types
utils chore(1-3842): don't reorder constraint properties / make id's non-optional (#10160) 2025-06-19 10:09:38 +02:00
index.tsx feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
setupTests.ts
vite-env.d.ts