mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-02 05:05:12 +09:00
cutover(cloudflare-ops): the last in-place flagship leaves the tree (plan 52 Phase 2)
builtin-extensions/serverkit-cloudflare-ops + the tracked frontend live copy removed; FLAGSHIP_SLUGS is now empty (machinery kept); plugins-manifest.json empties; the bundled registry entry flips to bundled:false with the local zip's sha256. cloudflare_ops_bridge resolves the copy-installed package FIRST so a registry install works without the builtin registration path. Tests: new conftest.mount_sibling_extension mirrors a real install from the sibling checkout (the _wp_support.ensure_plugin analogue) and a cf_extension fixture forces a private app; the zone-settings and round2 suites mount it autouse (74/74 green), the extraction suite pins the lean-panel shape, and the flagship-era onboarding tests prove the machinery with a fabricated member instead. OPERATOR: publish jhd3197/serverkit-cloudflare-ops, sign, sync-registry-index.sh. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
43fec8030c
commit
665d6775e4
31 files changed
+129
-6973
No files matched your search
@@ -1,12 +1,3 @@
|
||||
{
|
||||
"plugins": [
|
||||
{
|
||||
"name": "serverkit-cloudflare-ops",
|
||||
"slug": "serverkit-cloudflare-ops",
|
||||
"display_name": "Cloudflare Zone Ops",
|
||||
"version": "1.0.0",
|
||||
"frontend_entry": "",
|
||||
"path": "serverkit-cloudflare-ops"
|
||||
}
|
||||
]
|
||||
"plugins": []
|
||||
}
|
||||
@@ -1,335 +0,0 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { ShieldAlert } from 'lucide-react';
|
||||
import api from '../services/cloudflare';
|
||||
import {
|
||||
Button, Input, Textarea, Switch, Badge,
|
||||
Select, SelectTrigger, SelectContent, SelectItem, SelectValue,
|
||||
EmptyState, useToast,
|
||||
} from 'serverkit-sdk';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const ACTION_OPTIONS = [
|
||||
{ value: 'block', labelKey: 'app.cloudflareWafPanel.block', label: 'Block' },
|
||||
{ value: 'managed_challenge', labelKey: 'app.cloudflareWafPanel.managedChallenge', label: 'Managed Challenge' },
|
||||
{ value: 'js_challenge', labelKey: 'app.cloudflareWafPanel.jsChallenge', label: 'JS Challenge' },
|
||||
{ value: 'log', labelKey: 'app.cloudflareWafPanel.log', label: 'Log' },
|
||||
];
|
||||
|
||||
const EXPRESSION_PLACEHOLDER = '(http.request.uri.path contains "/admin")';
|
||||
|
||||
export default function CloudflareWafPanel({ zoneId, isAdmin }) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
const [rulesetId, setRulesetId] = useState(null);
|
||||
const [rules, setRules] = useState([]);
|
||||
const [presets, setPresets] = useState([]);
|
||||
|
||||
// Preset form state
|
||||
const [selectedPreset, setSelectedPreset] = useState('');
|
||||
const [presetParams, setPresetParams] = useState({});
|
||||
|
||||
// Custom rule form state
|
||||
const [customDescription, setCustomDescription] = useState('');
|
||||
const [customExpression, setCustomExpression] = useState('');
|
||||
const [customAction, setCustomAction] = useState('block');
|
||||
|
||||
// Tracks any in-flight write so buttons can disable
|
||||
const [applying, setApplying] = useState(false);
|
||||
|
||||
const loadRules = useCallback(async () => {
|
||||
try {
|
||||
const data = await api.getCloudflareWafRules(zoneId);
|
||||
setRulesetId(data.ruleset_id ?? null);
|
||||
setRules(data.rules || []);
|
||||
setPresets(data.presets || []);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}, [zoneId]);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
setLoading(true);
|
||||
(async () => {
|
||||
try {
|
||||
const data = await api.getCloudflareWafRules(zoneId);
|
||||
if (!active) return;
|
||||
setRulesetId(data.ruleset_id ?? null);
|
||||
setRules(data.rules || []);
|
||||
setPresets(data.presets || []);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
if (active) setError(err.message);
|
||||
} finally {
|
||||
if (active) setLoading(false);
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [zoneId]);
|
||||
|
||||
const activePreset = presets.find((p) => p.key === selectedPreset) || null;
|
||||
const presetParamDefs = activePreset?.params || [];
|
||||
|
||||
const handleSelectPreset = (key) => {
|
||||
setSelectedPreset(key);
|
||||
setPresetParams({});
|
||||
};
|
||||
|
||||
const handleParamChange = (key, value) => {
|
||||
setPresetParams((prev) => ({ ...prev, [key]: value }));
|
||||
};
|
||||
|
||||
const handleApplyPreset = async () => {
|
||||
if (!activePreset) return;
|
||||
setApplying(true);
|
||||
try {
|
||||
await api.applyCloudflareWafPreset(zoneId, activePreset.key, presetParams);
|
||||
await loadRules();
|
||||
setPresetParams({});
|
||||
toast.success(t('app.cloudflareWafPanel.addedQuickRule', 'Added quick rule: {{label}}', { label: activePreset.label }));
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setApplying(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddCustomRule = async () => {
|
||||
setApplying(true);
|
||||
try {
|
||||
await api.addCloudflareWafRule(zoneId, {
|
||||
description: customDescription,
|
||||
expression: customExpression,
|
||||
action: customAction,
|
||||
enabled: true,
|
||||
});
|
||||
await loadRules();
|
||||
setCustomDescription('');
|
||||
setCustomExpression('');
|
||||
setCustomAction('block');
|
||||
toast.success(t('app.cloudflareWafPanel.customRuleAdded', 'Custom rule added'));
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setApplying(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleRule = async (rule) => {
|
||||
setApplying(true);
|
||||
try {
|
||||
await api.updateCloudflareWafRule(zoneId, rulesetId, rule.id, {
|
||||
enabled: !rule.enabled,
|
||||
});
|
||||
await loadRules();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setApplying(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteRule = async (rule) => {
|
||||
setApplying(true);
|
||||
try {
|
||||
await api.deleteCloudflareWafRule(zoneId, rulesetId, rule.id);
|
||||
await loadRules();
|
||||
toast.success(t('app.cloudflareWafPanel.ruleDeleted', 'Rule deleted'));
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setApplying(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <div className="cf-waf__loading">{t('app.cloudflareWafPanel.loadingFirewallRules', 'Loading firewall rules…')}</div>;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<EmptyState
|
||||
icon={ShieldAlert}
|
||||
title={t('app.cloudflareWafPanel.firewallRulesUnavailable', 'Firewall rules unavailable')}
|
||||
description={error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const writeDisabled = !isAdmin || applying;
|
||||
|
||||
return (
|
||||
<div className="cf-waf">
|
||||
{/* Presets / quick rules */}
|
||||
<section className="cf-waf__section">
|
||||
<h3 className="cf-waf__heading">{t('app.cloudflareWafPanel.quickRules', 'Quick rules')}</h3>
|
||||
<p className="cf-waf__hint">
|
||||
{t('app.cloudflareWafPanel.applyACuratedCloudflareRuleWithout', 'Apply a curated Cloudflare rule without writing an expression by hand.')}
|
||||
</p>
|
||||
|
||||
<div className="cf-waf__field">
|
||||
<Select
|
||||
value={selectedPreset}
|
||||
onValueChange={handleSelectPreset}
|
||||
disabled={writeDisabled}
|
||||
>
|
||||
<SelectTrigger className="cf-waf__select">
|
||||
<SelectValue placeholder={t('app.cloudflareWafPanel.chooseAQuickRule', 'Choose a quick rule…')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{presets.map((preset) => (
|
||||
<SelectItem key={preset.key} value={preset.key}>
|
||||
{preset.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{activePreset && (
|
||||
<p className="cf-waf__preset-desc">{activePreset.description}</p>
|
||||
)}
|
||||
|
||||
{presetParamDefs.length > 0 && (
|
||||
<div className="cf-waf__params">
|
||||
{presetParamDefs.map((param) => (
|
||||
<div className="cf-waf__field" key={param.key}>
|
||||
<label className="cf-waf__label">{param.label}</label>
|
||||
<Input
|
||||
value={presetParams[param.key] || ''}
|
||||
placeholder={param.placeholder}
|
||||
onChange={(e) => handleParamChange(param.key, e.target.value)}
|
||||
disabled={writeDisabled}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="cf-waf__actions">
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleApplyPreset}
|
||||
disabled={writeDisabled || !activePreset}
|
||||
>
|
||||
{t('app.cloudflareWafPanel.addRule', 'Add rule')}
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Custom rule */}
|
||||
<section className="cf-waf__section">
|
||||
<h3 className="cf-waf__heading">{t('app.cloudflareWafPanel.customRule', 'Custom rule')}</h3>
|
||||
<p className="cf-waf__hint">
|
||||
{t('app.cloudflareWafPanel.writeYourOwnCloudflareFirewallExpression', 'Write your own Cloudflare firewall expression for full control.')}
|
||||
</p>
|
||||
|
||||
<div className="cf-waf__field">
|
||||
<label className="cf-waf__label">{t('common.labels.description', 'Description')}</label>
|
||||
<Input
|
||||
value={customDescription}
|
||||
placeholder={t('app.cloudflareWafPanel.blockAdminFromOutsideTheOffice', 'Block admin from outside the office')}
|
||||
onChange={(e) => setCustomDescription(e.target.value)}
|
||||
disabled={writeDisabled}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="cf-waf__field">
|
||||
<label className="cf-waf__label">{t('app.cloudflareWafPanel.expression', 'Expression')}</label>
|
||||
<Textarea
|
||||
rows={3}
|
||||
value={customExpression}
|
||||
placeholder={EXPRESSION_PLACEHOLDER}
|
||||
onChange={(e) => setCustomExpression(e.target.value)}
|
||||
disabled={writeDisabled}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="cf-waf__field">
|
||||
<label className="cf-waf__label">{t('common.labels.action', 'Action')}</label>
|
||||
<Select
|
||||
value={customAction}
|
||||
onValueChange={setCustomAction}
|
||||
disabled={writeDisabled}
|
||||
>
|
||||
<SelectTrigger className="cf-waf__select">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{ACTION_OPTIONS.map((opt) => (
|
||||
<SelectItem key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="cf-waf__actions">
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleAddCustomRule}
|
||||
disabled={writeDisabled || !customExpression.trim()}
|
||||
>
|
||||
{t('app.cloudflareWafPanel.addCustomRule', 'Add custom rule')}
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Active rules list */}
|
||||
<section className="cf-waf__section">
|
||||
<h3 className="cf-waf__heading">{t('app.cloudflareWafPanel.activeRules', 'Active rules (')}{rules.length})</h3>
|
||||
|
||||
{rules.length === 0 ? (
|
||||
<EmptyState
|
||||
icon={ShieldAlert}
|
||||
title={t('app.cloudflareWafPanel.noCustomFirewallRules', 'No custom firewall rules')}
|
||||
description={t('app.cloudflareWafPanel.addAQuickRuleOrA', 'Add a quick rule or a custom rule above.')}
|
||||
/>
|
||||
) : (
|
||||
<ul className="cf-waf__list">
|
||||
{rules.map((rule) => (
|
||||
<li className="cf-waf__rule" key={rule.id}>
|
||||
<div className="cf-waf__rule-main">
|
||||
<div className="cf-waf__rule-head">
|
||||
<Badge
|
||||
variant={rule.action === 'block' ? 'destructive' : 'secondary'}
|
||||
>
|
||||
{rule.action}
|
||||
</Badge>
|
||||
<span className="cf-waf__rule-desc">
|
||||
{rule.description || 'Untitled rule'}
|
||||
</span>
|
||||
</div>
|
||||
<code className="cf-waf__rule-expr">{rule.expression}</code>
|
||||
</div>
|
||||
|
||||
<div className="cf-waf__rule-actions">
|
||||
<Switch
|
||||
checked={rule.enabled}
|
||||
onCheckedChange={() => handleToggleRule(rule)}
|
||||
disabled={writeDisabled}
|
||||
/>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => handleDeleteRule(rule)}
|
||||
disabled={writeDisabled}
|
||||
>
|
||||
{t('common.actions.delete', 'Delete')}
|
||||
</Button>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { HardDrive } from 'lucide-react';
|
||||
import api from '../services/cloudflare';
|
||||
import { Button, Input, EmptyState, useToast } from 'serverkit-sdk';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
function StorageSection({
|
||||
title,
|
||||
items,
|
||||
error,
|
||||
placeholder,
|
||||
hint,
|
||||
renderItem,
|
||||
onCreate,
|
||||
onDelete,
|
||||
isAdmin,
|
||||
busy,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [value, setValue] = useState('');
|
||||
|
||||
const writeDisabled = !isAdmin || busy;
|
||||
|
||||
const handleCreate = async () => {
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed) return;
|
||||
// Only clear the input when the create succeeds; a throw leaves the text intact.
|
||||
await onCreate(trimmed);
|
||||
setValue('');
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="cf-storage__section">
|
||||
<h3 className="cf-storage__heading">
|
||||
{title} ({error ? 0 : items.length})
|
||||
</h3>
|
||||
|
||||
{hint && <p className="cf-storage__hint">{hint}</p>}
|
||||
|
||||
{error ? (
|
||||
<p className="cf-storage__error">{error}</p>
|
||||
) : (
|
||||
<>
|
||||
<div className="cf-storage__create">
|
||||
<Input
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
disabled={writeDisabled}
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleCreate}
|
||||
disabled={writeDisabled || !value.trim()}
|
||||
>
|
||||
{t('common.actions.add', 'Add')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{items.length === 0 ? (
|
||||
<p className="cf-storage__hint">{`No ${title.toLowerCase()} yet.`}</p>
|
||||
) : (
|
||||
<ul className="cf-storage__list">
|
||||
{items.map((item) => {
|
||||
const { key, label } = renderItem(item);
|
||||
return (
|
||||
<li className="cf-storage__item" key={key}>
|
||||
<code className="cf-storage__name">{label}</code>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => onDelete(item)}
|
||||
disabled={writeDisabled}
|
||||
>
|
||||
{t('common.actions.delete', 'Delete')}
|
||||
</Button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export default function StoragePanel({ zoneId, isAdmin }) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
const [data, setData] = useState(null);
|
||||
|
||||
// Tracks any in-flight write so all write controls can disable
|
||||
const [working, setWorking] = useState(false);
|
||||
|
||||
const loadData = useCallback(async () => {
|
||||
try {
|
||||
const res = await api.getCloudflareStorage(zoneId);
|
||||
setData(res);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}, [zoneId]);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
setLoading(true);
|
||||
(async () => {
|
||||
try {
|
||||
const res = await api.getCloudflareStorage(zoneId);
|
||||
if (!active) return;
|
||||
setData(res);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
if (active) setError(err.message);
|
||||
} finally {
|
||||
if (active) setLoading(false);
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [zoneId]);
|
||||
|
||||
const handleCreateR2 = async (name) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.createCloudflareR2Bucket(zoneId, name);
|
||||
toast.success(t('app.storagePanel.createdBucket', 'Created bucket "{{name}}"', { name: name }));
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
throw err;
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteR2 = async (bucket) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.deleteCloudflareR2Bucket(zoneId, bucket.name);
|
||||
toast.success(t('app.storagePanel.deleted', 'Deleted'));
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreateKv = async (title) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.createCloudflareKvNamespace(zoneId, title);
|
||||
toast.success(t('app.storagePanel.createdNamespace', 'Created namespace "{{title}}"', { title: title }));
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
throw err;
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteKv = async (namespace) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.deleteCloudflareKvNamespace(zoneId, namespace.id);
|
||||
toast.success(t('app.storagePanel.deleted', 'Deleted'));
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreateD1 = async (name) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.createCloudflareD1Database(zoneId, name);
|
||||
toast.success(t('app.storagePanel.createdDatabase', 'Created database "{{name}}"', { name: name }));
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
throw err;
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteD1 = async (database) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.deleteCloudflareD1Database(zoneId, database.uuid);
|
||||
toast.success(t('app.storagePanel.deleted', 'Deleted'));
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <div className="cf-storage__loading">{t('app.storagePanel.loadingStorage', 'Loading storage…')}</div>;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<EmptyState
|
||||
icon={HardDrive}
|
||||
title={t('app.storagePanel.storageUnavailable', 'Storage unavailable')}
|
||||
description={error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const errors = data.errors || {};
|
||||
|
||||
return (
|
||||
<div className="cf-storage">
|
||||
<StorageSection
|
||||
title={t('app.storagePanel.r2Buckets', 'R2 buckets')}
|
||||
items={data.r2 || []}
|
||||
error={errors.r2}
|
||||
placeholder="my-bucket"
|
||||
hint={t('app.storagePanel.r2IsS3CompatibleSoA', 'R2 is S3-compatible, so a bucket here can back ServerKit backups later.')}
|
||||
renderItem={(b) => ({ key: b.name, label: b.name })}
|
||||
onCreate={handleCreateR2}
|
||||
onDelete={handleDeleteR2}
|
||||
isAdmin={isAdmin}
|
||||
busy={working}
|
||||
/>
|
||||
|
||||
<StorageSection
|
||||
title={t('app.storagePanel.kvNamespaces', 'KV namespaces')}
|
||||
items={data.kv || []}
|
||||
error={errors.kv}
|
||||
placeholder="my-namespace"
|
||||
renderItem={(n) => ({ key: n.id, label: n.title })}
|
||||
onCreate={handleCreateKv}
|
||||
onDelete={handleDeleteKv}
|
||||
isAdmin={isAdmin}
|
||||
busy={working}
|
||||
/>
|
||||
|
||||
<StorageSection
|
||||
title={t('app.storagePanel.d1Databases', 'D1 databases')}
|
||||
items={data.d1 || []}
|
||||
error={errors.d1}
|
||||
placeholder="my-database"
|
||||
renderItem={(d) => ({ key: d.uuid, label: d.name })}
|
||||
onCreate={handleCreateD1}
|
||||
onDelete={handleDeleteD1}
|
||||
isAdmin={isAdmin}
|
||||
busy={working}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,362 +0,0 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { Network } from 'lucide-react';
|
||||
import api from '../services/cloudflare';
|
||||
import { Button, Input, Badge, EmptyState, useToast, copyToClipboard } from 'serverkit-sdk';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
function InstallBox({ command }) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
|
||||
if (!command) {
|
||||
return <p className="cf-tunnels__hint">{t('app.tunnelsPanel.noInstallCommandAvailable', 'No install command available.')}</p>;
|
||||
}
|
||||
|
||||
const handleCopy = async () => {
|
||||
if (await copyToClipboard(command)) toast.success(t('app.tunnelsPanel.copied', 'Copied'));
|
||||
else toast.error(t('app.tunnelsPanel.couldNotCopyTheInstallCommand', 'Could not copy the install command'));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="cf-tunnels__install">
|
||||
<code className="cf-tunnels__cmd">{command}</code>
|
||||
<Button size="sm" variant="outline" onClick={handleCopy}>
|
||||
{t('common.actions.copy', 'Copy')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TunnelRow({ zoneId, tunnel, isAdmin, onChanged }) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
|
||||
const [install, setInstall] = useState(null);
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const [hostnames, setHostnames] = useState([]);
|
||||
const [hostname, setHostname] = useState('');
|
||||
const [service, setService] = useState('');
|
||||
const [working, setWorking] = useState(false);
|
||||
|
||||
const loadHostnames = useCallback(async () => {
|
||||
try {
|
||||
const res = await api.getCloudflareTunnelHostnames(zoneId, tunnel.id);
|
||||
setHostnames(res.hostnames || []);
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
}
|
||||
}, [zoneId, tunnel.id, toast]);
|
||||
|
||||
const handleToggleInstall = async () => {
|
||||
if (install) {
|
||||
setInstall(null);
|
||||
return;
|
||||
}
|
||||
setWorking(true);
|
||||
try {
|
||||
const res = await api.getCloudflareTunnelInstall(zoneId, tunnel.id);
|
||||
setInstall(res.install || null);
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleHostnames = async () => {
|
||||
const next = !expanded;
|
||||
setExpanded(next);
|
||||
if (next && hostnames.length === 0) {
|
||||
await loadHostnames();
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.deleteCloudflareTunnel(zoneId, tunnel.id);
|
||||
toast.success(t('app.tunnelsPanel.deletedCloudflareTunnel', 'Deleted Cloudflare Tunnel "{{name}}"', { name: tunnel.name }));
|
||||
onChanged();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveHostname = async (h) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.removeCloudflareTunnelHostname(zoneId, tunnel.id, h.hostname);
|
||||
toast.success(t('app.tunnelsPanel.hostnameRemoved', 'Hostname removed'));
|
||||
await loadHostnames();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddHostname = async () => {
|
||||
setWorking(true);
|
||||
try {
|
||||
const res = await api.addCloudflareTunnelHostname(
|
||||
zoneId,
|
||||
tunnel.id,
|
||||
hostname,
|
||||
service,
|
||||
);
|
||||
toast.success(t('app.tunnelsPanel.hostnameRouted', 'Hostname routed'));
|
||||
if (res.dns && !res.dns.created) {
|
||||
toast.error(t('app.tunnelsPanel.routeSetButTheDnsRecord', 'Route set, but the DNS record failed: ') + res.dns.error);
|
||||
}
|
||||
setHostname('');
|
||||
setService('');
|
||||
await loadHostnames();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const writeDisabled = !isAdmin || working;
|
||||
|
||||
return (
|
||||
<li className="cf-tunnels__item">
|
||||
<div className="cf-tunnels__item-head">
|
||||
<span className="cf-tunnels__name">{tunnel.name}</span>
|
||||
<code className="cf-tunnels__meta">{tunnel.id.slice(0, 12)}…</code>
|
||||
{tunnel.status && (
|
||||
<span className="cf-tunnels__meta">{tunnel.status}</span>
|
||||
)}
|
||||
{tunnel.connections != null && (
|
||||
<span className="cf-tunnels__meta">{tunnel.connections}</span>
|
||||
)}
|
||||
{tunnel.managed && <Badge variant="secondary">{t('common.labels.serverKit', 'ServerKit')}</Badge>}
|
||||
</div>
|
||||
|
||||
<div className="cf-tunnels__item-actions">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={handleToggleInstall}
|
||||
disabled={!isAdmin || working}
|
||||
>
|
||||
{t('app.tunnelsPanel.installCommand', 'Install command')}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={handleToggleHostnames}
|
||||
disabled={working}
|
||||
>
|
||||
{t('app.tunnelsPanel.hostnames', 'Hostnames')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={handleDelete}
|
||||
disabled={writeDisabled}
|
||||
>
|
||||
{t('common.actions.delete', 'Delete')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{install && <InstallBox command={install} />}
|
||||
|
||||
{expanded && (
|
||||
<div className="cf-tunnels__hostnames">
|
||||
{hostnames.length === 0 ? (
|
||||
<p className="cf-tunnels__hint">{t('app.tunnelsPanel.noPublicHostnamesRoutedYet', 'No public hostnames routed yet.')}</p>
|
||||
) : (
|
||||
hostnames.map((h) => (
|
||||
<div className="cf-tunnels__host" key={h.hostname}>
|
||||
<span>
|
||||
<code>{h.hostname}</code> → <code>{h.service}</code>
|
||||
</span>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => handleRemoveHostname(h)}
|
||||
disabled={writeDisabled}
|
||||
>
|
||||
{t('common.actions.remove', 'Remove')}
|
||||
</Button>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
|
||||
<div className="cf-tunnels__host-add">
|
||||
<Input
|
||||
value={hostname}
|
||||
placeholder="app.example.com"
|
||||
onChange={(e) => setHostname(e.target.value)}
|
||||
disabled={writeDisabled}
|
||||
/>
|
||||
<Input
|
||||
value={service}
|
||||
placeholder="http://localhost:8080"
|
||||
onChange={(e) => setService(e.target.value)}
|
||||
disabled={writeDisabled}
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleAddHostname}
|
||||
disabled={writeDisabled || !hostname.trim() || !service.trim()}
|
||||
>
|
||||
{t('common.actions.add', 'Add')}
|
||||
</Button>
|
||||
</div>
|
||||
<p className="cf-tunnels__hint">
|
||||
{t('app.tunnelsPanel.theHostnameShouldBeInsideThis', 'The hostname should be inside this zone\'s domain; a proxied DNS record is created automatically.')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TunnelsPanel({ zoneId, isAdmin }) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
const [tunnels, setTunnels] = useState([]);
|
||||
|
||||
// Create form state
|
||||
const [name, setName] = useState('');
|
||||
const [creating, setCreating] = useState(false);
|
||||
const [lastInstall, setLastInstall] = useState(null);
|
||||
|
||||
const loadData = useCallback(async () => {
|
||||
try {
|
||||
const data = await api.getCloudflareTunnels(zoneId);
|
||||
setTunnels(data.tunnels || []);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}, [zoneId]);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
setLoading(true);
|
||||
(async () => {
|
||||
try {
|
||||
const data = await api.getCloudflareTunnels(zoneId);
|
||||
if (!active) return;
|
||||
setTunnels(data.tunnels || []);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
if (active) setError(err.message);
|
||||
} finally {
|
||||
if (active) setLoading(false);
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [zoneId]);
|
||||
|
||||
const handleCreate = async () => {
|
||||
setCreating(true);
|
||||
try {
|
||||
const res = await api.createCloudflareTunnel(zoneId, name);
|
||||
toast.success(t('app.tunnelsPanel.createdTunnel', 'Created tunnel "{{name}}"', { name: name }));
|
||||
setLastInstall({ name, install: res.install, token: res.token });
|
||||
setName('');
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setCreating(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <div className="cf-tunnels__loading">{t('app.tunnelsPanel.loadingCloudflareTunnels', 'Loading Cloudflare Tunnels…')}</div>;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<EmptyState
|
||||
icon={Network}
|
||||
title={t('app.tunnelsPanel.cloudflareTunnelsUnavailable', 'Cloudflare Tunnels unavailable')}
|
||||
description={error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const createDisabled = !isAdmin || creating || !name.trim();
|
||||
|
||||
return (
|
||||
<div className="cf-tunnels">
|
||||
{/* Create a Cloudflare Tunnel */}
|
||||
<section className="cf-tunnels__section">
|
||||
<h3 className="cf-tunnels__heading">{t('app.tunnelsPanel.createACloudflareTunnel', 'Create a Cloudflare Tunnel')}</h3>
|
||||
<p className="cf-tunnels__hint">
|
||||
{t('app.tunnelsPanel.aCloudflareTunnelExposesALocal', 'A Cloudflare Tunnel exposes a local or private service through Cloudflare\'s edge — no public IP or open ports required.')}
|
||||
</p>
|
||||
|
||||
<div className="cf-tunnels__field">
|
||||
<label className="cf-tunnels__label">{t('common.labels.name', 'Name')}</label>
|
||||
<Input
|
||||
value={name}
|
||||
placeholder="home-jellyfin"
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
disabled={!isAdmin || creating}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="cf-tunnels__actions">
|
||||
<Button onClick={handleCreate} disabled={createDisabled}>
|
||||
{t('common.actions.create', 'Create')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{lastInstall && (
|
||||
<div className="cf-tunnels__install">
|
||||
<p className="cf-tunnels__hint">
|
||||
{t('app.tunnelsPanel.runThisOnceOnTheMachine', 'Run this once on the machine hosting your local service. The connector token is shown only now.')}
|
||||
</p>
|
||||
<InstallBox command={lastInstall.install} />
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => setLastInstall(null)}
|
||||
>
|
||||
{t('common.actions.dismiss', 'Dismiss')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* Cloudflare Tunnels list */}
|
||||
<section className="cf-tunnels__section">
|
||||
<h3 className="cf-tunnels__heading">{t('app.tunnelsPanel.cloudflareTunnels', 'Cloudflare Tunnels (')}{tunnels.length})</h3>
|
||||
|
||||
{tunnels.length === 0 ? (
|
||||
<EmptyState
|
||||
icon={Network}
|
||||
title={t('app.tunnelsPanel.noCloudflareTunnels', 'No Cloudflare Tunnels')}
|
||||
description={t('app.tunnelsPanel.createOneAboveToExposeA', 'Create one above to expose a local service without a public IP.')}
|
||||
/>
|
||||
) : (
|
||||
<ul className="cf-tunnels__list">
|
||||
{tunnels.map((tunnel) => (
|
||||
<TunnelRow
|
||||
key={tunnel.id}
|
||||
zoneId={zoneId}
|
||||
tunnel={tunnel}
|
||||
isAdmin={isAdmin}
|
||||
onChanged={loadData}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { Zap } from 'lucide-react';
|
||||
import api from '../services/cloudflare';
|
||||
import { Button, Input, Textarea, Badge, EmptyState, useToast } from 'serverkit-sdk';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const STARTER_SCRIPT = `export default {
|
||||
async fetch(request, env, ctx) {
|
||||
return new Response("Hello from ServerKit + Cloudflare Workers!", {
|
||||
headers: { "content-type": "text/plain" },
|
||||
});
|
||||
},
|
||||
};`;
|
||||
|
||||
export default function WorkersPanel({ zoneId, isAdmin }) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
const [workers, setWorkers] = useState([]);
|
||||
const [routes, setRoutes] = useState([]);
|
||||
|
||||
// Deploy form state
|
||||
const [name, setName] = useState('');
|
||||
const [code, setCode] = useState(STARTER_SCRIPT);
|
||||
const [routePattern, setRoutePattern] = useState('');
|
||||
|
||||
// Tracks any in-flight write so buttons can disable
|
||||
const [deploying, setDeploying] = useState(false);
|
||||
const [working, setWorking] = useState(false);
|
||||
|
||||
const loadData = useCallback(async () => {
|
||||
try {
|
||||
const data = await api.getCloudflareWorkers(zoneId);
|
||||
setWorkers(data.workers || []);
|
||||
setRoutes(data.routes || []);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}, [zoneId]);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
setLoading(true);
|
||||
(async () => {
|
||||
try {
|
||||
const data = await api.getCloudflareWorkers(zoneId);
|
||||
if (!active) return;
|
||||
setWorkers(data.workers || []);
|
||||
setRoutes(data.routes || []);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
if (active) setError(err.message);
|
||||
} finally {
|
||||
if (active) setLoading(false);
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [zoneId]);
|
||||
|
||||
const handleDeploy = async () => {
|
||||
setDeploying(true);
|
||||
try {
|
||||
const res = await api.deployCloudflareWorker(zoneId, {
|
||||
name,
|
||||
code,
|
||||
route_pattern: routePattern || undefined,
|
||||
});
|
||||
toast.success(t('app.workersPanel.deployedWorker', 'Deployed worker "{{name}}"', { name: name }));
|
||||
if (res.route && !res.route.success) {
|
||||
toast.error(t('app.workersPanel.workerDeployedButTheRouteFailed', 'Worker deployed, but the route failed: ') + res.route.error);
|
||||
}
|
||||
setName('');
|
||||
setRoutePattern('');
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setDeploying(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteWorker = async (worker) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.deleteCloudflareWorker(zoneId, worker.name);
|
||||
await loadData();
|
||||
toast.success(t('app.workersPanel.deletedWorker', 'Deleted worker "{{name}}"', { name: worker.name }));
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteRoute = async (route) => {
|
||||
setWorking(true);
|
||||
try {
|
||||
await api.deleteCloudflareWorkerRoute(zoneId, route.id);
|
||||
await loadData();
|
||||
toast.success(t('app.workersPanel.routeRemoved', 'Route removed'));
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
} finally {
|
||||
setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <div className="cf-workers__loading">{t('app.workersPanel.loadingWorkers', 'Loading workers…')}</div>;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<EmptyState
|
||||
icon={Zap}
|
||||
title={t('app.workersPanel.workersUnavailable', 'Workers unavailable')}
|
||||
description={error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const writeDisabled = !isAdmin || working;
|
||||
const deployDisabled = !isAdmin || deploying || !name.trim() || !code.trim();
|
||||
|
||||
return (
|
||||
<div className="cf-workers">
|
||||
{/* Deploy a Worker */}
|
||||
<section className="cf-workers__section">
|
||||
<h3 className="cf-workers__heading">{t('app.workersPanel.deployAWorker', 'Deploy a Worker')}</h3>
|
||||
|
||||
<div className="cf-workers__field">
|
||||
<label className="cf-workers__label">{t('common.labels.name', 'Name')}</label>
|
||||
<Input
|
||||
value={name}
|
||||
placeholder="my-worker"
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
disabled={!isAdmin || deploying}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="cf-workers__field">
|
||||
<label className="cf-workers__label">{t('app.workersPanel.code', 'Code')}</label>
|
||||
<Textarea
|
||||
rows={8}
|
||||
className="cf-workers__code"
|
||||
value={code}
|
||||
onChange={(e) => setCode(e.target.value)}
|
||||
disabled={!isAdmin || deploying}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="cf-workers__field">
|
||||
<label className="cf-workers__label">{t('app.workersPanel.routePatternOptional', 'Route pattern (optional)')}</label>
|
||||
<Input
|
||||
value={routePattern}
|
||||
placeholder="example.com/*"
|
||||
onChange={(e) => setRoutePattern(e.target.value)}
|
||||
disabled={!isAdmin || deploying}
|
||||
/>
|
||||
<p className="cf-workers__hint">
|
||||
{t('app.workersPanel.attachesTheWorkerToThisDomain', 'Attaches the worker to this domain so matching traffic runs the script.')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="cf-workers__actions">
|
||||
<Button onClick={handleDeploy} disabled={deployDisabled}>
|
||||
{t('app.workersPanel.deploy', 'Deploy')}
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Deployed workers */}
|
||||
<section className="cf-workers__section">
|
||||
<h3 className="cf-workers__heading">{t('app.workersPanel.workers', 'Workers (')}{workers.length})</h3>
|
||||
|
||||
{workers.length === 0 ? (
|
||||
<EmptyState
|
||||
icon={Zap}
|
||||
title={t('app.workersPanel.noWorkersDeployed', 'No Workers deployed')}
|
||||
description={t('app.workersPanel.deployYourFirstEdgeScriptAbove', 'Deploy your first edge script above.')}
|
||||
/>
|
||||
) : (
|
||||
<ul className="cf-workers__list">
|
||||
{workers.map((worker) => (
|
||||
<li className="cf-workers__item" key={worker.name}>
|
||||
<div className="cf-workers__name">
|
||||
<code>{worker.name}</code>
|
||||
{worker.managed && (
|
||||
<Badge variant="secondary">{t('common.labels.serverKit', 'ServerKit')}</Badge>
|
||||
)}
|
||||
{worker.modified_on && (
|
||||
<span className="cf-workers__meta">
|
||||
{new Date(worker.modified_on).toLocaleString()}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="cf-workers__item-actions">
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => handleDeleteWorker(worker)}
|
||||
disabled={writeDisabled}
|
||||
>
|
||||
{t('common.actions.delete', 'Delete')}
|
||||
</Button>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* Routes */}
|
||||
<section className="cf-workers__section">
|
||||
<h3 className="cf-workers__heading">{t('app.workersPanel.routes', 'Routes (')}{routes.length})</h3>
|
||||
|
||||
{routes.length === 0 ? (
|
||||
<p className="cf-workers__hint">
|
||||
{t('app.workersPanel.noRoutesYetAddARoute', 'No routes yet. Add a route pattern when deploying to send traffic to a worker.')}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="cf-workers__list">
|
||||
{routes.map((route) => (
|
||||
<li className="cf-workers__item" key={route.id}>
|
||||
<div className="cf-workers__name">
|
||||
<code>{route.pattern}</code>
|
||||
<span className="cf-workers__meta">→ {route.script}</span>
|
||||
</div>
|
||||
|
||||
<div className="cf-workers__item-actions">
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => handleDeleteRoute(route)}
|
||||
disabled={writeDisabled}
|
||||
>
|
||||
{t('common.actions.remove', 'Remove')}
|
||||
</Button>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// Cloudflare Zone Ops UI, contributed through the extension system. Both
|
||||
// halves live in this extension: the zone-ops backend (the /api/v1/cloudflare
|
||||
// blueprint + CloudflareService) under backend/, and the full page here
|
||||
// (pages/CloudflareZoneSettings.jsx + the WAF/Workers/Tunnels/Storage panels
|
||||
// + its own API client + SCSS). Imports go through 'serverkit-sdk' so the
|
||||
// same source works baked in-tree (the panel's build-time glob) and as a
|
||||
// runtime-ESM bundle once the extension leaves the tree (plan 52 Phase 2).
|
||||
//
|
||||
// DNS records and the Cloudflare connection itself stay core (they back
|
||||
// /domains) — this page only adds the per-zone control panel, reached from
|
||||
// the "Open in Cloudflare" button on a Cloudflare-managed domain.
|
||||
//
|
||||
// It's a single plain full-bleed route (cloudflare/zones/:zoneId, own
|
||||
// PageTopbar + internal Settings/WAF/Workers/Tunnels/Storage tabs), so no
|
||||
// tab-group shell or self-rendered sub-router is needed — unlike WordPress.
|
||||
import './styles/cloudflare-zone.scss';
|
||||
|
||||
import CloudflareZoneSettings from './pages/CloudflareZoneSettings';
|
||||
|
||||
export function CloudflareZoneSettingsPage() {
|
||||
return <CloudflareZoneSettings />;
|
||||
}
|
||||
|
||||
// No default export on purpose: PluginLoader legacy-auto-renders any plugin
|
||||
// default export globally (the page then runs with zoneId=undefined). The
|
||||
// route contribution resolves the NAMED export via resolveComponent.
|
||||
@@ -1,465 +0,0 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import { Cloud, ShieldCheck, Lock, Gauge, Database, Wand2, Eraser, Flame, Zap, Network, HardDrive } from 'lucide-react';
|
||||
import CloudflareWafPanel from '../components/CloudflareWafPanel';
|
||||
import WorkersPanel from '../components/WorkersPanel';
|
||||
import TunnelsPanel from '../components/TunnelsPanel';
|
||||
import StoragePanel from '../components/StoragePanel';
|
||||
import api from '../services/cloudflare';
|
||||
import {
|
||||
PageLayout, Tabs, TabsList, TabsTrigger, TabsContent, Switch, Button,
|
||||
Badge, Textarea, Select, SelectTrigger, SelectContent, SelectItem,
|
||||
SelectValue, PageLoader, EmptyState, ConfirmDialog, useToast, useAuth,
|
||||
} from 'serverkit-sdk';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
// HSTS max-age presets (seconds). 0 disables the max-age while keeping HSTS off.
|
||||
const HSTS_MAX_AGE = [
|
||||
{ value: 0, labelKey: 'app.cloudflareZoneSettings.off', label: 'Off' },
|
||||
{ value: 86400, labelKey: 'app.cloudflareZoneSettings.1Day', label: '1 day' },
|
||||
{ value: 604800, labelKey: 'app.cloudflareZoneSettings.1Week', label: '1 week' },
|
||||
{ value: 2592000, labelKey: 'app.cloudflareZoneSettings.1Month', label: '1 month' },
|
||||
{ value: 15552000, labelKey: 'app.cloudflareZoneSettings.6Months', label: '6 months' },
|
||||
{ value: 31536000, labelKey: 'app.cloudflareZoneSettings.1Year', label: '1 year' },
|
||||
{ value: 63072000, labelKey: 'app.cloudflareZoneSettings.2Years', label: '2 years' },
|
||||
];
|
||||
|
||||
const TAB_ICONS = {
|
||||
ssl: <Lock size={15} />,
|
||||
speed: <Gauge size={15} />,
|
||||
caching: <Database size={15} />,
|
||||
security: <ShieldCheck size={15} />,
|
||||
};
|
||||
|
||||
const CloudflareZoneSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const { zoneId } = useParams();
|
||||
const toast = useToast();
|
||||
const { user } = useAuth();
|
||||
const isAdmin = !!user?.is_admin;
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
const [zone, setZone] = useState(null);
|
||||
const [groups, setGroups] = useState([]);
|
||||
const [settings, setSettings] = useState({});
|
||||
const [saving, setSaving] = useState(null); // setting id in flight
|
||||
const [applying, setApplying] = useState(false);
|
||||
const [purgeUrls, setPurgeUrls] = useState('');
|
||||
const [purging, setPurging] = useState(false);
|
||||
const [confirmPurgeAll, setConfirmPurgeAll] = useState(false);
|
||||
|
||||
const loadSettings = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const data = await api.getCloudflareZoneSettings(zoneId);
|
||||
setZone(data.zone || null);
|
||||
setGroups(data.groups || []);
|
||||
setSettings(data.settings || {});
|
||||
} catch (err) {
|
||||
setError(err.message || 'Failed to load Cloudflare settings');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [zoneId]);
|
||||
|
||||
useEffect(() => { loadSettings(); }, [loadSettings]);
|
||||
|
||||
// Optimistically reflect the change, PATCH it, and reload truth on failure so
|
||||
// the UI never drifts from Cloudflare.
|
||||
const save = useCallback(async (settingId, value) => {
|
||||
setSaving(settingId);
|
||||
setSettings(prev => ({ ...prev, [settingId]: { ...(prev[settingId] || {}), value } }));
|
||||
try {
|
||||
await api.updateCloudflareZoneSetting(zoneId, settingId, value);
|
||||
toast.success(t('app.cloudflareZoneSettings.settingSaved', 'Setting saved'));
|
||||
} catch (err) {
|
||||
toast.error(err.message || t('app.cloudflareZoneSettings.failedToSaveSetting', 'Failed to save setting'));
|
||||
loadSettings();
|
||||
} finally {
|
||||
setSaving(null);
|
||||
}
|
||||
}, [zoneId, toast, loadSettings]);
|
||||
|
||||
const handleApplyPreset = async () => {
|
||||
setApplying(true);
|
||||
try {
|
||||
const res = await api.applyCloudflareSettingsPreset(zoneId);
|
||||
const failed = (res.results || []).filter(r => !r.success);
|
||||
if (failed.length === 0) {
|
||||
toast.success(t('app.cloudflareZoneSettings.appliedRecommendedHardeningSettings', 'Applied recommended hardening ({{applied}} settings)', { applied: res.applied }));
|
||||
} else {
|
||||
toast.info(t('app.cloudflareZoneSettings.appliedNeedAHigherCloudflarePlan', 'Applied {{applied}}/{{total}}. {{length}} need a higher Cloudflare plan.', { applied: res.applied, total: res.total, length: failed.length }));
|
||||
}
|
||||
loadSettings();
|
||||
} catch (err) {
|
||||
toast.error(err.message || t('app.cloudflareZoneSettings.failedToApplyPreset', 'Failed to apply preset'));
|
||||
} finally {
|
||||
setApplying(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handlePurgeEverything = async () => {
|
||||
setConfirmPurgeAll(false);
|
||||
setPurging(true);
|
||||
try {
|
||||
await api.purgeCloudflareCache(zoneId, { purge_everything: true });
|
||||
toast.success(t('app.cloudflareZoneSettings.purgedTheEntireCache', 'Purged the entire cache'));
|
||||
} catch (err) {
|
||||
toast.error(err.message || t('app.cloudflareZoneSettings.failedToPurgeCache', 'Failed to purge cache'));
|
||||
} finally {
|
||||
setPurging(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handlePurgeFiles = async () => {
|
||||
const files = purgeUrls.split('\n').map(u => u.trim()).filter(Boolean);
|
||||
if (files.length === 0) {
|
||||
toast.error(t('app.cloudflareZoneSettings.enterAtLeastOneUrlTo', 'Enter at least one URL to purge'));
|
||||
return;
|
||||
}
|
||||
setPurging(true);
|
||||
try {
|
||||
const res = await api.purgeCloudflareCache(zoneId, { files });
|
||||
const n = res.purged?.files?.length ?? files.length;
|
||||
toast.success(t('app.cloudflareZoneSettings.purgedUrlFromCache', 'Purged {{n}} URL{{value}} from cache', { n: n, value: n === 1 ? '' : 's' }));
|
||||
setPurgeUrls('');
|
||||
} catch (err) {
|
||||
toast.error(err.message || t('app.cloudflareZoneSettings.failedToPurgeUrls', 'Failed to purge URLs'));
|
||||
} finally {
|
||||
setPurging(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) return <PageLoader />;
|
||||
|
||||
const crumbs = (
|
||||
<span className="cf-crumbs">
|
||||
<Link to="/dns">{t('app.cloudflareZoneSettings.dnsZones', 'DNS Zones')}</Link>
|
||||
<span className="cf-crumbs__sep">/</span>
|
||||
<span className="cf-crumbs__cur">{zone?.domain || `Zone ${zoneId}`}</span>
|
||||
<span className="cf-crumbs__sep">/</span>
|
||||
<span className="cf-crumbs__cur">{t('app.cloudflareZoneSettings.cloudflare', 'Cloudflare')}</span>
|
||||
</span>
|
||||
);
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<PageLayout
|
||||
className="cf-zone"
|
||||
contentClassName="app-detail-page app-detail-page--wide"
|
||||
icon={<Cloud size={18} />}
|
||||
title={crumbs}
|
||||
>
|
||||
<div className="cf-zone__body">
|
||||
<EmptyState
|
||||
icon={Cloud}
|
||||
title={t('app.cloudflareZoneSettings.cloudflareSettingsUnavailable', 'Cloudflare settings unavailable')}
|
||||
description={error}
|
||||
/>
|
||||
<div className="cf-zone__error-actions">
|
||||
<Button variant="outline" onClick={loadSettings}>{t('common.actions.retry', 'Retry')}</Button>
|
||||
<Link to="/dns"><Button variant="ghost">{t('app.cloudflareZoneSettings.backToDnsZones', 'Back to DNS Zones')}</Button></Link>
|
||||
</div>
|
||||
</div>
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
const tabGroups = groups.filter(g => g.settings?.length);
|
||||
const firstTab = tabGroups[0]?.key || 'actions';
|
||||
|
||||
return (
|
||||
<PageLayout
|
||||
className="cf-zone"
|
||||
contentClassName="app-detail-page app-detail-page--wide"
|
||||
icon={<Cloud size={18} />}
|
||||
title={crumbs}
|
||||
meta={zone?.provider_zone_id ? `Zone ${zone.provider_zone_id}` : undefined}
|
||||
>
|
||||
<div className="cf-zone__body">
|
||||
<Tabs defaultValue={firstTab} className="cf-zone__tabs">
|
||||
<TabsList>
|
||||
{tabGroups.map(g => (
|
||||
<TabsTrigger key={g.key} value={g.key}>
|
||||
{TAB_ICONS[g.key]}{g.label}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
<TabsTrigger value="waf"><Flame size={15} />WAF</TabsTrigger>
|
||||
<TabsTrigger value="workers"><Zap size={15} />{t('app.cloudflareZoneSettings.workers', 'Workers')}</TabsTrigger>
|
||||
<TabsTrigger value="tunnels"><Network size={15} />{t('app.cloudflareZoneSettings.tunnels', 'Tunnels')}</TabsTrigger>
|
||||
<TabsTrigger value="storage"><HardDrive size={15} />{t('common.labels.storage', 'Storage')}</TabsTrigger>
|
||||
<TabsTrigger value="actions"><Wand2 size={15} />{t('common.labels.actions', 'Actions')}</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{tabGroups.map(g => (
|
||||
<TabsContent key={g.key} value={g.key}>
|
||||
<div className="cf-panel">
|
||||
{g.settings.map(setting => (
|
||||
<SettingRow
|
||||
key={setting.id}
|
||||
setting={setting}
|
||||
state={settings[setting.id]}
|
||||
saving={saving === setting.id}
|
||||
disabled={!isAdmin}
|
||||
onSave={save}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</TabsContent>
|
||||
))}
|
||||
|
||||
<TabsContent value="waf">
|
||||
<div className="cf-panel">
|
||||
<CloudflareWafPanel zoneId={zoneId} isAdmin={isAdmin} />
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="workers">
|
||||
<div className="cf-panel">
|
||||
<WorkersPanel zoneId={zoneId} isAdmin={isAdmin} />
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="tunnels">
|
||||
<div className="cf-panel">
|
||||
<TunnelsPanel zoneId={zoneId} isAdmin={isAdmin} />
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="storage">
|
||||
<div className="cf-panel">
|
||||
<StoragePanel zoneId={zoneId} isAdmin={isAdmin} />
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="actions">
|
||||
<div className="cf-panel cf-actions">
|
||||
<div className="cf-action">
|
||||
<div className="cf-action__text">
|
||||
<h3>{t('app.cloudflareZoneSettings.applyRecommendedHardening', 'Apply recommended hardening')}</h3>
|
||||
<p>
|
||||
{t('app.cloudflareZoneSettings.setsFullStrictSslAlwaysUse', 'Sets Full (strict) SSL, Always Use HTTPS, HSTS (6 months), a TLS 1.2 floor with TLS 1.3, Brotli, HTTP/3, and a 4-hour browser cache. Settings your plan doesn\'t allow are skipped.')}
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={handleApplyPreset} disabled={applying || !isAdmin}>
|
||||
{applying ? 'Applying…' : 'Apply preset'}
|
||||
</Button>
|
||||
</div>
|
||||
{!isAdmin && (
|
||||
<p className="cf-actions__note">
|
||||
{t('app.cloudflareZoneSettings.changingCloudflareSettingsRequiresAnAdmin', 'Changing Cloudflare settings requires an admin account.')}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="cf-panel cf-actions">
|
||||
<div className="cf-action">
|
||||
<div className="cf-action__text">
|
||||
<h3><Eraser size={15} /> {t('app.cloudflareZoneSettings.purgeCache', 'Purge cache')}</h3>
|
||||
<p>
|
||||
{t('app.cloudflareZoneSettings.clearCloudflareSCachedCopyOf', 'Clear Cloudflare\'s cached copy of your site so visitors get fresh content. Purge everything, or list specific URLs below.')}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
variant="destructive"
|
||||
onClick={() => setConfirmPurgeAll(true)}
|
||||
disabled={purging || !isAdmin}
|
||||
>
|
||||
{purging ? 'Purging…' : 'Purge everything'}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="cf-purge-files">
|
||||
<label htmlFor="cf-purge-urls" className="cf-purge-files__label">
|
||||
{t('app.cloudflareZoneSettings.purgeSpecificUrlsOnePerLine', 'Purge specific URLs (one per line, up to 30)')}
|
||||
</label>
|
||||
<Textarea
|
||||
id="cf-purge-urls"
|
||||
rows={4}
|
||||
placeholder={'https://example.com/style.css\nhttps://example.com/app.js'}
|
||||
value={purgeUrls}
|
||||
disabled={purging || !isAdmin}
|
||||
onChange={(e) => setPurgeUrls(e.target.value)}
|
||||
/>
|
||||
<div className="cf-purge-files__actions">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={handlePurgeFiles}
|
||||
disabled={purging || !isAdmin || !purgeUrls.trim()}
|
||||
>
|
||||
{t('app.cloudflareZoneSettings.purgeUrls', 'Purge URLs')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
{confirmPurgeAll && (
|
||||
<ConfirmDialog
|
||||
isOpen
|
||||
title={t('app.cloudflareZoneSettings.purgeEntireCache', 'Purge entire cache')}
|
||||
message={t('app.cloudflareZoneSettings.clearCloudflareSEntireCacheFor', 'Clear Cloudflare\'s entire cache for {{value}}?', { value: zone?.domain || 'this zone' })
|
||||
+ t('app.cloudflareZoneSettings.theNextVisitToEachPage', 'The next visit to each page will be served from your origin until ')
|
||||
+ t('app.cloudflareZoneSettings.itReCachesThisIsSafe', 'it re-caches. This is safe but can briefly increase origin load.')}
|
||||
confirmText={t('app.cloudflareZoneSettings.purgeEverything', 'Purge everything')}
|
||||
onConfirm={handlePurgeEverything}
|
||||
onCancel={() => setConfirmPurgeAll(false)}
|
||||
variant="danger"
|
||||
/>
|
||||
)}
|
||||
</PageLayout>
|
||||
);
|
||||
};
|
||||
|
||||
// A single setting row — label + help on the left, the control on the right.
|
||||
// Reads the current value/editability from the live settings state; renders the
|
||||
// control declaratively from the setting's `type`.
|
||||
function SettingRow({ setting, state, saving, disabled, onSave }) {
|
||||
const { t } = useTranslation();
|
||||
const present = state !== undefined && state !== null;
|
||||
const editable = present ? state.editable !== false : false;
|
||||
const locked = disabled || !editable || saving;
|
||||
|
||||
return (
|
||||
<div className="cf-setting">
|
||||
<div className="cf-setting__info">
|
||||
<span className="cf-setting__label">{setting.label}</span>
|
||||
{setting.help && <span className="cf-setting__help">{setting.help}</span>}
|
||||
{!present && (
|
||||
<Badge variant="secondary" className="cf-setting__badge">
|
||||
{t('app.cloudflareZoneSettings.notAvailableOnThisZone', 'Not available on this zone')}
|
||||
</Badge>
|
||||
)}
|
||||
{present && !editable && (
|
||||
<Badge variant="secondary" className="cf-setting__badge">
|
||||
{t('app.cloudflareZoneSettings.lockedByYourCloudflarePlan', 'Locked by your Cloudflare plan')}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div className="cf-setting__control">
|
||||
<SettingControl
|
||||
setting={setting}
|
||||
value={present ? state.value : undefined}
|
||||
locked={locked || !present}
|
||||
onSave={onSave}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SettingControl({ setting, value, locked, onSave }) {
|
||||
if (setting.type === 'toggle') {
|
||||
return (
|
||||
<Switch
|
||||
checked={value === 'on'}
|
||||
disabled={locked}
|
||||
onCheckedChange={(checked) => onSave(setting.id, checked ? 'on' : 'off')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (setting.type === 'select') {
|
||||
const current = value === undefined || value === null ? '' : String(value);
|
||||
return (
|
||||
<Select
|
||||
value={current}
|
||||
disabled={locked}
|
||||
onValueChange={(v) => {
|
||||
const opt = setting.options.find(o => String(o.value) === v);
|
||||
onSave(setting.id, opt ? opt.value : v);
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="cf-setting__select"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{setting.options.map(o => (
|
||||
<SelectItem key={String(o.value)} value={String(o.value)}>{o.label}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
|
||||
if (setting.type === 'hsts') {
|
||||
return <HstsControl value={value} locked={locked} onSave={onSave} settingId={setting.id} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// HSTS is a compound object setting; editing any field re-sends the whole
|
||||
// strict_transport_security object so the others are preserved.
|
||||
function HstsControl({ value, locked, onSave, settingId }) {
|
||||
const { t } = useTranslation();
|
||||
const sts = (value && value.strict_transport_security) || {};
|
||||
const enabled = !!sts.enabled;
|
||||
|
||||
const patch = (changes) => {
|
||||
const next = {
|
||||
enabled: sts.enabled || false,
|
||||
max_age: sts.max_age || 0,
|
||||
include_subdomains: sts.include_subdomains || false,
|
||||
preload: sts.preload || false,
|
||||
nosniff: sts.nosniff !== undefined ? sts.nosniff : true,
|
||||
...changes,
|
||||
};
|
||||
onSave(settingId, { strict_transport_security: next });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="cf-hsts">
|
||||
<div className="cf-hsts__row">
|
||||
<span>{t('app.cloudflareZoneSettings.enabled', 'Enabled')}</span>
|
||||
<Switch
|
||||
checked={enabled}
|
||||
disabled={locked}
|
||||
onCheckedChange={(checked) => patch({
|
||||
enabled: checked,
|
||||
// Give a sane max-age when first enabling.
|
||||
max_age: checked && !sts.max_age ? 15552000 : sts.max_age || 0,
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{enabled && (
|
||||
<>
|
||||
<div className="cf-hsts__row">
|
||||
<span>{t('app.cloudflareZoneSettings.maxAge', 'Max age')}</span>
|
||||
<Select
|
||||
value={String(sts.max_age || 0)}
|
||||
disabled={locked}
|
||||
onValueChange={(v) => patch({ max_age: Number(v) })}
|
||||
>
|
||||
<SelectTrigger className="cf-setting__select"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{HSTS_MAX_AGE.map(o => (
|
||||
<SelectItem key={o.value} value={String(o.value)}>{o.label}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="cf-hsts__row">
|
||||
<span>{t('app.cloudflareZoneSettings.includeSubdomains', 'Include subdomains')}</span>
|
||||
<Switch
|
||||
checked={!!sts.include_subdomains}
|
||||
disabled={locked}
|
||||
onCheckedChange={(checked) => patch({ include_subdomains: checked })}
|
||||
/>
|
||||
</div>
|
||||
<div className="cf-hsts__row">
|
||||
<span>{t('app.cloudflareZoneSettings.preload', 'Preload')}</span>
|
||||
<Switch
|
||||
checked={!!sts.preload}
|
||||
disabled={locked}
|
||||
onCheckedChange={(checked) => patch({ preload: checked })}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default CloudflareZoneSettings;
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "serverkit-cloudflare-ops",
|
||||
"display_name": "Cloudflare Zone Ops",
|
||||
"version": "1.0.0",
|
||||
"description": "Cloudflare zone operations on top of your existing Cloudflare DNS connection, covering zone settings, cache purge, WAF, Workers, Tunnels, and R2/KV/D1 storage. DNS records and the connection itself stay in the core Domains surface; this adds the per-zone control panel reached from a Cloudflare-managed domain.",
|
||||
"author": "ServerKit",
|
||||
"license": "MIT",
|
||||
"category": "integration",
|
||||
"homepage": "https://github.com/jhd3197/ServerKit",
|
||||
"permissions": [
|
||||
"network"
|
||||
],
|
||||
"min_panel_version": "1.7.0",
|
||||
"featured": true,
|
||||
"feature_score": 70,
|
||||
"entry_point": "cloudflare:cloudflare_bp",
|
||||
"url_prefix": "/api/v1/cloudflare",
|
||||
"icon": "<path d=\"M20 17.5a3.5 3.5 0 00-.5-6.96A5.5 5.5 0 008.6 9.6 4 4 0 007 17.5z\"/>",
|
||||
"contributions": {
|
||||
"routes": [
|
||||
{
|
||||
"path": "cloudflare/zones/:zoneId",
|
||||
"component": "CloudflareZoneSettingsPage"
|
||||
}
|
||||
],
|
||||
"page_titles": {
|
||||
"/cloudflare/zones": "Cloudflare Zone"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
// Cloudflare operations — zone settings (SSL/TLS, Speed, Caching, Security) and
|
||||
// one-click hardening, layered on the existing Cloudflare DNS connection. Zones
|
||||
// are addressed by their ServerKit DNS zone id (same as the /dns API).
|
||||
//
|
||||
// The extension's own /api/v1/cloudflare client, built on the panel's
|
||||
// ApiClient via the SDK singleton — moved out of the host's services/api/
|
||||
// with the zone-ops surface (plan 52 Phase 2). The DNS-record layer and the
|
||||
// Cloudflare connection itself stay core (they back /domains).
|
||||
import { api } from 'serverkit-sdk';
|
||||
|
||||
async function getCloudflareZoneSettings(zoneId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/settings`);
|
||||
}
|
||||
|
||||
async function getCloudflareZoneSetting(zoneId, settingId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/settings/${settingId}`);
|
||||
}
|
||||
|
||||
async function updateCloudflareZoneSetting(zoneId, settingId, value) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/settings/${settingId}`, {
|
||||
method: 'PATCH',
|
||||
body: { value },
|
||||
});
|
||||
}
|
||||
|
||||
async function applyCloudflareSettingsPreset(zoneId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/settings/apply-preset`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
// Purge the zone's Cloudflare cache. payload is { purge_everything: true } or
|
||||
// { files: [...] } (and on Enterprise, hosts/prefixes/tags).
|
||||
async function purgeCloudflareCache(zoneId, payload) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/purge-cache`, {
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
});
|
||||
}
|
||||
|
||||
// WAF custom firewall rules (http_request_firewall_custom phase).
|
||||
async function getCloudflareWafRules(zoneId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/waf/rules`);
|
||||
}
|
||||
|
||||
async function addCloudflareWafRule(zoneId, rule) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/waf/rules`, {
|
||||
method: 'POST',
|
||||
body: rule,
|
||||
});
|
||||
}
|
||||
|
||||
async function applyCloudflareWafPreset(zoneId, presetKey, params = {}) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/waf/presets/${presetKey}`, {
|
||||
method: 'POST',
|
||||
body: { params },
|
||||
});
|
||||
}
|
||||
|
||||
async function updateCloudflareWafRule(zoneId, rulesetId, ruleId, fields) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/waf/rulesets/${rulesetId}/rules/${ruleId}`, {
|
||||
method: 'PATCH',
|
||||
body: fields,
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteCloudflareWafRule(zoneId, rulesetId, ruleId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/waf/rulesets/${rulesetId}/rules/${ruleId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
// Workers (edge hosting). Account is resolved from the zone server-side.
|
||||
async function getCloudflareWorkers(zoneId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/workers`);
|
||||
}
|
||||
|
||||
async function deployCloudflareWorker(zoneId, payload) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/workers`, {
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteCloudflareWorker(zoneId, name) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/workers/${encodeURIComponent(name)}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
async function addCloudflareWorkerRoute(zoneId, pattern, script) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/workers/routes`, {
|
||||
method: 'POST',
|
||||
body: { pattern, script },
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteCloudflareWorkerRoute(zoneId, routeId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/workers/routes/${routeId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
// Cloudflare Tunnels (cloudflared) — expose a local service through the edge.
|
||||
async function getCloudflareTunnels(zoneId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/tunnels`);
|
||||
}
|
||||
|
||||
async function createCloudflareTunnel(zoneId, name) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/tunnels`, {
|
||||
method: 'POST',
|
||||
body: { name },
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteCloudflareTunnel(zoneId, tunnelId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/tunnels/${tunnelId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
async function getCloudflareTunnelInstall(zoneId, tunnelId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/tunnels/${tunnelId}/install`);
|
||||
}
|
||||
|
||||
async function getCloudflareTunnelHostnames(zoneId, tunnelId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/tunnels/${tunnelId}/hostnames`);
|
||||
}
|
||||
|
||||
async function addCloudflareTunnelHostname(zoneId, tunnelId, hostname, service) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/tunnels/${tunnelId}/hostnames`, {
|
||||
method: 'POST',
|
||||
body: { hostname, service },
|
||||
});
|
||||
}
|
||||
|
||||
async function removeCloudflareTunnelHostname(zoneId, tunnelId, hostname) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/tunnels/${tunnelId}/hostnames`, {
|
||||
method: 'DELETE',
|
||||
body: { hostname },
|
||||
});
|
||||
}
|
||||
|
||||
// Developer platform — R2 buckets, KV namespaces, D1 databases (account-scoped).
|
||||
async function getCloudflareStorage(zoneId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/storage`);
|
||||
}
|
||||
|
||||
async function createCloudflareR2Bucket(zoneId, name) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/storage/r2`, {
|
||||
method: 'POST',
|
||||
body: { name },
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteCloudflareR2Bucket(zoneId, name) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/storage/r2/${encodeURIComponent(name)}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
async function createCloudflareKvNamespace(zoneId, title) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/storage/kv`, {
|
||||
method: 'POST',
|
||||
body: { title },
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteCloudflareKvNamespace(zoneId, namespaceId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/storage/kv/${namespaceId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
async function createCloudflareD1Database(zoneId, name) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/storage/d1`, {
|
||||
method: 'POST',
|
||||
body: { name },
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteCloudflareD1Database(zoneId, databaseId) {
|
||||
return api.request(`/cloudflare/zones/${zoneId}/storage/d1/${databaseId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
const cloudflareApi = {
|
||||
getCloudflareZoneSettings,
|
||||
getCloudflareZoneSetting,
|
||||
updateCloudflareZoneSetting,
|
||||
applyCloudflareSettingsPreset,
|
||||
purgeCloudflareCache,
|
||||
getCloudflareWafRules,
|
||||
addCloudflareWafRule,
|
||||
applyCloudflareWafPreset,
|
||||
updateCloudflareWafRule,
|
||||
deleteCloudflareWafRule,
|
||||
getCloudflareWorkers,
|
||||
deployCloudflareWorker,
|
||||
deleteCloudflareWorker,
|
||||
addCloudflareWorkerRoute,
|
||||
deleteCloudflareWorkerRoute,
|
||||
getCloudflareTunnels,
|
||||
createCloudflareTunnel,
|
||||
deleteCloudflareTunnel,
|
||||
getCloudflareTunnelInstall,
|
||||
getCloudflareTunnelHostnames,
|
||||
addCloudflareTunnelHostname,
|
||||
removeCloudflareTunnelHostname,
|
||||
getCloudflareStorage,
|
||||
createCloudflareR2Bucket,
|
||||
deleteCloudflareR2Bucket,
|
||||
createCloudflareKvNamespace,
|
||||
deleteCloudflareKvNamespace,
|
||||
createCloudflareD1Database,
|
||||
deleteCloudflareD1Database,
|
||||
};
|
||||
|
||||
export default cloudflareApi;
|
||||
@@ -1,572 +0,0 @@
|
||||
// Compiled through the extension's module graph (imported by index.jsx).
|
||||
// The host's design-token partial is imported via a sync-safe relative
|
||||
// path — the baked copy lives at frontend/src/plugins/serverkit-cloudflare-ops/,
|
||||
// so this resolves to frontend/src/styles/_variables.scss.
|
||||
@import '../../../styles/variables';
|
||||
|
||||
// Cloudflare zone settings — detail page reached from a Cloudflare-managed DNS
|
||||
// zone. Full-bleed top bar (PageTopbar) + tabbed setting groups.
|
||||
|
||||
.cf-zone {
|
||||
&__body {
|
||||
padding: $spacing-lg;
|
||||
max-width: 880px;
|
||||
}
|
||||
|
||||
&__tabs {
|
||||
margin-top: $spacing-sm;
|
||||
}
|
||||
|
||||
&__error-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: $spacing-sm;
|
||||
margin-top: $spacing-md;
|
||||
}
|
||||
}
|
||||
|
||||
// Breadcrumb in the top-bar title slot (mirrors the service-detail crumbs).
|
||||
.cf-crumbs {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: $spacing-xs;
|
||||
font-size: 0.95rem;
|
||||
|
||||
a {
|
||||
color: $text-secondary;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover { color: $primary-color; }
|
||||
}
|
||||
|
||||
&__sep { color: $text-tertiary; }
|
||||
&__cur { color: $text-primary; font-weight: 600; }
|
||||
}
|
||||
|
||||
.cf-panel {
|
||||
background: $card-bg;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: $radius-lg;
|
||||
padding: $spacing-xs $spacing-lg;
|
||||
margin-top: $spacing-md;
|
||||
}
|
||||
|
||||
// One setting: label/help on the left, control hugging the right.
|
||||
.cf-setting {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: $spacing-lg;
|
||||
padding: $spacing-md 0;
|
||||
border-bottom: 1px solid $border-color;
|
||||
|
||||
&:last-child { border-bottom: none; }
|
||||
|
||||
&__info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-weight: 600;
|
||||
color: $text-primary;
|
||||
}
|
||||
|
||||
&__help {
|
||||
font-size: 0.85rem;
|
||||
color: $text-muted;
|
||||
max-width: 52ch;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
&__badge {
|
||||
align-self: flex-start;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
&__control {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
&__select {
|
||||
min-width: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
// HSTS compound control — a small stack of rows.
|
||||
.cf-hsts {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-sm;
|
||||
min-width: 240px;
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: $spacing-md;
|
||||
font-size: 0.88rem;
|
||||
color: $text-secondary;
|
||||
}
|
||||
}
|
||||
|
||||
.cf-actions {
|
||||
& + & { margin-top: $spacing-md; }
|
||||
|
||||
.cf-action {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: $spacing-lg;
|
||||
padding: $spacing-md 0;
|
||||
|
||||
&__text {
|
||||
h3 {
|
||||
margin: 0 0 4px;
|
||||
font-size: 1rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: $spacing-xs;
|
||||
}
|
||||
p { margin: 0; color: $text-muted; font-size: 0.88rem; max-width: 60ch; line-height: 1.5; }
|
||||
}
|
||||
}
|
||||
|
||||
&__note {
|
||||
margin: $spacing-sm 0 0;
|
||||
color: $text-muted;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
}
|
||||
|
||||
.cf-purge-files {
|
||||
border-top: 1px solid $border-color;
|
||||
padding-top: $spacing-md;
|
||||
|
||||
&__label {
|
||||
display: block;
|
||||
font-size: 0.85rem;
|
||||
color: $text-secondary;
|
||||
margin-bottom: $spacing-xs;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: $spacing-sm;
|
||||
}
|
||||
}
|
||||
|
||||
// WAF tab — preset picker, custom-rule form, and the active-rules list.
|
||||
.cf-waf {
|
||||
&__loading {
|
||||
padding: $spacing-lg;
|
||||
color: $text-muted;
|
||||
}
|
||||
|
||||
&__section {
|
||||
padding: $spacing-md 0;
|
||||
border-bottom: 1px solid $border-color;
|
||||
|
||||
&:last-child { border-bottom: none; }
|
||||
}
|
||||
|
||||
&__heading {
|
||||
margin: 0 0 4px;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
&__hint {
|
||||
margin: 0 0 $spacing-sm;
|
||||
color: $text-muted;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
&__field {
|
||||
margin-bottom: $spacing-sm;
|
||||
}
|
||||
|
||||
&__label {
|
||||
display: block;
|
||||
font-size: 0.82rem;
|
||||
color: $text-secondary;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
&__select {
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
&__preset-desc {
|
||||
margin: 0 0 $spacing-sm;
|
||||
color: $text-secondary;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
&__params {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: $spacing-md;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: $spacing-sm;
|
||||
}
|
||||
|
||||
&__list {
|
||||
list-style: none;
|
||||
margin: $spacing-sm 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-sm;
|
||||
}
|
||||
|
||||
&__rule {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: $spacing-md;
|
||||
padding: $spacing-md;
|
||||
background: $bg-elevated;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
&__rule-main {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
&__rule-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: $spacing-sm;
|
||||
margin-bottom: $spacing-xs;
|
||||
}
|
||||
|
||||
&__rule-desc {
|
||||
font-weight: 600;
|
||||
color: $text-primary;
|
||||
}
|
||||
|
||||
&__rule-expr {
|
||||
display: block;
|
||||
font-family: $font-mono;
|
||||
font-size: 0.8rem;
|
||||
color: $text-secondary;
|
||||
background: $bg-code;
|
||||
padding: $spacing-xs $spacing-sm;
|
||||
border-radius: $radius-sm;
|
||||
overflow-x: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
&__rule-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: $spacing-sm;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Workers tab — deploy form + script/route lists.
|
||||
.cf-workers {
|
||||
&__loading {
|
||||
padding: $spacing-lg;
|
||||
color: $text-muted;
|
||||
}
|
||||
|
||||
&__section {
|
||||
padding: $spacing-md 0;
|
||||
border-bottom: 1px solid $border-color;
|
||||
|
||||
&:last-child { border-bottom: none; }
|
||||
}
|
||||
|
||||
&__heading {
|
||||
margin: 0 0 $spacing-sm;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
&__hint {
|
||||
margin: $spacing-xs 0 0;
|
||||
color: $text-muted;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
&__field {
|
||||
margin-bottom: $spacing-sm;
|
||||
}
|
||||
|
||||
&__label {
|
||||
display: block;
|
||||
font-size: 0.82rem;
|
||||
color: $text-secondary;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
&__code {
|
||||
font-family: $font-mono;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__list {
|
||||
list-style: none;
|
||||
margin: $spacing-sm 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-xs;
|
||||
}
|
||||
|
||||
&__item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: $spacing-md;
|
||||
padding: $spacing-sm $spacing-md;
|
||||
background: $bg-elevated;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
&__name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: $spacing-sm;
|
||||
min-width: 0;
|
||||
flex-wrap: wrap;
|
||||
|
||||
code {
|
||||
font-family: $font-mono;
|
||||
font-size: 0.85rem;
|
||||
color: $text-primary;
|
||||
}
|
||||
}
|
||||
|
||||
&__meta {
|
||||
color: $text-muted;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
&__item-actions {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Tunnels tab — create form, install command box, tunnel list with hostnames.
|
||||
.cf-tunnels {
|
||||
&__loading {
|
||||
padding: $spacing-lg;
|
||||
color: $text-muted;
|
||||
}
|
||||
|
||||
&__section {
|
||||
padding: $spacing-md 0;
|
||||
border-bottom: 1px solid $border-color;
|
||||
|
||||
&:last-child { border-bottom: none; }
|
||||
}
|
||||
|
||||
&__heading {
|
||||
margin: 0 0 $spacing-sm;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
&__hint {
|
||||
margin: $spacing-xs 0 0;
|
||||
color: $text-muted;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
&__field {
|
||||
margin-bottom: $spacing-sm;
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
display: block;
|
||||
font-size: 0.82rem;
|
||||
color: $text-secondary;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__install {
|
||||
margin-top: $spacing-md;
|
||||
padding: $spacing-md;
|
||||
background: $bg-code;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: $radius-md;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-sm;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&__cmd {
|
||||
display: block;
|
||||
width: 100%;
|
||||
font-family: $font-mono;
|
||||
font-size: 0.8rem;
|
||||
color: $text-primary;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
&__list {
|
||||
list-style: none;
|
||||
margin: $spacing-sm 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-sm;
|
||||
}
|
||||
|
||||
&__item {
|
||||
padding: $spacing-md;
|
||||
background: $bg-elevated;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
&__item-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: $spacing-sm;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-weight: 600;
|
||||
color: $text-primary;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
color: $text-muted;
|
||||
font-size: 0.8rem;
|
||||
font-family: $font-mono;
|
||||
}
|
||||
|
||||
&__item-actions {
|
||||
display: flex;
|
||||
gap: $spacing-sm;
|
||||
margin-top: $spacing-sm;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__hostnames {
|
||||
margin-top: $spacing-md;
|
||||
padding-top: $spacing-md;
|
||||
border-top: 1px solid $border-color;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-sm;
|
||||
}
|
||||
|
||||
&__host {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: $spacing-md;
|
||||
|
||||
code {
|
||||
font-family: $font-mono;
|
||||
font-size: 0.82rem;
|
||||
color: $text-secondary;
|
||||
}
|
||||
}
|
||||
|
||||
&__host-add {
|
||||
display: flex;
|
||||
gap: $spacing-sm;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
// Storage tab — R2 buckets, KV namespaces, D1 databases.
|
||||
.cf-storage {
|
||||
&__loading {
|
||||
padding: $spacing-lg;
|
||||
color: $text-muted;
|
||||
}
|
||||
|
||||
&__section {
|
||||
padding: $spacing-md 0;
|
||||
border-bottom: 1px solid $border-color;
|
||||
|
||||
&:last-child { border-bottom: none; }
|
||||
}
|
||||
|
||||
&__heading {
|
||||
margin: 0 0 $spacing-sm;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
&__hint {
|
||||
margin: $spacing-xs 0;
|
||||
color: $text-muted;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
&__error {
|
||||
margin: $spacing-xs 0;
|
||||
color: $text-muted;
|
||||
font-size: 0.82rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
&__create {
|
||||
display: flex;
|
||||
gap: $spacing-sm;
|
||||
align-items: center;
|
||||
max-width: 420px;
|
||||
margin-bottom: $spacing-sm;
|
||||
}
|
||||
|
||||
&__list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-xs;
|
||||
}
|
||||
|
||||
&__item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: $spacing-md;
|
||||
padding: $spacing-sm $spacing-md;
|
||||
background: $bg-elevated;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: $font-mono;
|
||||
font-size: 0.85rem;
|
||||
color: $text-primary;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user