fix: Settings submenu standalone-only, dashboard path, add admin bar link

This commit is contained in:
dwindown
2025-11-05 10:44:08 +07:00
parent 12e982b3e5
commit 3e7d75c98c
3 changed files with 28 additions and 5 deletions

View File

@@ -328,7 +328,8 @@ function AppRoutes() {
return (
<Routes>
{/* Dashboard */}
<Route path="/" element={<Dashboard />} />
<Route path="/" element={<Navigate to="/dashboard" replace />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/dashboard/revenue" element={<DashboardRevenue />} />
<Route path="/dashboard/orders" element={<DashboardOrders />} />
<Route path="/dashboard/products" element={<DashboardProducts />} />

View File

@@ -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` },
],
] : [],
},
];
}

View File

@@ -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' => '<span class="ab-icon dashicons-store"></span><span class="ab-label">WooNooW</span>',
'href' => home_url( '/admin' ),
'meta' => [
'title' => __( 'WooNooW Standalone Admin', 'woonoow' ),
],
] );
}
}