From 52127049429ce99fe9fe8dc3b60a99439cd2de36 Mon Sep 17 00:00:00 2001 From: Juan Denis Date: Mon, 15 Jun 2026 01:53:30 -0400 Subject: [PATCH] Add Git provider UI, refactor headers, and WP fixes Introduce GitProviders (provider detection, badges, and RepoProviderStrip) and a shared _git-connect.scss; update Git connect modal and WordPress Git form to use the new UI and provider detection. Replace many page header blocks with PageTopbar and wrap loading states in page-container for consistent layout. Backend: add _is_wp_app helper and use it in wordpress API endpoints; ensure wp-cli login plugin is installed and activated. Minor style/token cleanups and .gitignore addition for docs/UI_CONSISTENCY_AUDIT.md. --- .gitignore | 1 + backend/app/api/wordpress.py | 18 +- backend/app/services/wordpress_service.py | 7 +- frontend/src/components/git/GitProviders.jsx | 68 ++++ .../service-detail/GitConnectModal.jsx | 115 ++++--- .../components/wordpress/GitConnectForm.jsx | 190 ++++++----- frontend/src/pages/AppMap.jsx | 13 +- frontend/src/pages/Backups.jsx | 24 +- frontend/src/pages/CloudProvision.jsx | 2 +- frontend/src/pages/CronJobs.jsx | 6 +- frontend/src/pages/DNSZones.jsx | 2 +- frontend/src/pages/Deployments.jsx | 16 +- frontend/src/pages/Documentation.jsx | 37 +- frontend/src/pages/Email.jsx | 17 +- frontend/src/pages/Firewall.jsx | 23 +- frontend/src/pages/Git.jsx | 22 +- frontend/src/pages/Login.jsx | 5 +- frontend/src/pages/Marketplace.jsx | 2 +- frontend/src/pages/NewService.jsx | 13 +- frontend/src/pages/Security.jsx | 15 +- frontend/src/pages/ServerTemplates.jsx | 2 +- frontend/src/pages/Settings.jsx | 10 +- frontend/src/pages/StatusPages.jsx | 2 +- frontend/src/pages/WordPressDetail.jsx | 57 ++-- frontend/src/pages/WordPressProject.jsx | 2 +- frontend/src/pages/WordPressProjects.jsx | 2 +- frontend/src/pages/Workspaces.jsx | 2 +- .../src/styles/components/_git-connect.scss | 317 ++++++++++++++++++ frontend/src/styles/main.scss | 1 + frontend/src/styles/pages/_app-map.scss | 10 +- frontend/src/styles/pages/_applications.scss | 8 + .../src/styles/pages/_cloud-provision.scss | 40 +-- frontend/src/styles/pages/_downloads.scss | 19 -- frontend/src/styles/pages/_firewall.scss | 27 -- frontend/src/styles/pages/_git.scss | 27 -- .../src/styles/pages/_server-templates.scss | 58 ++-- frontend/src/styles/pages/_servers.scss | 2 +- .../src/styles/pages/_service-detail.scss | 78 ----- frontend/src/styles/pages/_settings.scss | 17 - frontend/src/styles/pages/_templates.scss | 28 -- frontend/src/styles/pages/_wordpress.scss | 152 +++------ 41 files changed, 810 insertions(+), 647 deletions(-) create mode 100644 frontend/src/components/git/GitProviders.jsx create mode 100644 frontend/src/styles/components/_git-connect.scss diff --git a/.gitignore b/.gitignore index e52b43c8..7d221557 100644 --- a/.gitignore +++ b/.gitignore @@ -128,3 +128,4 @@ docs/PLAN_AGENT_FLEET.md /.claude /.github/skills /.playwright-mcp +docs/UI_CONSISTENCY_AUDIT.md diff --git a/backend/app/api/wordpress.py b/backend/app/api/wordpress.py index a9915f0d..de7d0e21 100644 --- a/backend/app/api/wordpress.py +++ b/backend/app/api/wordpress.py @@ -16,6 +16,18 @@ def _resolve_app(site_or_app_id): return Application.query.get(site_or_app_id) +def _is_wp_app(app): + """True if `app` is a WordPress-managed site. Containerized WP sites are + stored with app_type 'docker' (see WordPressService), so app_type alone is + not a reliable signal — a linked WordPressSite record is the source of truth. + """ + if not app: + return False + if app.app_type == 'wordpress': + return True + return WordPressSite.query.filter_by(application_id=app.id).first() is not None + + # ==================== WORDPRESS SITES HUB ENDPOINTS ==================== @wordpress_bp.route('/sites', methods=['GET']) @@ -786,7 +798,7 @@ def get_wordpress_info(app_id): if user.role != 'admin' and app.user_id != current_user_id: return jsonify({'error': 'Access denied'}), 403 - if app.app_type != 'wordpress': + if not _is_wp_app(app): return jsonify({'error': 'Application is not a WordPress site'}), 400 info = WordPressService.get_wordpress_info(app.root_path) @@ -806,7 +818,7 @@ def update_wordpress(app_id): if not app: return jsonify({'error': 'Application not found'}), 404 - if app.app_type != 'wordpress': + if not _is_wp_app(app): return jsonify({'error': 'Application is not a WordPress site'}), 400 result = WordPressService.update_wordpress(app.root_path) @@ -1293,7 +1305,7 @@ def wp_auto_login(site_id): app = wp_site.application if wp_site else _resolve_app(site_id) if not app or not app.root_path: return jsonify({'error': 'Application not found'}), 404 - if app.app_type != 'wordpress': + if not _is_wp_app(app): return jsonify({'error': 'Application is not a WordPress site'}), 400 # Resolve a managed admin tied to the operator's panel email. Prefer the diff --git a/backend/app/services/wordpress_service.py b/backend/app/services/wordpress_service.py index 03db2406..902ee8e0 100644 --- a/backend/app/services/wordpress_service.py +++ b/backend/app/services/wordpress_service.py @@ -1223,8 +1223,11 @@ RewriteRule ^wp-content/uploads/.*\\.php$ - [F] inst = cls.wp_cli(path, ['package', 'install', 'aaemnnosttv/wp-cli-login-command']) if not inst.get('success'): return {'success': False, 'error': 'Failed to install wp-cli-login package: ' + (inst.get('error') or '')} - # Ensure the companion launcher mu-plugin is present (idempotent). - cls.wp_cli(path, ['login', 'install', '--yes']) + # Ensure the companion launcher plugin is present AND active (idempotent). + # Without --activate the plugin installs but stays inactive, and the + # subsequent `wp login create` fails with "requires the companion plugin + # to be installed and active". + cls.wp_cli(path, ['login', 'install', '--activate', '--yes']) return {'success': True} @classmethod diff --git a/frontend/src/components/git/GitProviders.jsx b/frontend/src/components/git/GitProviders.jsx new file mode 100644 index 00000000..cd329786 --- /dev/null +++ b/frontend/src/components/git/GitProviders.jsx @@ -0,0 +1,68 @@ +// Brand-authentic Git provider identities — the single source of truth for how a +// repository host is recognized and presented across ServerKit's "connect a +// repository" surfaces (New Service page, the service connect modal, and the +// WordPress Git tab). Mirrors components/icons/DatabaseBrands.jsx: we wrap Simple +// Icons (via react-icons) so GitHub / GitLab / Bitbucket / Gitea are instantly +// recognizable instead of sharing one generic git glyph. +// +// Simple Icons render with `fill="currentColor"`, so the surrounding SCSS controls +// the color with no inline styles. +import { SiGithub, SiGitlab, SiBitbucket, SiGitea } from 'react-icons/si'; +import { GitBranch } from 'lucide-react'; + +// Ordered list rendered in the provider strip. `match` recognizes a clone URL's +// host; the trailing "other" entry is the catch-all (self-hosted, SSH, anything +// unrecognized). +export const GIT_PROVIDERS = [ + { key: 'github', label: 'GitHub', Icon: SiGithub, hint: 'HTTPS or SSH', match: /github\.com/i }, + { key: 'gitlab', label: 'GitLab', Icon: SiGitlab, hint: 'Cloud or self-managed', match: /gitlab\./i }, + { key: 'bitbucket', label: 'Bitbucket', Icon: SiBitbucket, hint: 'bitbucket.org', match: /bitbucket\.org/i }, + { key: 'gitea', label: 'Gitea', Icon: SiGitea, hint: 'Self-hosted', match: /gitea/i }, + { key: 'other', label: 'SSH / Other', Icon: GitBranch, hint: 'Any Git remote', match: null }, +]; + +const OTHER_PROVIDER = GIT_PROVIDERS[GIT_PROVIDERS.length - 1]; + +// Resolve a clone URL to a provider. Returns null for an empty field (so callers +// can render a neutral, nothing-detected state) and the "other" catch-all when a +// non-empty URL matches no known host. +export function detectProvider(url) { + const trimmed = (url || '').trim(); + if (!trimmed) return null; + return GIT_PROVIDERS.find((p) => p.match && p.match.test(trimmed)) || OTHER_PROVIDER; +} + +// The "explains the others" strip: every supported host as a chip with its brand +// mark, label, and a one-liner. The detected provider gets the accent highlight. +export function RepoProviderStrip({ detected }) { + return ( +
+ {GIT_PROVIDERS.map(({ key, label, Icon, hint }) => ( +
+ + + {label} + {hint} +
+ ))} +
+ ); +} + +// Inline brand mark + name — the live "detected provider" indicator beside a URL +// field. Renders nothing until a provider is resolved. +export function ProviderBadge({ provider }) { + if (!provider) return null; + const { Icon, label } = provider; + return ( + + + ); +} diff --git a/frontend/src/components/service-detail/GitConnectModal.jsx b/frontend/src/components/service-detail/GitConnectModal.jsx index 64358a1e..fa87edd6 100644 --- a/frontend/src/components/service-detail/GitConnectModal.jsx +++ b/frontend/src/components/service-detail/GitConnectModal.jsx @@ -1,4 +1,5 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; +import { ChevronDown, GitBranch, Settings2 } from 'lucide-react'; import api from '../../services/api'; import { useToast } from '../../contexts/ToastContext'; import { Button } from '@/components/ui/button'; @@ -7,6 +8,7 @@ import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; import { Switch } from '@/components/ui/switch'; import Modal from '../Modal'; +import { RepoProviderStrip, ProviderBadge, detectProvider } from '../git/GitProviders'; const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => { const toast = useToast(); @@ -16,13 +18,9 @@ const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => { const [autoDeploy, setAutoDeploy] = useState(deployConfig?.auto_deploy ?? true); const [preDeployScript, setPreDeployScript] = useState(deployConfig?.pre_deploy_script || ''); const [postDeployScript, setPostDeployScript] = useState(deployConfig?.post_deploy_script || ''); - - function detectProvider(url) { - if (url.includes('github.com')) return 'GitHub'; - if (url.includes('gitlab.com')) return 'GitLab'; - if (url.includes('bitbucket.org')) return 'Bitbucket'; - return null; - } + const [scriptsOpen, setScriptsOpen] = useState( + Boolean(deployConfig?.pre_deploy_script || deployConfig?.post_deploy_script) + ); const provider = detectProvider(repoUrl); @@ -56,7 +54,7 @@ const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => { toast.success('Repository connected'); onSaved(); - } catch (err) { + } catch { toast.error('Failed to save deployment configuration'); } finally { setSaving(false); @@ -71,7 +69,7 @@ const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => { await api.removeDeployment(appId); toast.success('Repository disconnected'); onSaved(); - } catch (err) { + } catch { toast.error('Failed to disconnect repository'); setSaving(false); } @@ -79,26 +77,36 @@ const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => { return ( -
-
- + +
+ + + +
+ Connect a Git repository + Link a repo so ServerKit can pull your code and redeploy on every push. +
+
+ + + +
+ setRepoUrl(e.target.value)} placeholder="https://github.com/user/repo.git" required /> - {provider && ( - - Detected: {provider} - - )} + {provider && }
-
- +
+ setBranch(e.target.value)} @@ -106,43 +114,58 @@ const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => { />
-
-
- Auto-deploy on push - Automatically deploy when new commits are pushed to the branch. +
+
+ Auto-deploy on push + Automatically deploy when new commits land on this branch.
- +
-
- -