feat: wire feature flag checks into web Sidebar and upgrade mobile flag client
This commit is contained in:
parent
5842ff1b22
commit
304d2ae865
@ -28,6 +28,11 @@ export const featureFlagClient = createFeatureFlagClient({
|
||||
productId: PRODUCT_ID,
|
||||
platform: 'mobile',
|
||||
pollIntervalMs: 5 * 60 * 1000,
|
||||
getAccessToken,
|
||||
storage: {
|
||||
getItem: (key: string) => mmkvStorage.getItem(key),
|
||||
setItem: (key: string, value: string) => mmkvStorage.setItem(key, value),
|
||||
},
|
||||
});
|
||||
|
||||
export const killSwitchClient = createKillSwitchClient({
|
||||
@ -75,6 +80,13 @@ export function isFeatureEnabled(key: string): boolean {
|
||||
return featureFlagClient.isEnabled(key);
|
||||
}
|
||||
|
||||
export function getFeatureValue<T = boolean | string | number | Record<string, unknown>>(
|
||||
key: string,
|
||||
defaultValue: T,
|
||||
): T {
|
||||
return featureFlagClient.getValue(key, defaultValue);
|
||||
}
|
||||
|
||||
export async function checkKillSwitch(): Promise<{ disabled: boolean; message: string | null }> {
|
||||
return killSwitchClient.check();
|
||||
}
|
||||
|
||||
@ -4,11 +4,12 @@ import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { House, Search, Settings, Sparkles, FolderKanban, ShieldCheck } from "lucide-react";
|
||||
import { PRODUCT_NAME } from "@/lib/product-config";
|
||||
import { isFeatureEnabled } from "@/lib/feature-flags";
|
||||
|
||||
const navItems = [
|
||||
const navItems: { href: string; label: string; icon: typeof House; flag?: string }[] = [
|
||||
{ href: "/dashboard", label: "Dashboard", icon: House },
|
||||
{ href: "/workspaces", label: "Workspaces", icon: FolderKanban },
|
||||
{ href: "/reviews", label: "Reviews", icon: ShieldCheck },
|
||||
{ href: "/reviews", label: "Reviews", icon: ShieldCheck, flag: "mcp_tools_enabled" },
|
||||
{ href: "/search", label: "Search", icon: Search },
|
||||
{ href: "/settings", label: "Settings", icon: Settings },
|
||||
];
|
||||
@ -33,7 +34,7 @@ export function Sidebar() {
|
||||
</div>
|
||||
|
||||
<nav aria-label="Primary navigation" style={{ display: "grid", gap: "var(--nl-space-2)" }}>
|
||||
{navItems.map((item) => {
|
||||
{navItems.filter((item) => !item.flag || isFeatureEnabled(item.flag)).map((item) => {
|
||||
const Icon = item.icon;
|
||||
const active = pathname === item.href || pathname.startsWith(`${item.href}/`);
|
||||
return (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user