- Updated the `IntegrationService` to perform connection tests using only the API key, removing reliance on username and app password. - Simplified health check logic and improved error messaging for better clarity. - Added functionality to revoke API keys in the `WordPressIntegrationForm` component. - Enhanced site settings page with a site selector and improved integration status display. - Cleaned up unused code and improved overall structure for better maintainability.
171 lines
5.0 KiB
Markdown
171 lines
5.0 KiB
Markdown
# Connection Status Indicator - Enhanced Real-Time Validation
|
|
|
|
## Date: 2025-11-22
|
|
|
|
## Problem Identified
|
|
|
|
The user reported that the connection status indicator was showing **"Connected" (green)** even though:
|
|
1. The WordPress plugin was disabled
|
|
2. API credentials were revoked in the plugin
|
|
|
|
**Root Cause:** Connection status was **cached and only checked every 60 minutes**, leading to stale status information that didn't reflect the current state.
|
|
|
|
---
|
|
|
|
## Improvements Made
|
|
|
|
### **1. Added Manual Refresh Button** ✅
|
|
|
|
Added a refresh icon button next to the connection status indicator that allows users to manually trigger a connection test.
|
|
|
|
**Features:**
|
|
- Circular refresh icon
|
|
- Hover tooltip: "Refresh connection status"
|
|
- Disabled during pending status (prevents spam)
|
|
- Instant feedback when clicked
|
|
|
|
**Location:** Right next to the connection status text
|
|
|
|
**Code:**
|
|
```typescript
|
|
<button
|
|
onClick={(e) => {
|
|
e.preventDefault();
|
|
runIntegrationTest();
|
|
}}
|
|
disabled={integrationTestStatus === 'pending'}
|
|
className="ml-2 px-2 py-1 text-xs font-medium text-gray-600 hover:text-brand-600 dark:text-gray-400 dark:hover:text-brand-400 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
title="Refresh connection status"
|
|
>
|
|
<svg className="w-4 h-4" ...>
|
|
```
|
|
|
|
---
|
|
|
|
### **2. Reduced Auto-Check Interval** ✅
|
|
|
|
Changed automatic connection test frequency from **60 minutes** to **5 minutes**.
|
|
|
|
**Before:**
|
|
```typescript
|
|
// Schedule hourly checks (one per hour)
|
|
60 * 60 * 1000 // 60 minutes ❌ Too long!
|
|
```
|
|
|
|
**After:**
|
|
```typescript
|
|
// Schedule checks every 5 minutes (more responsive)
|
|
5 * 60 * 1000 // 5 minutes ✅ Much better!
|
|
```
|
|
|
|
**Impact:**
|
|
- Connection status updates every 5 minutes automatically
|
|
- Maximum staleness: 5 minutes (down from 60 minutes)
|
|
- Detects plugin disablement/credential revocation faster
|
|
|
|
---
|
|
|
|
### **3. Auto-Test on Tab Switch** ✅
|
|
|
|
Added automatic connection test when user switches to the **Integrations tab**.
|
|
|
|
**Code:**
|
|
```typescript
|
|
useEffect(() => {
|
|
if (activeTab === 'content-types' && wordPressIntegration) {
|
|
loadContentTypes();
|
|
}
|
|
// Re-check connection status when switching to integrations tab
|
|
if (activeTab === 'integrations' && wordPressIntegration) {
|
|
runIntegrationTest();
|
|
}
|
|
}, [activeTab, wordPressIntegration]);
|
|
```
|
|
|
|
**Behavior:**
|
|
- When user clicks "Integrations" tab
|
|
- Connection test runs automatically
|
|
- Shows current status immediately
|
|
- User gets fresh status without manual action
|
|
|
|
---
|
|
|
|
## User Experience Improvements
|
|
|
|
### **Before Fix:**
|
|
❌ Status could be stale for up to 60 minutes
|
|
❌ No way to manually refresh
|
|
❌ False "Connected" status persisted even after plugin disabled
|
|
❌ User had to reload entire page to get fresh status
|
|
|
|
### **After Fix:**
|
|
✅ Auto-refresh every 5 minutes
|
|
✅ Manual refresh button available
|
|
✅ Auto-refresh when switching to Integrations tab
|
|
✅ Maximum staleness: 5 minutes (or instant with refresh button)
|
|
✅ User can verify status on-demand
|
|
|
|
---
|
|
|
|
## Connection Status States
|
|
|
|
| Status | Color | Meaning |
|
|
|--------|-------|---------|
|
|
| 🟢 **Connected** | Green | Integration configured AND last test succeeded |
|
|
| ⚪ **Not configured** | Gray | No integration set up |
|
|
| 🔴 **Error** | Red | Integration exists but connection failed |
|
|
| 🟡 **Checking...** | Yellow | Connection test in progress |
|
|
|
|
---
|
|
|
|
## Testing Scenarios
|
|
|
|
### Scenario 1: Plugin Disabled After Initial Connection
|
|
1. **Initial state:** Plugin active, shows "Connected" ✅
|
|
2. **User disables plugin** on WordPress site
|
|
3. **Old behavior:** Shows "Connected" for up to 60 minutes ❌
|
|
4. **New behavior:**
|
|
- Auto-refresh in max 5 minutes, shows "Error" ✅
|
|
- User can click refresh button for instant check ✅
|
|
- Switching to Integrations tab triggers check ✅
|
|
|
|
### Scenario 2: API Credentials Revoked
|
|
1. **Initial state:** Valid credentials, shows "Connected" ✅
|
|
2. **User revokes credentials** in WordPress plugin
|
|
3. **Old behavior:** Shows "Connected" for up to 60 minutes ❌
|
|
4. **New behavior:**
|
|
- Auto-refresh in max 5 minutes, shows "Error" ✅
|
|
- User can click refresh button for instant check ✅
|
|
|
|
### Scenario 3: User Wants to Verify Status
|
|
1. **User unsure** about current connection state
|
|
2. **Old behavior:** Had to wait or reload page ❌
|
|
3. **New behavior:** Click refresh button for instant check ✅
|
|
|
|
---
|
|
|
|
## Files Modified
|
|
|
|
**File:** `/data/app/igny8/frontend/src/pages/Sites/Settings.tsx`
|
|
|
|
**Changes:**
|
|
1. ✅ Added manual refresh button with icon
|
|
2. ✅ Reduced auto-check interval from 60min to 5min
|
|
3. ✅ Added auto-check when switching to Integrations tab
|
|
4. ✅ Button disabled during pending state
|
|
5. ✅ Hover tooltips added
|
|
|
|
---
|
|
|
|
## Summary
|
|
|
|
The connection status indicator is now **much more responsive** and provides **real-time validation** of WordPress integration status:
|
|
|
|
- **5-minute auto-refresh** (down from 60 minutes)
|
|
- **Manual refresh button** for instant validation
|
|
- **Auto-refresh on tab switch** to Integrations
|
|
- **Maximum staleness: 5 minutes** (or 0 with manual refresh)
|
|
|
|
Users can now **trust the connection status** and verify it on-demand! 🎯
|
|
|