mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-19 01:17:18 +02:00
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.
16 lines
471 B
TypeScript
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);
|
|
};
|