Skip to content

Commit aed0ea4

Browse files
[dev] [Marfuen] mariano/trust-ff (#1756)
* feat(nav): add feature flag to conditionally render Trust tab * feat(nav): add feature flag to conditionally render Trust tab --------- Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
1 parent dd4f86c commit aed0ea4

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

apps/app/src/components/header.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getFeatureFlags } from '@/app/posthog';
2-
import { auth } from '@/utils/auth';
32
import { UserMenu } from '@/components/user-menu';
43
import { getOrganizations } from '@/data/getOrganizations';
4+
import { auth } from '@/utils/auth';
55
import { Skeleton } from '@comp/ui/skeleton';
66
import { headers } from 'next/headers';
77
import { Suspense } from 'react';
@@ -18,14 +18,17 @@ export async function Header({
1818
}) {
1919
const { organizations } = await getOrganizations();
2020

21-
// Check feature flag for questionnaire menu item
21+
// Check feature flags for menu items
2222
const session = await auth.api.getSession({
2323
headers: await headers(),
2424
});
2525
let isQuestionnaireEnabled = false;
26+
let isTrustNdaEnabled = false;
2627
if (session?.user?.id) {
2728
const flags = await getFeatureFlags(session.user.id);
2829
isQuestionnaireEnabled = flags['ai-vendor-questionnaire'] === true;
30+
isTrustNdaEnabled =
31+
flags['is-trust-nda-enabled'] === true || flags['is-trust-nda-enabled'] === 'true';
2932
}
3033

3134
return (
@@ -34,6 +37,7 @@ export async function Header({
3437
organizations={organizations}
3538
organizationId={organizationId}
3639
isQuestionnaireEnabled={isQuestionnaireEnabled}
40+
isTrustNdaEnabled={isTrustNdaEnabled}
3741
/>
3842

3943
{!hideChat && <AssistantButton />}

apps/app/src/components/main-menu.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export function MainMenu({
5252
isCollapsed = false,
5353
onItemClick,
5454
isQuestionnaireEnabled = false,
55+
isTrustNdaEnabled = false,
5556
}: Props) {
5657
const pathname = usePathname();
5758
const [activeStyle, setActiveStyle] = useState({ top: '0px', height: '0px' });
@@ -98,6 +99,7 @@ export function MainMenu({
9899
disabled: false,
99100
icon: ShieldCheck,
100101
protected: false,
102+
hidden: !isTrustNdaEnabled,
101103
},
102104
{
103105
id: 'people',
@@ -340,4 +342,5 @@ type Props = {
340342
isCollapsed?: boolean;
341343
onItemClick?: () => void;
342344
isQuestionnaireEnabled?: boolean;
345+
isTrustNdaEnabled?: boolean;
343346
};

apps/app/src/components/mobile-menu.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ interface MobileMenuProps {
1313
isCollapsed?: boolean;
1414
organizationId?: string;
1515
isQuestionnaireEnabled?: boolean;
16+
isTrustNdaEnabled?: boolean;
1617
}
1718

1819
export function MobileMenu({
1920
organizationId,
2021
organizations,
2122
isQuestionnaireEnabled = false,
23+
isTrustNdaEnabled = false,
2224
}: MobileMenuProps) {
2325
const [isOpen, setOpen] = useState(false);
2426

@@ -55,6 +57,7 @@ export function MobileMenu({
5557
organization={currentOrganization}
5658
onItemClick={handleCloseSheet}
5759
isQuestionnaireEnabled={isQuestionnaireEnabled}
60+
isTrustNdaEnabled={isTrustNdaEnabled}
5861
/>
5962
</div>
6063
</SheetContent>

apps/app/src/components/sidebar.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ export async function Sidebar({
2020
const isCollapsed = collapsed || cookieStore.get('sidebar-collapsed')?.value === 'true';
2121
const { organizations } = await getOrganizations();
2222

23-
// Check feature flag for questionnaire menu item
23+
// Check feature flags for menu items
2424
const session = await auth.api.getSession({
2525
headers: await headers(),
2626
});
2727
let isQuestionnaireEnabled = false;
28+
let isTrustNdaEnabled = false;
2829
if (session?.user?.id) {
2930
const flags = await getFeatureFlags(session.user.id);
3031
isQuestionnaireEnabled = flags['ai-vendor-questionnaire'] === true;
32+
isTrustNdaEnabled =
33+
flags['is-trust-nda-enabled'] === true || flags['is-trust-nda-enabled'] === 'true';
3134
}
3235

3336
return (
@@ -47,6 +50,7 @@ export async function Sidebar({
4750
organization={organization}
4851
isCollapsed={isCollapsed}
4952
isQuestionnaireEnabled={isQuestionnaireEnabled}
53+
isTrustNdaEnabled={isTrustNdaEnabled}
5054
/>
5155
</div>
5256
</div>

0 commit comments

Comments
 (0)