diff --git a/app/(main)/_context/user.tsx b/app/(main)/_context/user.tsx index 1285b51d..c5f6997f 100644 --- a/app/(main)/_context/user.tsx +++ b/app/(main)/_context/user.tsx @@ -28,7 +28,7 @@ export function UserProvider({ children }: { children: React.ReactNode }) { const isClient = use(IsClientContext); return ( - {children} - + ); } diff --git a/app/(main)/instance/layout.tsx b/app/(main)/instance/layout.tsx index 7064822d..183ff882 100644 --- a/app/(main)/instance/layout.tsx +++ b/app/(main)/instance/layout.tsx @@ -77,7 +77,7 @@ function InstanceLayoutContent({ children }: { children: React.ReactNode }) { Error - {isError?.message || 'Instance not found.'} + Instance not found or failed to load. @@ -268,17 +268,11 @@ const TABS = [ { value: 'configuration', label: 'Configuration', icon: Settings }, ]; -function InstanceTabs() { - const pathname = usePathname(); - const { name: instanceName } = useInstanceContext(); - - // Determine current tab based on pathname - // /instance -> dashboard - // /instance/backups -> backups - // etc. - // More robust logic: extract tab from pathname, supporting only known tabs. +function getTabFromPathname(pathname: string): string { + // Default to dashboard let currentTab = 'dashboard'; - if (pathname.startsWith('/instance/')) { + + if (pathname && pathname.startsWith('/instance/')) { // Take the segment after /instance/ const segment = pathname.replace(/^\/instance\/?/, '').split('/')[0]; // Match only known TABS by value @@ -287,6 +281,15 @@ function InstanceTabs() { } } + return currentTab; +} + +function InstanceTabs() { + const pathname = usePathname(); + const { name: instanceName } = useInstanceContext(); + + const currentTab = getTabFromPathname(pathname); + return (
@@ -294,7 +297,7 @@ function InstanceTabs() { {TABS.map((tab) => { const targetPath = tab.value === 'dashboard' ? '/instance' : `/instance/${tab.value}`; - + const Icon = tab.icon; return ( - diff --git a/app/(main)/layout.tsx b/app/(main)/layout.tsx index d2899542..f816a1b7 100644 --- a/app/(main)/layout.tsx +++ b/app/(main)/layout.tsx @@ -8,7 +8,6 @@ export default function DashboardLayout({ }: { children: React.ReactNode; }) { - const variant = 'inset'; return ( - - {variant != 'inset' ? ( - <> -
-
-
- {children} -
-
-
- - ) : ( - - - {children} - - - )} + + + + {children} + +
); diff --git a/app/_lib/server.ts b/app/_lib/server.ts index e69a43c7..46de2071 100644 --- a/app/_lib/server.ts +++ b/app/_lib/server.ts @@ -45,7 +45,8 @@ function processConfigurableOptions(config: ConfigurableOptions) { }; // Helper to process a single option - const MATCHED_TYPE_BOTH = 'both' as const; + const getOptionIdentifier = (option: ConfigOption) => + option.name || option.key || '[unknown key]'; const processOption = (option: ConfigOption) => { const textToCheck = [option.condition, option.shortdesc, option.longdesc] @@ -55,25 +56,25 @@ function processConfigurableOptions(config: ConfigurableOptions) { // Default to supporting both types option.supported_types = ['container', 'virtual-machine']; - let typeMatchCategory: 'both' | 'container' | 'virtual-machine' = MATCHED_TYPE_BOTH; + let matchedType: 'both' | 'container' | 'virtual-machine' = 'both'; // Check for container-only patterns if ( TYPE_PATTERNS.container.some((pattern) => textToCheck.includes(pattern)) ) { option.supported_types = ['container']; - typeMatchCategory = 'container'; + matchedType = 'container'; } // Check for VM-only patterns else if ( TYPE_PATTERNS.vm.some((pattern) => textToCheck.includes(pattern)) ) { option.supported_types = ['virtual-machine']; - typeMatchCategory = 'virtual-machine'; + matchedType = 'virtual-machine'; } // Warn if no pattern matched and falling back to both - if (typeMatchCategory === MATCHED_TYPE_BOTH && process.env.NODE_ENV === 'development') { + if (matchedType === 'both' && process.env.NODE_ENV === 'development') { console.warn( - `[processOption] Option ${option.name || option.key || '[unknown key]'} uses the default 'both' instance types due to unmatched pattern:`, + `[processOption] Option ${getOptionIdentifier(option)} uses the default 'both' instance types due to unmatched pattern:`, textToCheck ); }