1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-19 01:17:18 +02:00
unleash.unleash/frontend/src/component/changeRequest/ChangeRequestContext.tsx
Thomas Heartman 73c4c62ea3
chore: track metrics for how many CRs are moved into next state with conflicts (#6109)
Use React's context to track how many CRs are moved into their next
state with conflicts present.

This PR wraps environment change requests and change request overviews
in a change request plausible context that contains a
`willOverwriteStrategyChanges` property. This property is updated by the
diff calculation if there are any conflicts and then read by the
`changeState` function in the `useChangeRequestApi` hook.

As long as at least one of the strategies in the CR contain conflicts,
it will be marked as overwriting changes.
2024-02-05 18:27:11 +09:00

16 lines
471 B
TypeScript

import { createContext, useContext } from 'react';
const defaultContext = {
willOverwriteStrategyChanges: false,
registerWillOverwriteStrategyChanges: () => {},
};
const ChangeRequestPlausibleContext = createContext(defaultContext);
export const ChangeRequestPlausibleProvider =
ChangeRequestPlausibleContext.Provider;
export const useChangeRequestPlausibleContext = (): typeof defaultContext => {
return useContext(ChangeRequestPlausibleContext);
};