mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
fix: hidden envs (#6050)
This commit is contained in:
parent
4a2d1b0364
commit
ce219f1b74
@ -134,7 +134,13 @@ const FeatureOverviewEnvironment = ({
|
||||
|
||||
return (
|
||||
<ConditionallyRender
|
||||
condition={!new Set(globalStore.hiddenEnvironments).has(env.name)}
|
||||
condition={
|
||||
!new Set(
|
||||
Array.isArray(globalStore.hiddenEnvironments)
|
||||
? globalStore.hiddenEnvironments
|
||||
: [],
|
||||
).has(env.name)
|
||||
}
|
||||
show={
|
||||
<StyledFeatureOverviewEnvironment enabled={env.enabled}>
|
||||
<StyledAccordion
|
||||
|
@ -4,15 +4,26 @@ import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||
|
||||
export const useHiddenEnvironments = () => {
|
||||
const { trackEvent } = usePlausibleTracker();
|
||||
|
||||
const { value: globalStore, setValue: setGlobalStore } =
|
||||
useGlobalLocalStorage();
|
||||
const [hiddenEnvironments, setStoredHiddenEnvironments] = useState<
|
||||
Set<string>
|
||||
>(new Set(globalStore.hiddenEnvironments));
|
||||
>(
|
||||
new Set(
|
||||
Array.isArray(globalStore.hiddenEnvironments)
|
||||
? globalStore.hiddenEnvironments
|
||||
: [],
|
||||
),
|
||||
);
|
||||
|
||||
const setHiddenEnvironments = (environment: string) => {
|
||||
setGlobalStore((params) => {
|
||||
const hiddenEnvironments = new Set(params.hiddenEnvironments);
|
||||
const hiddenEnvironments = new Set(
|
||||
Array.isArray(globalStore.hiddenEnvironments)
|
||||
? globalStore.hiddenEnvironments
|
||||
: [],
|
||||
);
|
||||
if (hiddenEnvironments.has(environment)) {
|
||||
hiddenEnvironments.delete(environment);
|
||||
trackEvent('hidden_environment', {
|
||||
@ -29,9 +40,10 @@ export const useHiddenEnvironments = () => {
|
||||
});
|
||||
}
|
||||
setStoredHiddenEnvironments(hiddenEnvironments);
|
||||
|
||||
return {
|
||||
...globalStore,
|
||||
hiddenEnvironments: hiddenEnvironments,
|
||||
hiddenEnvironments: [...hiddenEnvironments],
|
||||
};
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user