plugin distribution system

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-09 21:38:14 +00:00
parent cf8181d1f9
commit 80f1709a2e
22 changed files with 2804 additions and 35 deletions

View File

@@ -22,7 +22,8 @@ import {
TrashBinIcon,
GlobeIcon,
KeyIcon,
RefreshCwIcon
RefreshCwIcon,
InfoIcon
} from '../../icons';
interface WordPressIntegrationFormProps {
@@ -45,6 +46,8 @@ export default function WordPressIntegrationForm({
const [generatingKey, setGeneratingKey] = useState(false);
const [apiKey, setApiKey] = useState<string>('');
const [apiKeyVisible, setApiKeyVisible] = useState(false);
const [pluginInfo, setPluginInfo] = useState<any>(null);
const [loadingPlugin, setLoadingPlugin] = useState(false);
// Load API key from integration on mount or when integration changes
useEffect(() => {
@@ -55,6 +58,23 @@ export default function WordPressIntegrationForm({
}
}, [integration]);
// Fetch plugin information
useEffect(() => {
const fetchPluginInfo = async () => {
try {
setLoadingPlugin(true);
const response = await fetchAPI('/plugins/wordpress/latest/');
setPluginInfo(response);
} catch (error) {
console.error('Failed to fetch plugin info:', error);
} finally {
setLoadingPlugin(false);
}
};
fetchPluginInfo();
}, []);
const handleGenerateApiKey = async () => {
try {
setGeneratingKey(true);
@@ -151,7 +171,8 @@ export default function WordPressIntegrationForm({
};
const handleDownloadPlugin = () => {
const pluginUrl = `https://github.com/igny8/igny8-wp-bridge/releases/latest/download/igny8-wp-bridge.zip`;
// Use the backend API endpoint for plugin download
const pluginUrl = `/api/plugins/igny8-wp-bridge/download/`;
window.open(pluginUrl, '_blank');
toast.success('Plugin download started');
};
@@ -371,23 +392,93 @@ export default function WordPressIntegrationForm({
{/* Plugin Download Section */}
{apiKey && (
<Card className="p-6">
<div className="flex items-center justify-between">
<div>
<h3 className="text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2">
<DownloadIcon className="w-5 h-5 text-purple-600 dark:text-purple-400" />
IGNY8 WP Bridge Plugin
</h3>
<p className="text-sm text-gray-600 dark:text-gray-400 mt-1">
Download and install the plugin on your WordPress site
</p>
<div className="space-y-4">
<div className="flex items-start justify-between">
<div className="flex-1">
<h3 className="text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2">
<DownloadIcon className="w-5 h-5 text-purple-600 dark:text-purple-400" />
IGNY8 WP Bridge Plugin
</h3>
<p className="text-sm text-gray-600 dark:text-gray-400 mt-1">
Download and install the plugin on your WordPress site
</p>
</div>
<Button
onClick={handleDownloadPlugin}
variant="solid"
startIcon={<DownloadIcon className="w-4 h-4" />}
disabled={loadingPlugin}
>
Download Plugin
</Button>
</div>
<Button
onClick={handleDownloadPlugin}
variant="solid"
startIcon={<DownloadIcon className="w-4 h-4" />}
>
Download Plugin
</Button>
{/* Plugin Details */}
{pluginInfo && (
<div className="border-t border-gray-200 dark:border-gray-700 pt-4">
<div className="grid grid-cols-2 gap-4">
<div>
<p className="text-xs text-gray-500 dark:text-gray-400 mb-1">Version</p>
<p className="text-sm font-medium text-gray-900 dark:text-white">
{pluginInfo.version}
</p>
</div>
<div>
<p className="text-xs text-gray-500 dark:text-gray-400 mb-1">File Size</p>
<p className="text-sm font-medium text-gray-900 dark:text-white">
{(pluginInfo.file_size / 1024).toFixed(1)} KB
</p>
</div>
<div>
<p className="text-xs text-gray-500 dark:text-gray-400 mb-1">WordPress Version</p>
<p className="text-sm font-medium text-gray-900 dark:text-white">
5.0+
</p>
</div>
<div>
<p className="text-xs text-gray-500 dark:text-gray-400 mb-1">PHP Version</p>
<p className="text-sm font-medium text-gray-900 dark:text-white">
7.4+
</p>
</div>
</div>
{/* Requirements & Instructions */}
<div className="mt-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg">
<div className="flex items-start gap-2">
<InfoIcon className="w-4 h-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0" />
<div className="flex-1">
<p className="text-xs font-medium text-blue-900 dark:text-blue-300 mb-1">
Installation Steps
</p>
<ol className="text-xs text-blue-800 dark:text-blue-400 space-y-1 list-decimal list-inside">
<li>Download the plugin ZIP file</li>
<li>Go to your WordPress admin Plugins Add New</li>
<li>Click "Upload Plugin" and select the ZIP file</li>
<li>Activate the plugin after installation</li>
<li>Configure plugin with your API key from above</li>
</ol>
</div>
</div>
</div>
{/* Changelog */}
{pluginInfo.changelog && (
<div className="mt-3 text-xs text-gray-600 dark:text-gray-400">
<p className="font-medium text-gray-900 dark:text-white mb-1">What's New:</p>
<p className="whitespace-pre-line">{pluginInfo.changelog}</p>
</div>
)}
</div>
)}
{loadingPlugin && (
<div className="border-t border-gray-200 dark:border-gray-700 pt-4">
<p className="text-sm text-gray-500 dark:text-gray-400 text-center">
Loading plugin information...
</p>
</div>
)}
</div>
</Card>
)}