MCPcopy Create free account
hub / github.com/ShipSecAI/studio / AppLayout

Function AppLayout

frontend/src/components/layout/AppLayout.tsx:66–738  ·  view source on GitHub ↗
({ children }: AppLayoutProps)

Source from the content-addressed store, hash-verified

64}
65
66export function AppLayout({ children }: AppLayoutProps) {
67 const isMobile = useIsMobile();
68 const [sidebarOpen, setSidebarOpen] = useState(!isMobile);
69 const [, setIsHovered] = useState(false);
70 const [wasExplicitlyOpened, setWasExplicitlyOpened] = useState(!isMobile);
71 const [settingsOpen, setSettingsOpen] = useState(false);
72 const location = useLocation();
73 const navigate = useNavigate();
74 const roles = useAuthStore((state) => state.roles);
75 const canManageWorkflows = hasAdminRole(roles);
76 const { isAuthenticated } = useAuth();
77 const authProvider = useAuthProvider();
78 const showUserButton = isAuthenticated || authProvider.name === 'clerk';
79 const { theme, startTransition } = useThemeStore();
80 const openCommandPalette = useCommandPaletteStore((state) => state.open);
81
82 // Get git SHA for version display (monorepo - same for frontend and backend)
83 const gitSha = env.VITE_GIT_SHA;
84 // If it's a tag (starts with v), show full tag. Otherwise show first 7 chars of SHA
85 const displayVersion =
86 gitSha && gitSha !== '' && gitSha !== 'unknown'
87 ? gitSha.startsWith('v')
88 ? gitSha
89 : gitSha.slice(0, 7)
90 : 'dev';
91
92 // Auto-collapse sidebar when opening workflow builder, expand for other routes
93 // On mobile, always start collapsed
94 useEffect(() => {
95 if (isMobile) {
96 setSidebarOpen(false);
97 setWasExplicitlyOpened(false);
98 } else {
99 const isWorkflowRoute =
100 (location.pathname.startsWith('/workflows') ||
101 location.pathname.startsWith('/webhooks/')) &&
102 location.pathname !== '/';
103 setSidebarOpen(!isWorkflowRoute);
104 setWasExplicitlyOpened(!isWorkflowRoute);
105 }
106 }, [location.pathname, isMobile]);
107
108 // Close sidebar on mobile when navigating
109 useEffect(() => {
110 if (isMobile) {
111 setSidebarOpen(false);
112 }
113 }, [location.pathname, isMobile]);
114
115 // Set up sidebar close callback for mobile component placement
116 useEffect(() => {
117 if (isMobile) {
118 setMobilePlacementSidebarClose(() => {
119 setSidebarOpen(false);
120 setWasExplicitlyOpened(false);
121 });
122 }
123 return () => {

Callers

nothing calls this directly

Calls 11

hasAdminRoleFunction · 0.90
cnFunction · 0.90
useAuthFunction · 0.85
useAuthProviderFunction · 0.85
getPageActionsFunction · 0.85
removeMethod · 0.80
useIsMobileFunction · 0.70
isActiveFunction · 0.70
addEventListenerMethod · 0.45
removeEventListenerMethod · 0.45

Tested by

no test coverage detected