Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Redirect WordPress apps to dedicated page and refactor

Juan Denise3d60775faf8
diff --git a/frontend/src/pages/ApplicationDetail.jsx b/frontend/src/pages/ApplicationDetail.jsx
index 57902282..90086234 100644
--- a/frontend/src/pages/ApplicationDetail.jsx
+++ b/frontend/src/pages/ApplicationDetail.jsx
@@ -19,6 +19,13 @@ const ApplicationDetail = () => {
loadApp();
}, [id]);
+ // Redirect WordPress apps to the dedicated WordPress detail page
+ useEffect(() => {
+ if (app && app.app_type === 'wordpress') {
+ navigate(`/wordpress/${id}`, { replace: true });
+ }
+ }, [app, id, navigate]);
+
async function loadApp() {
try {
const data = await api.getApp(id);
@@ -93,7 +100,6 @@ const ApplicationDetail = () => {
}
const isPythonApp = ['flask', 'django'].includes(app.app_type);
- const isWordPressApp = app.app_type === 'wordpress';
const isDockerApp = app.app_type === 'docker';
const isRunning = app.status === 'running';
@@ -216,28 +222,6 @@ const ApplicationDetail = () => {
</div>
</>
)}
- {isWordPressApp && (
- <>
- <div
- className={`app-detail-tab ${activeTab === 'plugins' ? 'active' : ''}`}
- onClick={() => setActiveTab('plugins')}
- >
- Plugins
- </div>
- <div
- className={`app-detail-tab ${activeTab === 'themes' ? 'active' : ''}`}
- onClick={() => setActiveTab('themes')}
- >
- Themes
- </div>
- <div
- className={`app-detail-tab ${activeTab === 'backups' ? 'active' : ''}`}
- onClick={() => setActiveTab('backups')}
- >
- Backups
- </div>
- </>
- )}
<div
className={`app-detail-tab ${activeTab === 'build' ? 'active' : ''}`}
onClick={() => setActiveTab('build')}
@@ -271,9 +255,6 @@ const ApplicationDetail = () => {
{activeTab === 'packages' && isPythonApp && <PackagesTab appId={app.id} />}
{activeTab === 'gunicorn' && isPythonApp && <GunicornTab appId={app.id} />}
{activeTab === 'commands' && isPythonApp && <CommandsTab appId={app.id} appType={app.app_type} />}
- {activeTab === 'plugins' && isWordPressApp && <PluginsTab appId={app.id} />}
- {activeTab === 'themes' && isWordPressApp && <ThemesTab appId={app.id} />}
- {activeTab === 'backups' && isWordPressApp && <BackupsTab appId={app.id} />}
{activeTab === 'build' && <BuildTab appId={app.id} appPath={app.path} />}
{activeTab === 'deploy' && <DeployTab appId={app.id} appPath={app.path} />}
{activeTab === 'logs' && <LogsTab app={app} />}
@@ -861,226 +842,6 @@ const CommandsTab = ({ appId, appType }) => {
);
};
-const PluginsTab = ({ appId }) => {
- const [plugins, setPlugins] = useState([]);
- const [loading, setLoading] = useState(true);
-
- useEffect(() => {
- loadPlugins();
- }, [appId]);
-
- async function loadPlugins() {
- try {
- const data = await api.getWordPressPlugins(appId);
- setPlugins(data.plugins || []);
- } catch (err) {
- console.error('Failed to load plugins:', err);
- } finally {
- setLoading(false);
- }
- }
-
- async function handleActivate(plugin) {
- try {
- await api.activateWordPressPlugin(appId, plugin);
- loadPlugins();
- } catch (err) {
- console.error('Failed to activate plugin:', err);
- }
- }
-
- async function handleDeactivate(plugin) {
- try {
- await api.deactivateWordPressPlugin(appId, plugin);
- loadPlugins();
- } catch (err) {
- console.error('Failed to deactivate plugin:', err);
- }
- }
-
- if (loading) {
- return <div className="loading">Loading plugins...</div>;
- }
-
- return (
- <div>
- <h3>WordPress Plugins</h3>
- <div className="plugins-list">
- {plugins.map(plugin => (
- <div key={plugin.name} className="plugin-item">
- <div className="plugin-info">
- <span className="plugin-name">{plugin.title || plugin.name}</span>
- <span className="plugin-version">{plugin.version}</span>
- </div>
- <div className="plugin-actions">
- {plugin.status === 'active' ? (
- <button
- className="btn btn-secondary btn-sm"
- onClick={() => handleDeactivate(plugin.name)}
- >
- Deactivate
- </button>
- ) : (
- <button
- className="btn btn-primary btn-sm"
- onClick={() => handleActivate(plugin.name)}
- >
- Activate
- </button>
- )}
- </div>
- </div>
- ))}
- </div>
- </div>
- );
-};
-
-const ThemesTab = ({ appId }) => {
- const [themes, setThemes] = useState([]);
- const [loading, setLoading] = useState(true);
-
- useEffect(() => {
- loadThemes();
- }, [appId]);
-
- async function loadThemes() {
- try {
- const data = await api.getWordPressThemes(appId);
- setThemes(data.themes || []);
- } catch (err) {
- console.error('Failed to load themes:', err);
- } finally {
- setLoading(false);
- }
- }
-
- async function handleActivate(theme) {
- try {
- await api.activateWordPressTheme(appId, theme);
- loadThemes();
- } catch (err) {
- console.error('Failed to activate theme:', err);
- }
- }
-
- if (loading) {
- return <div className="loading">Loading themes...</div>;
- }
-
- return (
- <div>
- <h3>WordPress Themes</h3>
- <div className="themes-list">
- {themes.map(theme => (
- <div key={theme.name} className={`theme-item ${theme.status === 'active' ? 'active' : ''}`}>
- <div className="theme-info">
- <span className="theme-name">{theme.title || theme.name}</span>
- <span className="theme-version">{theme.version}</span>
- </div>
- {theme.status !== 'active' && (
- <button
- className="btn btn-primary btn-sm"
- onClick={() => handleActivate(theme.name)}
- >
- Activate
- </button>
- )}
- {theme.status === 'active' && (
- <span className="active-badge">Active</span>
- )}
- </div>
- ))}
- </div>
- </div>
- );
-};
-
-const BackupsTab = ({ appId }) => {
- const toast = useToast();
- const [backups, setBackups] = useState([]);
- const [loading, setLoading] = useState(true);
- const [creating, setCreating] = useState(false);
-
- useEffect(() => {
- loadBackups();
- }, [appId]);
-
- async function loadBackups() {
- try {
- const data = await api.getWordPressBackups(appId);
- setBackups(data.backups || []);
- } catch (err) {
- console.error('Failed to load backups:', err);
- } finally {
- setLoading(false);
- }
- }
-
- async function handleCreate() {
- setCreating(true);
- try {
- await api.createWordPressBackup(appId);
- loadBackups();
- } catch (err) {
- console.error('Failed to create backup:', err);
- } finally {
- setCreating(false);
- }
- }
-
- async function handleRestore(backupName) {
- if (!confirm(`Restore from ${backupName}? This will overwrite current data.`)) return;
-
- try {
- await api.restoreWordPressBackup(appId, backupName);
- toast.success('Backup restored successfully');
- } catch (err) {
- toast.error('Failed to restore backup');
- console.error('Failed to restore backup:', err);
- }
- }
-
- if (loading) {
- return <div className="loading">Loading backups...</div>;
- }
-
- return (
- <div>
- <div className="section-header">
- <h3>Backups</h3>
- <button className="btn btn-primary" onClick={handleCreate} disabled={creating}>
- {creating ? 'Creating...' : 'Create Backup'}
- </button>
- </div>
-
- {backups.length === 0 ? (
- <p className="hint">No backups yet. Create your first backup.</p>
- ) : (
- <div className="backups-list">
- {backups.map(backup => (
- <div key={backup.name} className="backup-item">
- <div className="backup-info">
- <span className="backup-name">{backup.name}</span>
- <span className="backup-size">{formatBytes(backup.size)}</span>
- <span className="backup-date">
- {new Date(backup.created_at).toLocaleString()}
- </span>
- </div>
- <button
- className="btn btn-secondary btn-sm"
- onClick={() => handleRestore(backup.name)}
- >
- Restore
- </button>
- </div>
- ))}
- </div>
- )}
- </div>
- );
-};
-
const BuildTab = ({ appId, appPath }) => {
const toast = useToast();
const [buildConfig, setBuildConfig] = useState(null);
diff --git a/frontend/src/pages/Applications.jsx b/frontend/src/pages/Applications.jsx
index a58de4a1..0e96feae 100644
--- a/frontend/src/pages/Applications.jsx
+++ b/frontend/src/pages/Applications.jsx
@@ -484,7 +484,12 @@ const CreateAppModal = ({ onClose }) => {
function selectTemplate(templateId) {
onClose();
- navigate(`/templates?install=${templateId}`);
+ // WordPress has its own dedicated management page
+ if (templateId === 'wordpress') {
+ navigate('/wordpress');
+ } else {
+ navigate(`/templates?install=${templateId}`);
+ }
}
function goToAllTemplates() {
diff --git a/frontend/src/pages/Templates.jsx b/frontend/src/pages/Templates.jsx
index fd560dab..339bb35f 100644
--- a/frontend/src/pages/Templates.jsx
+++ b/frontend/src/pages/Templates.jsx
@@ -119,6 +119,11 @@ const Templates = () => {
// Auto-open install modal if template ID is in URL
useEffect(() => {
if (installTemplateId && templates.length > 0 && !loading) {
+ // WordPress has its own dedicated page
+ if (installTemplateId === 'wordpress') {
+ navigate('/wordpress', { replace: true });
+ return;
+ }
const template = templates.find(t => t.id === installTemplateId);
if (template) {
handleViewTemplate(template).then(() => {
@@ -240,6 +245,11 @@ const Templates = () => {
}
async function handleViewTemplate(template) {
+ // WordPress has its own dedicated page
+ if (template.id === 'wordpress') {
+ navigate('/wordpress');
+ return;
+ }
try {
const result = await api.getTemplate(template.id);
if (result.template) {
diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js
index 50536d65..538a4c93 100644
--- a/frontend/src/services/api.js
+++ b/frontend/src/services/api.js
@@ -547,121 +547,7 @@ class ApiService {
return this.request(`/php/versions/${version}/fpm/status`);
}
- // WordPress endpoints
- async installWordPress(config) {
- return this.request('/wordpress/install', {
- method: 'POST',
- body: config
- });
- }
-
- async getWordPressInfo(appId) {
- return this.request(`/wordpress/sites/${appId}/info`);
- }
-
- async updateWordPress(appId) {
- return this.request(`/wordpress/sites/${appId}/update`, { method: 'POST' });
- }
-
- async getWordPressPlugins(appId) {
- return this.request(`/wordpress/sites/${appId}/plugins`);
- }
-
- async installWordPressPlugin(appId, plugin, activate = true) {
- return this.request(`/wordpress/sites/${appId}/plugins`, {
- method: 'POST',
- body: { plugin, activate }
- });
- }
-
- async uninstallWordPressPlugin(appId, plugin) {
- return this.request(`/wordpress/sites/${appId}/plugins/${plugin}`, { method: 'DELETE' });
- }
-
- async activateWordPressPlugin(appId, plugin) {
- return this.request(`/wordpress/sites/${appId}/plugins/${plugin}/activate`, { method: 'POST' });
- }
-
- async deactivateWordPressPlugin(appId, plugin) {
- return this.request(`/wordpress/sites/${appId}/plugins/${plugin}/deactivate`, { method: 'POST' });
- }
-
- async updateWordPressPlugins(appId, plugins = null) {
- return this.request(`/wordpress/sites/${appId}/plugins/update`, {
- method: 'POST',
- body: plugins ? { plugins } : {}
- });
- }
-
- async getWordPressThemes(appId) {
- return this.request(`/wordpress/sites/${appId}/themes`);
- }
-
- async installWordPressTheme(appId, theme, activate = false) {
- return this.request(`/wordpress/sites/${appId}/themes`, {
- method: 'POST',
- body: { theme, activate }
- });
- }
-
- async activateWordPressTheme(appId, theme) {
- return this.request(`/wordpress/sites/${appId}/themes/${theme}/activate`, { method: 'POST' });
- }
-
- async createWordPressBackup(appId, includeDb = true) {
- return this.request(`/wordpress/sites/${appId}/backup`, {
- method: 'POST',
- body: { include_db: includeDb }
- });
- }
-
- async getWordPressBackups(appId) {
- return this.request(`/wordpress/sites/${appId}/backups`);
- }
-
- async restoreWordPressBackup(appId, backupName) {
- return this.request(`/wordpress/sites/${appId}/restore`, {
- method: 'POST',
- body: { backup_name: backupName }
- });
- }
-
- async deleteWordPressBackup(backupName) {
- return this.request(`/wordpress/backups/${backupName}`, { method: 'DELETE' });
- }
-
- async hardenWordPress(appId) {
- return this.request(`/wordpress/sites/${appId}/harden`, { method: 'POST' });
- }
-
- async optimizeWordPressDatabase(appId) {
- return this.request(`/wordpress/sites/${appId}/optimize`, { method: 'POST' });
- }
-
- async flushWordPressCache(appId) {
- return this.request(`/wordpress/sites/${appId}/flush-cache`, { method: 'POST' });
- }
-
- async searchReplaceWordPress(appId, search, replace, dryRun = true) {
- return this.request(`/wordpress/sites/${appId}/search-replace`, {
- method: 'POST',
- body: { search, replace, dry_run: dryRun }
- });
- }
-
- async createWordPressUser(appId, userData) {
- return this.request(`/wordpress/sites/${appId}/users`, {
- method: 'POST',
- body: userData
- });
- }
-
- async resetWordPressPassword(appId, user, password = null) {
- return this.request(`/wordpress/sites/${appId}/users/${user}/reset-password`, {
- method: 'POST',
- body: password ? { password } : {}
- });
- }
+ // WordPress: Use dedicated wordpress.js service instead
// Python endpoints
async getPythonVersions() {