Skip to content

Commit

Permalink
Merge pull request #1105 from near/fix/sidebar-query-flag
Browse files Browse the repository at this point in the history
Fix ?sidebar=true test flag
  • Loading branch information
calebjacob committed Apr 8, 2024
2 parents c91f2bb + dad777d commit 3d8cfd6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/sidebar-navigation/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';

import { sidebarLayoutEnabled as sidebarLayoutFeatureFlagEnabled } from '@/utils/config';

export function useSidebarLayoutEnabled() {
const router = useRouter();
const sidebarLayoutTestOverrideEnabled = router.query.sidebar === 'true';
const [sidebarLayoutTestOverrideEnabled, setSidebarLayoutTestOverrideEnabled] = useState(false);
const sidebarLayoutEnabled = sidebarLayoutTestOverrideEnabled || sidebarLayoutFeatureFlagEnabled;

useEffect(() => {
/*
We only evaluate this once on page load so that we keep it enabled until they close
their browser tab.
*/

setSidebarLayoutTestOverrideEnabled(router.query.sidebar === 'true');

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

/*
The sidebarLayoutTestOverrideEnabled logic is only needed for short term testing.
Add "?sidebar=true" to any URL to temporarily enable the sidebar layout.
Expand Down

0 comments on commit 3d8cfd6

Please sign in to comment.