docs: Update all documentation for standalone mode and settings structure

This commit is contained in:
dwindown
2025-11-05 11:28:09 +07:00
parent 3e7d75c98c
commit d52fc3bb24
6 changed files with 271 additions and 33 deletions

View File

@@ -2062,3 +2062,166 @@ All endpoints support caching (5 minutes):
**Total Development Time:** ~6 hours
**Status:** ✅ Production Ready
**Next Milestone:** Products module OR Settings module
---
## 🚀 Standalone Admin Mode — November 5, 2025
### ✅ COMPLETE - Three Admin Modes Implemented
**Goal:** Provide flexible admin interface access with three distinct modes: normal (wp-admin), fullscreen, and standalone.
### 🎯 Three Admin Modes
#### **1. Normal Mode (wp-admin)**
- **URL:** `/wp-admin/admin.php?page=woonoow`
- **Layout:** WordPress admin sidebar + WooNooW SPA
- **Use Case:** Traditional WordPress admin workflow
- **Features:**
- WordPress admin bar visible
- WordPress sidebar navigation
- WooNooW SPA in main content area
- Settings submenu hidden (use WooCommerce settings)
#### **2. Fullscreen Mode**
- **Toggle:** Fullscreen button in header
- **Layout:** WooNooW SPA only (no WordPress chrome)
- **Use Case:** Focus mode for order processing
- **Features:**
- Maximized workspace
- Distraction-free interface
- All WooNooW features accessible
- Settings submenu hidden
#### **3. Standalone Mode** ✨ NEW
- **URL:** `https://yoursite.com/admin`
- **Layout:** Complete standalone application
- **Use Case:** Quick daily access, mobile-friendly
- **Features:**
- Custom login page (`/admin#/login`)
- WordPress authentication integration
- Settings submenu visible (SPA settings pages)
- "WordPress" button to access wp-admin
- "Logout" button in header
- Admin bar link in wp-admin to standalone
### 🔧 Implementation Details
#### **Backend Changes**
**File:** `includes/Admin/StandaloneAdmin.php`
- Handles `/admin` and `/admin/` requests
- Renders standalone HTML template
- Localizes `WNW_CONFIG` with `standaloneMode: true`
- Provides authentication state
- Includes store settings (currency, formatting)
**File:** `includes/Admin/Menu.php`
- Added admin bar link to standalone mode
- Icon: `dashicons-store`
- Only visible to users with `manage_woocommerce` capability
**File:** `includes/Api/AuthController.php`
- Login endpoint using native WordPress authentication
- Sequence: `wp_authenticate()` → `wp_clear_auth_cookie()` → `wp_set_current_user()` → `wp_set_auth_cookie()` → `do_action('wp_login')`
- Ensures session persistence between standalone and wp-admin
#### **Frontend Changes**
**File:** `admin-spa/src/App.tsx`
- `AuthWrapper` component handles authentication
- Login/logout flow with page reload
- "WordPress" button in header (standalone only)
- "Logout" button in header (standalone only)
**File:** `admin-spa/src/routes/Login.tsx`
- Custom login form
- Username/password authentication
- Redirects to dashboard after login
- Page reload to pick up fresh cookies/nonces
**File:** `admin-spa/src/nav/tree.ts`
- Dynamic settings submenu using getter
- Only shows in standalone mode: `get children() { return isStandalone ? [...] : [] }`
- Dashboard path: `/dashboard` (with redirect from `/`)
### 📊 Navigation Structure
**Standalone Mode Settings:**
```
Settings
├── WooNooW (main settings)
├── General (store settings)
├── Payments (gateways)
├── Shipping (zones, methods)
├── Products (inventory)
├── Tax (rates)
├── Accounts & Privacy
├── Emails (templates)
├── Advanced (bridge to wp-admin)
├── Integration (bridge to wp-admin)
├── Status (bridge to wp-admin)
└── Extensions (bridge to wp-admin)
```
**Strategy:** Option A - Everyday Use Dashboard
- Focus on most-used settings
- Bridge to wp-admin for advanced settings
- Extensible for 3rd party plugins
- Coexist with WooCommerce
### 🔐 Authentication Flow
**Standalone Login:**
1. User visits `/admin`
2. Not authenticated → redirect to `/admin#/login`
3. Submit credentials → `POST /wp-json/woonoow/v1/auth/login`
4. Backend sets WordPress auth cookies
5. Page reload → authenticated state
6. Access all WooNooW features
**Session Persistence:**
- Login in standalone → logged in wp-admin ✅
- Login in wp-admin → logged in standalone ✅
- Logout in standalone → logged out wp-admin ✅
- Logout in wp-admin → logged out standalone ✅
### 📱 Cross-Navigation
**From Standalone to wp-admin:**
- Click "WordPress" button in header
- Opens `/wp-admin` in same tab
- Session persists
**From wp-admin to Standalone:**
- Click "WooNooW" in admin bar
- Opens `/admin` in same tab
- Session persists
### ✅ Features Completed
- [x] Standalone mode routing (`/admin`)
- [x] Custom login page
- [x] WordPress authentication integration
- [x] Session persistence
- [x] Settings submenu (standalone only)
- [x] WordPress button in header
- [x] Logout button in header
- [x] Admin bar link to standalone
- [x] Dashboard path consistency (`/dashboard`)
- [x] Dynamic navigation tree
- [x] Settings placeholder pages
- [x] Documentation updates
### 📚 Documentation
- `STANDALONE_ADMIN_SETUP.md` - Setup guide
- `PROJECT_BRIEF.md` - Updated Phase 4
- `PROJECT_SOP.md` - Section 7 (modes explanation)
- `PROGRESS_NOTE.md` - This section
---
**Implementation Date:** November 5, 2025
**Status:** ✅ Production Ready
**Next Milestone:** Implement General/Payments/Shipping settings pages