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.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(git): shared RepoConnectForm + clickable commits; center icon tiles
Juan Denis505ff0f2cd0c
diff --git a/frontend/src/components/git/RepoConnectForm.jsx b/frontend/src/components/git/RepoConnectForm.jsxnew file mode 100644index 00000000..4b400094--- /dev/null+++ b/frontend/src/components/git/RepoConnectForm.jsx@@ -0,0 +1,227 @@+import { useState } from 'react';+import { GitBranch, Unlink } from 'lucide-react';+import { Button } from '@/components/ui/button';+import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';+import { Textarea } from '@/components/ui/textarea';+import { Switch } from '@/components/ui/switch';+import { RepoProviderStrip, ProviderBadge, detectProvider } from './GitProviders';++// Canonical "connect a repository" form, shared across ServerKit's surfaces+// (WordPress Git settings, the New Service page, the service connect modal).+// It owns the form state and submits via the `onConnect` callback; when a repo+// is already connected it shows the connected summary + Disconnect. Everything+// host-specific (intro copy, whether tracked paths are shown, defaults) is a+// prop so each caller can dress it without forking the markup.+//+// props:+// gitStatus { connected, repo_url, branch, auto_deploy, last_deploy_* }+// onConnect async ({ repo_url, branch, paths, auto_deploy }) => void+// onDisconnect async () => void+// intro { title, subtitle }+// showPaths render the "tracked paths" textarea (WordPress)+// defaultPaths / pathsLabel / pathsHint / pathsPlaceholder+// urlPlaceholder / submitLabel+// idPrefix unique id prefix (so two forms can coexist on one page)+const RepoConnectForm = ({+ gitStatus,+ onConnect,+ onDisconnect,+ intro = {+ title: 'Connect a Git repository',+ subtitle: 'Track this service in version control — push to deploy.',+ },+ showPaths = false,+ defaultPaths = [],+ pathsLabel = 'Tracked paths (one per line)',+ pathsHint = '',+ pathsPlaceholder = '',+ urlPlaceholder = 'https://github.com/user/repo.git',+ submitLabel = 'Connect Repository',+ idPrefix = 'repo',+}) => {+ const [formData, setFormData] = useState({+ repoUrl: '',+ branch: 'main',+ paths: defaultPaths,+ autoDeploy: false,+ });+ const [loading, setLoading] = useState(false);+ const [error, setError] = useState('');++ const isConnected = gitStatus?.connected;+ const provider = detectProvider(formData.repoUrl);++ function handleChange(e) {+ const { name, value } = e.target;+ setFormData((prev) => ({ ...prev, [name]: value }));+ }++ function handlePathsChange(e) {+ const paths = e.target.value.split('\n').filter((p) => p.trim());+ setFormData((prev) => ({ ...prev, paths }));+ }++ async function handleConnect(e) {+ e.preventDefault();+ setError('');+ setLoading(true);+ try {+ await onConnect({+ repo_url: formData.repoUrl,+ branch: formData.branch,+ paths: formData.paths,+ auto_deploy: formData.autoDeploy,+ });+ } catch (err) {+ setError(err.message || 'Failed to connect repository');+ } finally {+ setLoading(false);+ }+ }++ async function handleDisconnect() {+ if (!confirm('Disconnect Git repository? This will not delete any files.')) return;+ setLoading(true);+ try {+ await onDisconnect();+ } catch (err) {+ setError(err.message || 'Failed to disconnect repository');+ } finally {+ setLoading(false);+ }+ }++ if (isConnected) {+ return (+ <div className="git-connect-status">+ <div className="git-connect-status__header">+ <span className="git-connect-status__icon">+ <GitBranch size={19} />+ </span>+ <div className="git-connect-status__title">+ <strong>Repository connected</strong>+ <a+ href={gitStatus.repo_url}+ target="_blank"+ rel="noopener noreferrer"+ className="git-connect-status__url"+ >+ {gitStatus.repo_url}+ </a>+ </div>+ </div>++ <div className="git-connect-status__meta">+ <div className="git-connect-status__meta-item">+ <span>Branch</span>+ <strong>{gitStatus.branch}</strong>+ </div>+ <div className="git-connect-status__meta-item">+ <span>Auto Deploy</span>+ <strong>{gitStatus.auto_deploy ? 'Enabled' : 'Disabled'}</strong>+ </div>+ {gitStatus.last_deploy_commit && (+ <div className="git-connect-status__meta-item">+ <span>Last Deploy</span>+ <strong className="mono">{gitStatus.last_deploy_commit.substring(0, 7)}</strong>+ </div>+ )}+ {gitStatus.last_deploy_at && (+ <div className="git-connect-status__meta-item">+ <span>Deployed At</span>+ <strong>{new Date(gitStatus.last_deploy_at).toLocaleString()}</strong>+ </div>+ )}+ </div>++ <div className="git-connect-status__actions">+ <Button variant="destructive" onClick={handleDisconnect} disabled={loading}>+ <Unlink size={14} />+ {loading ? 'Disconnecting...' : 'Disconnect'}+ </Button>+ </div>+ </div>+ );+ }++ return (+ <form className="git-connect git-connect--card" onSubmit={handleConnect}>+ <div className="git-connect__intro">+ <span className="git-connect__intro-icon">+ <GitBranch size={19} />+ </span>+ <div className="git-connect__intro-text">+ <strong>{intro.title}</strong>+ <span>{intro.subtitle}</span>+ </div>+ </div>++ <RepoProviderStrip detected={provider?.key} />++ {error && <div className="error-message">{error}</div>}++ <div className="git-connect__field">+ <Label htmlFor={`${idPrefix}-repo-url`}>Repository URL</Label>+ <Input+ id={`${idPrefix}-repo-url`}+ type="text"+ name="repoUrl"+ value={formData.repoUrl}+ onChange={handleChange}+ placeholder={urlPlaceholder}+ required+ />+ {provider && <ProviderBadge provider={provider} />}+ </div>++ <div className="git-connect__field">+ <Label htmlFor={`${idPrefix}-branch`}>Branch</Label>+ <Input+ id={`${idPrefix}-branch`}+ type="text"+ name="branch"+ value={formData.branch}+ onChange={handleChange}+ placeholder="main"+ />+ </div>++ {showPaths && (+ <div className="git-connect__field">+ <Label htmlFor={`${idPrefix}-paths`}>{pathsLabel}</Label>+ <Textarea+ id={`${idPrefix}-paths`}+ value={formData.paths.join('\n')}+ onChange={handlePathsChange}+ placeholder={pathsPlaceholder}+ rows={3}+ />+ {pathsHint && <span className="git-connect__field-hint">{pathsHint}</span>}+ </div>+ )}++ <div className="git-connect__toggle">+ <div>+ <strong>Auto-deploy on push</strong>+ <span>Automatically deploy when new commits land on this branch.</span>+ </div>+ <Switch+ checked={formData.autoDeploy}+ onCheckedChange={(checked) =>+ setFormData((prev) => ({ ...prev, autoDeploy: checked }))+ }+ />+ </div>++ <div className="git-connect__actions">+ <Button type="submit" disabled={loading}>+ <GitBranch size={14} />+ {loading ? 'Connecting...' : submitLabel}+ </Button>+ </div>+ </form>+ );+};++export default RepoConnectForm;diff --git a/frontend/src/components/wordpress/CommitList.jsx b/frontend/src/components/wordpress/CommitList.jsxindex d7a5f4b8..1de9cf89 100644--- a/frontend/src/components/wordpress/CommitList.jsx+++ b/frontend/src/components/wordpress/CommitList.jsx@@ -1,11 +1,24 @@import React, { useState } from 'react';-import { GitCommit, Rocket, Copy, CheckCircle } from 'lucide-react';+import { GitCommit, Rocket, Copy, CheckCircle, ExternalLink } from 'lucide-react';import Modal from '../Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';--const CommitList = ({ commits, currentCommit, onDeploy, onCreateDev, loading = false }) => {+import { detectProvider } from '../git/GitProviders';++// Build a web URL to a commit on the host from the clone URL + sha so the log is+// clickable. Handles https + scp-style ssh remotes and Bitbucket's /commits path.+function commitUrl(repoUrl, sha) {+ if (!repoUrl || !sha) return null;+ let base = repoUrl.trim().replace(/\.git$/i, '');+ const ssh = base.match(/^git@([^:]+):(.+)$/);+ if (ssh) base = `https://${ssh[1]}/${ssh[2]}`;+ if (!/^https?:\/\//i.test(base)) return null;+ const seg = detectProvider(repoUrl)?.key === 'bitbucket' ? 'commits' : 'commit';+ return `${base}/${seg}/${sha}`;+}++const CommitList = ({ commits, currentCommit, onDeploy, onCreateDev, loading = false, repoUrl }) => {const [actionLoading, setActionLoading] = useState({});const [showDevModal, setShowDevModal] = useState(null);@@ -80,7 +93,20 @@ const CommitList = ({ commits, currentCommit, onDeploy, onCreateDev, loading = f<div className="commit-info"><div className="commit-header">- <span className="commit-sha mono">{commit.sha.substring(0, 7)}</span>+ {commitUrl(repoUrl, commit.sha) ? (+ <a+ className="commit-sha mono commit-sha--link"+ href={commitUrl(repoUrl, commit.sha)}+ target="_blank"+ rel="noopener noreferrer"+ title="View this commit on the remote"+ >+ {commit.sha.substring(0, 7)}+ <ExternalLink size={11} />+ </a>+ ) : (+ <span className="commit-sha mono">{commit.sha.substring(0, 7)}</span>+ )}{isCurrent && <span className="current-badge">Deployed</span>}<span className="commit-date">{formatDate(commit.date)}</span></div>@@ -151,7 +177,7 @@ const CreateDevModal = ({ commit, onClose, onCreate, loading }) => {Create a development environment with code from commit{' '}<code>{commit.sha.substring(0, 7)}</code></p>- <p className="commit-message-preview">"{commit.message}"</p>+ <p className="commit-message-preview">“{commit.message}”</p><form onSubmit={handleSubmit}><div className="form-group">diff --git a/frontend/src/components/wordpress/GitConnectForm.jsx b/frontend/src/components/wordpress/GitConnectForm.jsxindex b1c3b7b9..13f88d95 100644--- a/frontend/src/components/wordpress/GitConnectForm.jsx+++ b/frontend/src/components/wordpress/GitConnectForm.jsx@@ -1,198 +1,22 @@-import { useState } from 'react';-import { GitBranch, Unlink } from 'lucide-react';-import { Button } from '@/components/ui/button';-import { Input } from '@/components/ui/input';-import { Label } from '@/components/ui/label';-import { Textarea } from '@/components/ui/textarea';-import { Switch } from '@/components/ui/switch';-import { RepoProviderStrip, ProviderBadge, detectProvider } from '../git/GitProviders';--const GitConnectForm = ({ gitStatus, onConnect, onDisconnect }) => {- const [formData, setFormData] = useState({- repoUrl: '',- branch: 'main',- paths: ['wp-content/themes', 'wp-content/plugins'],- autoDeploy: false- });- const [loading, setLoading] = useState(false);- const [error, setError] = useState('');-- const isConnected = gitStatus?.connected;- const provider = detectProvider(formData.repoUrl);-- function handleChange(e) {- const { name, value } = e.target;- setFormData(prev => ({ ...prev, [name]: value }));- }-- function handlePathsChange(e) {- const paths = e.target.value.split('\n').filter(p => p.trim());- setFormData(prev => ({ ...prev, paths }));- }-- async function handleConnect(e) {- e.preventDefault();- setError('');- setLoading(true);-- try {- await onConnect({- repo_url: formData.repoUrl,- branch: formData.branch,- paths: formData.paths,- auto_deploy: formData.autoDeploy- });- } catch (err) {- setError(err.message || 'Failed to connect repository');- } finally {- setLoading(false);- }- }-- async function handleDisconnect() {- if (!confirm('Disconnect Git repository? This will not delete any files.')) {- return;- }- setLoading(true);- try {- await onDisconnect();- } catch (err) {- setError(err.message || 'Failed to disconnect repository');- } finally {- setLoading(false);- }- }-- if (isConnected) {- return (- <div className="git-connect-status">- <div className="git-connect-status__header">- <span className="git-connect-status__icon">- <GitBranch size={19} />- </span>- <div className="git-connect-status__title">- <strong>Repository connected</strong>- <a- href={gitStatus.repo_url}- target="_blank"- rel="noopener noreferrer"- className="git-connect-status__url"- >- {gitStatus.repo_url}- </a>- </div>- </div>-- <div className="git-connect-status__meta">- <div className="git-connect-status__meta-item">- <span>Branch</span>- <strong>{gitStatus.branch}</strong>- </div>- <div className="git-connect-status__meta-item">- <span>Auto Deploy</span>- <strong>{gitStatus.auto_deploy ? 'Enabled' : 'Disabled'}</strong>- </div>- {gitStatus.last_deploy_commit && (- <div className="git-connect-status__meta-item">- <span>Last Deploy</span>- <strong className="mono">{gitStatus.last_deploy_commit.substring(0, 7)}</strong>- </div>- )}- {gitStatus.last_deploy_at && (- <div className="git-connect-status__meta-item">- <span>Deployed At</span>- <strong>{new Date(gitStatus.last_deploy_at).toLocaleString()}</strong>- </div>- )}- </div>-- <div className="git-connect-status__actions">- <Button variant="destructive" onClick={handleDisconnect} disabled={loading}>- <Unlink size={14} />- {loading ? 'Disconnecting...' : 'Disconnect'}- </Button>- </div>- </div>- );- }-- return (- <form className="git-connect git-connect--card" onSubmit={handleConnect}>- <div className="git-connect__intro">- <span className="git-connect__intro-icon">- <GitBranch size={19} />- </span>- <div className="git-connect__intro-text">- <strong>Connect a Git repository</strong>- <span>Manage themes and plugins for this site with version control — push to deploy.</span>- </div>- </div>-- <RepoProviderStrip detected={provider?.key} />-- {error && <div className="error-message">{error}</div>}-- <div className="git-connect__field">- <Label htmlFor="wp-repo-url">Repository URL</Label>- <Input- id="wp-repo-url"- type="text"- name="repoUrl"- value={formData.repoUrl}- onChange={handleChange}- placeholder="https://github.com/user/repo.git"- required- />- {provider && <ProviderBadge provider={provider} />}- </div>-- <div className="git-connect__field">- <Label htmlFor="wp-branch">Branch</Label>- <Input- id="wp-branch"- type="text"- name="branch"- value={formData.branch}- onChange={handleChange}- placeholder="main"- />- </div>-- <div className="git-connect__field">- <Label htmlFor="wp-paths">Tracked paths (one per line)</Label>- <Textarea- id="wp-paths"- value={formData.paths.join('\n')}- onChange={handlePathsChange}- placeholder={"wp-content/themes\nwp-content/plugins"}- rows={3}- />- <span className="git-connect__field-hint">- Paths relative to the WordPress root that should be tracked.- </span>- </div>-- <div className="git-connect__toggle">- <div>- <strong>Auto-deploy on push</strong>- <span>Automatically deploy when new commits land on this branch.</span>- </div>- <Switch- checked={formData.autoDeploy}- onCheckedChange={(checked) =>- setFormData(prev => ({ ...prev, autoDeploy: checked }))- }- />- </div>-- <div className="git-connect__actions">- <Button type="submit" disabled={loading}>- <GitBranch size={14} />- {loading ? 'Connecting...' : 'Connect Repository'}- </Button>- </div>- </form>- );-};+// WordPress-flavored wrapper over the shared RepoConnectForm: same form, just+// pre-dressed with the WordPress intro copy and the wp-content tracked-path+// defaults. The reusable component lives in components/git/RepoConnectForm.jsx.+import RepoConnectForm from '../git/RepoConnectForm';++const GitConnectForm = (props) => (+ <RepoConnectForm+ {...props}+ idPrefix="wp"+ intro={{+ title: 'Connect a Git repository',+ subtitle: 'Manage themes and plugins for this site with version control — push to deploy.',+ }}+ showPaths+ defaultPaths={['wp-content/themes', 'wp-content/plugins']}+ pathsLabel="Tracked paths (one per line)"+ pathsHint="Paths relative to the WordPress root that should be tracked."+ pathsPlaceholder={'wp-content/themes\nwp-content/plugins'}+ />+);export default GitConnectForm;diff --git a/frontend/src/pages/WordPressDetail.jsx b/frontend/src/pages/WordPressDetail.jsxindex 93ae79d0..1232614c 100644--- a/frontend/src/pages/WordPressDetail.jsx+++ b/frontend/src/pages/WordPressDetail.jsx@@ -3620,6 +3620,7 @@ const GitTab = ({ siteId, site, onUpdate }) => {currentCommit={site.last_deploy_commit}onDeploy={handleDeploy}onCreateDev={handleCreateDev}+ repoUrl={gitStatus?.repo_url}/></div>)}diff --git a/frontend/src/styles/pages/_new-service.scss b/frontend/src/styles/pages/_new-service.scssindex e73858f4..2ea2babd 100644--- a/frontend/src/styles/pages/_new-service.scss+++ b/frontend/src/styles/pages/_new-service.scss@@ -115,10 +115,19 @@line-height: 1.45;}+ // Icon tiles: grid + place-items is the most reliable centering (no inline+ // baseline/descender offset that inline-flex leaves behind), and a block SVG+ // drops the phantom inline gap — that's what left the glyphs off-center.&__method-icon,- &__provider-title svg,&__connect-icon,&__deploy-icon {+ display: grid;+ place-items: center;+ flex-shrink: 0;++ svg { display: block; }+ }+ &__provider-title svg {display: inline-flex;align-items: center;justify-content: center;diff --git a/frontend/src/styles/pages/_wordpress.scss b/frontend/src/styles/pages/_wordpress.scssindex 9d8e7d86..d1760ca1 100644--- a/frontend/src/styles/pages/_wordpress.scss+++ b/frontend/src/styles/pages/_wordpress.scss@@ -1310,6 +1310,17 @@padding: 2px 7px;border-radius: 5px;}+ // Clickable SHA → the commit on the remote host.+ a.commit-sha--link {+ display: inline-flex;+ align-items: center;+ gap: 4px;+ text-decoration: none;+ transition: background 0.14s;++ svg { opacity: 0.6; }+ &:hover { background: var(--accent-bg-soft); text-decoration: underline; svg { opacity: 1; } }+ }.current-badge {font-family: var(--mono);