- 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.
5.0 KiB
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:
- The WordPress plugin was disabled
- 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:
<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:
// Schedule hourly checks (one per hour)
60 * 60 * 1000 // 60 minutes ❌ Too long!
After:
// 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:
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
- Initial state: Plugin active, shows "Connected" ✅
- User disables plugin on WordPress site
- Old behavior: Shows "Connected" for up to 60 minutes ❌
- 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
- Initial state: Valid credentials, shows "Connected" ✅
- User revokes credentials in WordPress plugin
- Old behavior: Shows "Connected" for up to 60 minutes ❌
- 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
- User unsure about current connection state
- Old behavior: Had to wait or reload page ❌
- New behavior: Click refresh button for instant check ✅
Files Modified
File: /data/app/igny8/frontend/src/pages/Sites/Settings.tsx
Changes:
- ✅ Added manual refresh button with icon
- ✅ Reduced auto-check interval from 60min to 5min
- ✅ Added auto-check when switching to Integrations tab
- ✅ Button disabled during pending state
- ✅ 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! 🎯