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 (
|
return (
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={!new Set(globalStore.hiddenEnvironments).has(env.name)}
|
condition={
|
||||||
|
!new Set(
|
||||||
|
Array.isArray(globalStore.hiddenEnvironments)
|
||||||
|
? globalStore.hiddenEnvironments
|
||||||
|
: [],
|
||||||
|
).has(env.name)
|
||||||
|
}
|
||||||
show={
|
show={
|
||||||
<StyledFeatureOverviewEnvironment enabled={env.enabled}>
|
<StyledFeatureOverviewEnvironment enabled={env.enabled}>
|
||||||
<StyledAccordion
|
<StyledAccordion
|
||||||
|
@ -4,15 +4,26 @@ import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
|||||||
|
|
||||||
export const useHiddenEnvironments = () => {
|
export const useHiddenEnvironments = () => {
|
||||||
const { trackEvent } = usePlausibleTracker();
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
const { value: globalStore, setValue: setGlobalStore } =
|
const { value: globalStore, setValue: setGlobalStore } =
|
||||||
useGlobalLocalStorage();
|
useGlobalLocalStorage();
|
||||||
const [hiddenEnvironments, setStoredHiddenEnvironments] = useState<
|
const [hiddenEnvironments, setStoredHiddenEnvironments] = useState<
|
||||||
Set<string>
|
Set<string>
|
||||||
>(new Set(globalStore.hiddenEnvironments));
|
>(
|
||||||
|
new Set(
|
||||||
|
Array.isArray(globalStore.hiddenEnvironments)
|
||||||
|
? globalStore.hiddenEnvironments
|
||||||
|
: [],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
const setHiddenEnvironments = (environment: string) => {
|
const setHiddenEnvironments = (environment: string) => {
|
||||||
setGlobalStore((params) => {
|
setGlobalStore((params) => {
|
||||||
const hiddenEnvironments = new Set(params.hiddenEnvironments);
|
const hiddenEnvironments = new Set(
|
||||||
|
Array.isArray(globalStore.hiddenEnvironments)
|
||||||
|
? globalStore.hiddenEnvironments
|
||||||
|
: [],
|
||||||
|
);
|
||||||
if (hiddenEnvironments.has(environment)) {
|
if (hiddenEnvironments.has(environment)) {
|
||||||
hiddenEnvironments.delete(environment);
|
hiddenEnvironments.delete(environment);
|
||||||
trackEvent('hidden_environment', {
|
trackEvent('hidden_environment', {
|
||||||
@ -29,9 +40,10 @@ export const useHiddenEnvironments = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
setStoredHiddenEnvironments(hiddenEnvironments);
|
setStoredHiddenEnvironments(hiddenEnvironments);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...globalStore,
|
...globalStore,
|
||||||
hiddenEnvironments: hiddenEnvironments,
|
hiddenEnvironments: [...hiddenEnvironments],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user