From 3e7d75c98ce21dfa7612ef0b01e37a34c750021e Mon Sep 17 00:00:00 2001 From: dwindown Date: Wed, 5 Nov 2025 10:44:08 +0700 Subject: [PATCH] fix: Settings submenu standalone-only, dashboard path, add admin bar link --- admin-spa/src/App.tsx | 3 ++- admin-spa/src/nav/tree.ts | 9 +++++---- includes/Admin/Menu.php | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/admin-spa/src/App.tsx b/admin-spa/src/App.tsx index b2f2f1d..26fcf5c 100644 --- a/admin-spa/src/App.tsx +++ b/admin-spa/src/App.tsx @@ -328,7 +328,8 @@ function AppRoutes() { return ( {/* Dashboard */} - } /> + } /> + } /> } /> } /> } /> diff --git a/admin-spa/src/nav/tree.ts b/admin-spa/src/nav/tree.ts index 92cd68c..fb00c4c 100644 --- a/admin-spa/src/nav/tree.ts +++ b/admin-spa/src/nav/tree.ts @@ -46,10 +46,10 @@ function getStaticFallbackTree(): MainNode[] { { key: 'dashboard', label: 'Dashboard', - path: '/', + path: '/dashboard', icon: 'layout-dashboard', children: [ - { label: 'Overview', mode: 'spa', path: '/', exact: true }, + { label: 'Overview', mode: 'spa', path: '/dashboard', exact: true }, { label: 'Revenue', mode: 'spa', path: '/dashboard/revenue' }, { label: 'Orders', mode: 'spa', path: '/dashboard/orders' }, { label: 'Products', mode: 'spa', path: '/dashboard/products' }, @@ -102,7 +102,8 @@ function getStaticFallbackTree(): MainNode[] { label: 'Settings', path: '/settings', icon: 'settings', - children: [ + // Only show submenu in standalone mode + children: (window as any).WNW_CONFIG?.standaloneMode ? [ // WooNooW Settings { label: 'WooNooW', mode: 'spa', path: '/settings' }, @@ -120,7 +121,7 @@ function getStaticFallbackTree(): MainNode[] { { label: 'Integration', mode: 'bridge', href: `${admin}?page=wc-settings&tab=integration` }, { label: 'Status', mode: 'bridge', href: `${admin}?page=wc-status` }, { label: 'Extensions', mode: 'bridge', href: `${admin}?page=wc-addons` }, - ], + ] : [], }, ]; } diff --git a/includes/Admin/Menu.php b/includes/Admin/Menu.php index 9a4d2fa..a36ce9e 100644 --- a/includes/Admin/Menu.php +++ b/includes/Admin/Menu.php @@ -6,6 +6,8 @@ class Menu { add_action('admin_menu', [__CLASS__, 'register']); // After all plugins/themes add their menus, collect Woo menus for SPA add_action('admin_head', [__CLASS__, 'localize_wc_menus'], 999); + // Add link to standalone admin in admin bar + add_action('admin_bar_menu', [__CLASS__, 'add_admin_bar_link'], 100); } public static function register() { add_menu_page( @@ -92,4 +94,23 @@ class Menu { } } + /** + * Add link to standalone admin in WordPress admin bar + */ + public static function add_admin_bar_link( $wp_admin_bar ) { + // Only show for users with WooCommerce permissions + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return; + } + + $wp_admin_bar->add_node( [ + 'id' => 'woonoow-standalone', + 'title' => 'WooNooW', + 'href' => home_url( '/admin' ), + 'meta' => [ + 'title' => __( 'WooNooW Standalone Admin', 'woonoow' ), + ], + ] ); + } + } \ No newline at end of file