import React, { useState } from 'react'; import { GitBranch, Link, Unlink } from 'lucide-react'; 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; function handleChange(e) { const { name, value, type, checked } = e.target; setFormData(prev => ({ ...prev, [name]: type === 'checkbox' ? checked : 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 (

Repository Connected

{gitStatus.repo_url}
Branch {gitStatus.branch}
Auto Deploy {gitStatus.auto_deploy ? 'Enabled' : 'Disabled'}
{gitStatus.last_deploy_commit && (
Last Deploy {gitStatus.last_deploy_commit.substring(0, 7)}
)} {gitStatus.last_deploy_at && (
Deployed At {new Date(gitStatus.last_deploy_at).toLocaleString()}
)}
); } return (

Connect Git Repository

Connect a Git repository to manage themes and plugins via version control.

{error &&
{error}
}