Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
+446
-114
@@ -32,19 +32,30 @@
|
||||
currentVersion: { id: number; version: number; release_version: string | null } | null;
|
||||
kind: ArtifactKind;
|
||||
latestVersion: {
|
||||
id: number; version: number; sha256: string; size: number;
|
||||
id: number;
|
||||
version: number;
|
||||
sha256: string;
|
||||
size: number;
|
||||
release_version: string | null;
|
||||
state: 'untested' | 'tested' | 'test-failed'; uploaded_at: string;
|
||||
state: 'untested' | 'tested' | 'test-failed';
|
||||
uploaded_at: string;
|
||||
} | null;
|
||||
versionCount: number;
|
||||
servers: string[];
|
||||
runningBetaId: number | null;
|
||||
}
|
||||
interface ScopeOptions { games: string[]; mapsByGame: Record<string, string[]>; }
|
||||
interface ScopeOptions {
|
||||
games: string[];
|
||||
mapsByGame: Record<string, string[]>;
|
||||
}
|
||||
|
||||
let addOpen = $state(false);
|
||||
let githubBusy = $state(false);
|
||||
let importComplete = $state<{ pluginId: number; betaUrl: string; alreadyImported: boolean } | null>(null);
|
||||
let importComplete = $state<{
|
||||
pluginId: number;
|
||||
betaUrl: string;
|
||||
alreadyImported: boolean;
|
||||
} | null>(null);
|
||||
let method = $state('upload');
|
||||
let updatesOpen = $state(false);
|
||||
let updates = $state<PluginUpdate[]>([]);
|
||||
@@ -54,20 +65,59 @@
|
||||
let sort = $state('name');
|
||||
let limit = $state(25);
|
||||
let mounted = $state(false);
|
||||
afterNavigate(() => { mounted = true; });
|
||||
afterNavigate(() => {
|
||||
mounted = true;
|
||||
});
|
||||
let lastFilters = '';
|
||||
$effect(() => { const key = JSON.stringify([search, game, status, sort]); if (!mounted) return; if (lastFilters && lastFilters !== key) limit = 25; lastFilters = key; });
|
||||
$effect(() => { if (mounted) saveLibraryContext({ q: search, game, status, sort, limit }, { sort: 'name', limit: 25 }); });
|
||||
const visible = $derived.by(() => plugins.filter(a => (a.name + ' ' + a.target_rel_path).toLowerCase().includes(search.toLowerCase())
|
||||
&& (!game || !a.scope_type || (a.scope_type === 'game' ? a.scope_value === game : (scopeOptions.mapsByGame[game] ?? []).includes(a.scope_value ?? '')))
|
||||
&& (!status || stateLabel(a) === status)).sort((a,b) => sort === 'recent' ? (b.latestVersion?.uploaded_at ?? '').localeCompare(a.latestVersion?.uploaded_at ?? '') : a.name.localeCompare(b.name)));
|
||||
$effect(() => {
|
||||
const key = JSON.stringify([search, game, status, sort]);
|
||||
if (!mounted) return;
|
||||
if (lastFilters && lastFilters !== key) limit = 25;
|
||||
lastFilters = key;
|
||||
});
|
||||
$effect(() => {
|
||||
if (mounted)
|
||||
saveLibraryContext(
|
||||
{ q: search, game, status, sort, limit },
|
||||
{ sort: 'name', limit: 25 }
|
||||
);
|
||||
});
|
||||
const visible = $derived.by(() =>
|
||||
plugins
|
||||
.filter(
|
||||
(a) =>
|
||||
(a.name + ' ' + a.target_rel_path)
|
||||
.toLowerCase()
|
||||
.includes(search.toLowerCase()) &&
|
||||
(!game ||
|
||||
!a.scope_type ||
|
||||
(a.scope_type === 'game'
|
||||
? a.scope_value === game
|
||||
: (scopeOptions.mapsByGame[game] ?? []).includes(
|
||||
a.scope_value ?? ''
|
||||
))) &&
|
||||
(!status || stateLabel(a) === status)
|
||||
)
|
||||
.sort((a, b) =>
|
||||
sort === 'recent'
|
||||
? (b.latestVersion?.uploaded_at ?? '').localeCompare(
|
||||
a.latestVersion?.uploaded_at ?? ''
|
||||
)
|
||||
: a.name.localeCompare(b.name)
|
||||
)
|
||||
);
|
||||
let plugins = $state<ArtifactRow[]>([]);
|
||||
let importCount = $state(0);
|
||||
let loading = $state(true);
|
||||
let flash = $state<string | null>(null);
|
||||
let uploading = $state(false);
|
||||
let scopeOptions = $state<ScopeOptions>({ games: [], mapsByGame: {} });
|
||||
let successBanner = $state<{ name: string; artifactId: number; version: number; release_version: string | null } | null>(null);
|
||||
let successBanner = $state<{
|
||||
name: string;
|
||||
artifactId: number;
|
||||
version: number;
|
||||
release_version: string | null;
|
||||
} | null>(null);
|
||||
|
||||
let newName = $state('');
|
||||
let newReleaseVersion = $state('');
|
||||
@@ -90,13 +140,18 @@
|
||||
fetch('/api/scope-options')
|
||||
]);
|
||||
if (!pluginRes.ok) {
|
||||
throw new Error('Could not refresh plugins. Your last loaded results are still shown.');
|
||||
throw new Error(
|
||||
'Could not refresh plugins. Your last loaded results are still shown.'
|
||||
);
|
||||
} else {
|
||||
plugins = ((await pluginRes.json()) as { scripts?: ArtifactRow[] }).scripts ?? [];
|
||||
}
|
||||
flash = null;
|
||||
if (scopeRes.ok) {
|
||||
scopeOptions = ((await scopeRes.json()) as ScopeOptions | undefined) ?? { games: [], mapsByGame: {} };
|
||||
scopeOptions = ((await scopeRes.json()) as ScopeOptions | undefined) ?? {
|
||||
games: [],
|
||||
mapsByGame: {}
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
flash = `Failed to load plugins: ${(err as Error).message}`;
|
||||
@@ -104,7 +159,15 @@
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
onMount(() => { const params = new URLSearchParams(window.location.search); search = params.get('q') ?? ''; game = params.get('game') ?? ''; status = params.get('status') ?? ''; sort = params.get('sort') === 'recent' ? 'recent' : 'name'; limit = libraryLimit(params); void load(); });
|
||||
onMount(() => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
search = params.get('q') ?? '';
|
||||
game = params.get('game') ?? '';
|
||||
status = params.get('status') ?? '';
|
||||
sort = params.get('sort') === 'recent' ? 'recent' : 'name';
|
||||
limit = libraryLimit(params);
|
||||
void load();
|
||||
});
|
||||
|
||||
function pickFile(e: Event): void {
|
||||
const t = e.target as HTMLInputElement;
|
||||
@@ -115,8 +178,12 @@
|
||||
async function createPlugin(e: Event): Promise<void> {
|
||||
e.preventDefault();
|
||||
if (uploading || !newFile || !newName.trim()) return;
|
||||
if (newScopeType !== 'none' && !scopeValue) { flash = `Pick a ${newScopeType}`; return; }
|
||||
uploading = true; flash = null;
|
||||
if (newScopeType !== 'none' && !scopeValue) {
|
||||
flash = `Pick a ${newScopeType}`;
|
||||
return;
|
||||
}
|
||||
uploading = true;
|
||||
flash = null;
|
||||
const form = new FormData();
|
||||
form.append('name', newName.trim());
|
||||
form.append('kind', 'plugin');
|
||||
@@ -127,23 +194,48 @@
|
||||
form.append('content', newFile);
|
||||
try {
|
||||
const res = await fetch('/api/plugins', { method: 'POST', body: form });
|
||||
const body = (await res.json()) as { ok: boolean; error?: string; script?: { id: number; name: string } };
|
||||
if (!res.ok || !body.ok) { flash = body.error ?? `HTTP ${res.status}`; return; }
|
||||
const body = (await res.json()) as {
|
||||
ok: boolean;
|
||||
error?: string;
|
||||
script?: { id: number; name: string };
|
||||
};
|
||||
if (!res.ok || !body.ok) {
|
||||
flash = body.error ?? `HTTP ${res.status}`;
|
||||
return;
|
||||
}
|
||||
successBanner = body.script
|
||||
? { name: body.script.name, artifactId: body.script.id, version: 1, release_version: newReleaseVersion.trim() || null }
|
||||
? {
|
||||
name: body.script.name,
|
||||
artifactId: body.script.id,
|
||||
version: 1,
|
||||
release_version: newReleaseVersion.trim() || null
|
||||
}
|
||||
: null;
|
||||
newName = ''; newScopeType = 'none'; newScopeGame = ''; newScopeMap = ''; newNotes = ''; newFile = null;
|
||||
newName = '';
|
||||
newScopeType = 'none';
|
||||
newScopeGame = '';
|
||||
newScopeMap = '';
|
||||
newNotes = '';
|
||||
newFile = null;
|
||||
newReleaseVersion = '';
|
||||
addOpen = false;
|
||||
await load();
|
||||
} catch (error) { flash = (error as Error).message; } finally {
|
||||
} catch (error) {
|
||||
flash = (error as Error).message;
|
||||
} finally {
|
||||
uploading = false;
|
||||
}
|
||||
}
|
||||
|
||||
function scopeLabel(a: ArtifactRow): string {
|
||||
if (!a.scope_type) return 'unscoped';
|
||||
return a.scope_type === 'map' ? mapLabel(a.scope_value ?? '') : a.scope_value === 't5' ? 'Black Ops I' : a.scope_value === 't6' ? 'Black Ops II' : a.scope_value ?? 'Unscoped';
|
||||
return a.scope_type === 'map'
|
||||
? mapLabel(a.scope_value ?? '')
|
||||
: a.scope_value === 't5'
|
||||
? 'Black Ops I'
|
||||
: a.scope_value === 't6'
|
||||
? 'Black Ops II'
|
||||
: (a.scope_value ?? 'Unscoped');
|
||||
}
|
||||
function stateLabel(a: ArtifactRow): string {
|
||||
if (a.runningBetaId) return 'testing';
|
||||
@@ -163,115 +255,305 @@
|
||||
let scopeTypeOptions = [
|
||||
{ value: 'none', label: 'Unscoped' },
|
||||
{ value: 'game', label: 'Game' },
|
||||
{ value: 'map', label: 'Map' }
|
||||
{ value: 'map', label: 'Map' }
|
||||
];
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Plugins · Electric Cherry</title></svelte:head>
|
||||
|
||||
<div class="page">
|
||||
<SectionHeader title="Plugins" subtitle="Manage plugin versions and test changes before promotion.">
|
||||
{#snippet actions()}{#if plugins.length}<Button variant="ghost" onclick={() => updatesOpen = !updatesOpen}>{updatesOpen ? 'Hide update details' : 'Check for updates'}</Button>{/if}{#if loading || plugins.length || flash}<Button variant="primary" onclick={() => addOpen = true}>Add plugin</Button>{/if}{/snippet}
|
||||
<SectionHeader
|
||||
title="Plugins"
|
||||
subtitle="Manage plugin versions and test changes before promotion."
|
||||
>
|
||||
{#snippet actions()}{#if plugins.length}<Button
|
||||
variant="ghost"
|
||||
onclick={() => (updatesOpen = !updatesOpen)}
|
||||
>{updatesOpen ? 'Hide update details' : 'Check for updates'}</Button
|
||||
>{/if}{#if loading || plugins.length || flash}<Button
|
||||
variant="primary"
|
||||
onclick={() => (addOpen = true)}>Add plugin</Button
|
||||
>{/if}{/snippet}
|
||||
</SectionHeader>
|
||||
{#if importComplete}<div class="banner" role="status"><strong>{importComplete.alreadyImported ? 'This plugin version was already imported.' : 'Plugin imported.'}</strong><span><a href={'/plugins/' + importComplete.pluginId}>View version</a> · <a href={importComplete.betaUrl}>Start beta</a></span></div>{/if}
|
||||
{#if successBanner}
|
||||
<div class="banner" role="status">
|
||||
<strong>{artifactVersionLabel(successBanner)} of "{successBanner.name}" uploaded — untested.</strong>
|
||||
<span><a href="/plugins/{successBanner.artifactId}">Review the version and start a beta</a></span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if importComplete}<div class="banner" role="status">
|
||||
<strong
|
||||
>{importComplete.alreadyImported
|
||||
? 'This plugin version was already imported.'
|
||||
: 'Plugin imported.'}</strong
|
||||
><span
|
||||
><a href={'/plugins/' + importComplete.pluginId}>View version</a> ·
|
||||
<a href={importComplete.betaUrl}>Start beta</a></span
|
||||
>
|
||||
</div>{/if}
|
||||
{#if successBanner}
|
||||
<div class="banner" role="status">
|
||||
<strong
|
||||
>{artifactVersionLabel(successBanner)} of "{successBanner.name}" uploaded —
|
||||
untested.</strong
|
||||
>
|
||||
<span
|
||||
><a href="/plugins/{successBanner.artifactId}"
|
||||
>Review the version and start a beta</a
|
||||
></span
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if flash && !addOpen}<div class="ui-error" role="alert">{flash}<Button size="sm" onclick={load}>Retry</Button></div>{/if}
|
||||
{#if flash && !addOpen}<div class="ui-error" role="alert">
|
||||
{flash}<Button size="sm" onclick={load}>Retry</Button>
|
||||
</div>{/if}
|
||||
{#if loading || plugins.length || flash}<div class="library-toolbar">
|
||||
<input class="search" type="search" aria-label="Search plugins" bind:value={search} placeholder="Search names or files…" />
|
||||
<select aria-label="Filter plugins by game" bind:value={game}><option value="">All games</option><option value="t5">Black Ops I</option><option value="t6">Black Ops II</option></select>
|
||||
<select aria-label="Filter plugins by status" bind:value={status}><option value="">All statuses</option><option value="untested">Needs testing</option><option value="testing">Beta active</option><option value="test-failed">Test failed</option><option value="tested">Test passed</option><option value="promoted">Promoted</option><option value="empty">No versions</option></select>
|
||||
<select aria-label="Sort plugins" bind:value={sort}><option value="name">Name A–Z</option><option value="recent">Recently uploaded</option></select>
|
||||
</div>{/if}
|
||||
{#if game}<p class="filter-hint">Game results include unscoped plugins that can use explicitly selected beta servers.</p>{/if}
|
||||
{#if updatesOpen}<details open ontoggle={event => { if (!event.currentTarget.open) updatesOpen = false; }}><summary>Update check details</summary>{#key importCount}<PluginUpdates onchecked={results => updates = results} />{/key}</details>{/if}
|
||||
<input
|
||||
class="search"
|
||||
type="search"
|
||||
aria-label="Search plugins"
|
||||
bind:value={search}
|
||||
placeholder="Search names or files…"
|
||||
/>
|
||||
<select aria-label="Filter plugins by game" bind:value={game}
|
||||
><option value="">All games</option><option value="t5">Black Ops I</option><option
|
||||
value="t6">Black Ops II</option
|
||||
></select
|
||||
>
|
||||
<select aria-label="Filter plugins by status" bind:value={status}
|
||||
><option value="">All statuses</option><option value="untested"
|
||||
>Needs testing</option
|
||||
><option value="testing">Beta active</option><option value="test-failed"
|
||||
>Test failed</option
|
||||
><option value="tested">Test passed</option><option value="promoted"
|
||||
>Promoted</option
|
||||
><option value="empty">No versions</option></select
|
||||
>
|
||||
<select aria-label="Sort plugins" bind:value={sort}
|
||||
><option value="name">Name A–Z</option><option value="recent"
|
||||
>Recently uploaded</option
|
||||
></select
|
||||
>
|
||||
</div>{/if}
|
||||
{#if game}<p class="filter-hint">
|
||||
Game results include unscoped plugins that can use explicitly selected beta servers.
|
||||
</p>{/if}
|
||||
{#if updatesOpen}<details
|
||||
open
|
||||
ontoggle={(event) => {
|
||||
if (!event.currentTarget.open) updatesOpen = false;
|
||||
}}
|
||||
>
|
||||
<summary>Update check details</summary>{#key importCount}<PluginUpdates
|
||||
onchecked={(results) => (updates = results)}
|
||||
/>{/key}
|
||||
</details>{/if}
|
||||
<section class="section">
|
||||
<div class="list-heading"><span>{visible.length} of {plugins.length} plugins</span>{#if visible.length && (search || game || status)}<Button variant="ghost" size="sm" onclick={() => { search = ''; game = ''; status = ''; }}>Clear filters</Button>{/if}</div>
|
||||
<div class="list-heading">
|
||||
<span>{visible.length} of {plugins.length} plugins</span
|
||||
>{#if visible.length && (search || game || status)}<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onclick={() => {
|
||||
search = '';
|
||||
game = '';
|
||||
status = '';
|
||||
}}>Clear filters</Button
|
||||
>{/if}
|
||||
</div>
|
||||
{#if loading}
|
||||
<div class="loading">Loading…</div>
|
||||
{:else if visible.length === 0 && !flash}
|
||||
<EmptyState title={plugins.length ? 'No matching plugins' : 'No plugins yet'} description={plugins.length ? 'Try another name, game, or status.' : 'Plugins add server features. Upload a file or import a GitHub release to test it in a beta.'}>
|
||||
{#snippet actions()}{#if plugins.length}<Button onclick={() => { search = ''; game = ''; status = ''; }}>Clear filters</Button>{:else}<Button variant="primary" onclick={() => addOpen = true}>Add plugin</Button>{/if}{/snippet}
|
||||
<EmptyState
|
||||
title={plugins.length ? 'No matching plugins' : 'No plugins yet'}
|
||||
description={plugins.length
|
||||
? 'Try another name, game, or status.'
|
||||
: 'Plugins add server features. Upload a file or import a GitHub release to test it in a beta.'}
|
||||
>
|
||||
{#snippet actions()}{#if plugins.length}<Button
|
||||
onclick={() => {
|
||||
search = '';
|
||||
game = '';
|
||||
status = '';
|
||||
}}>Clear filters</Button
|
||||
>{:else}<Button variant="primary" onclick={() => (addOpen = true)}
|
||||
>Add plugin</Button
|
||||
>{/if}{/snippet}
|
||||
</EmptyState>
|
||||
{:else}
|
||||
<div class="library-table"><table>
|
||||
<thead><tr><th>Plugin</th><th>Game / scope</th><th>Version / status</th><th>Eligible servers</th><th><span class="sr-only">Next action</span></th></tr></thead>
|
||||
<tbody>{#each visible.slice(0,limit) as a (a.id)}
|
||||
{@const update = updates.find(update => update.pluginId === a.id && update.status === 'available')}
|
||||
<tr>
|
||||
<td><a class="name" href={contextHref(`/plugins/${a.id}`, $page.url)}>{a.name}</a>{#if a.target_rel_path !== `${a.name}.dll`}<span class="secondary">{a.target_rel_path}</span>{/if}
|
||||
{#if update}<span class="secondary">{update.release?.tag} available</span>{/if}</td>
|
||||
<td>{scopeLabel(a)}</td>
|
||||
<td><LibraryVersions current={a.currentVersion} latest={a.latestVersion} betaId={a.runningBetaId} /></td>
|
||||
<td class="numeric">{a.scope_type ? a.servers.length : 'Explicit targets'}</td>
|
||||
<td>{#if update}<a href={contextHref(`/plugins/${a.id}#github-releases`, $page.url)}>Review update</a>
|
||||
{:else if a.runningBetaId !== null}<a href={contextHref(`/betas/${a.runningBetaId}`, $page.url)}>View beta</a>
|
||||
{:else if a.latestVersion && a.latestVersion.id !== a.current_version_id}<a href={contextHref(`/plugins/${a.id}`, $page.url)}>Review version</a>{/if}</td>
|
||||
</tr>
|
||||
{/each}</tbody>
|
||||
</table></div>
|
||||
<div class="library-table">
|
||||
<table>
|
||||
<thead
|
||||
><tr
|
||||
><th>Plugin</th><th>Game / scope</th><th>Version / status</th><th
|
||||
>Eligible servers</th
|
||||
><th><span class="sr-only">Next action</span></th></tr
|
||||
></thead
|
||||
>
|
||||
<tbody
|
||||
>{#each visible.slice(0, limit) as a (a.id)}
|
||||
{@const update = updates.find(
|
||||
(update) =>
|
||||
update.pluginId === a.id && update.status === 'available'
|
||||
)}
|
||||
<tr>
|
||||
<td
|
||||
><a
|
||||
class="name"
|
||||
href={contextHref(`/plugins/${a.id}`, $page.url)}
|
||||
>{a.name}</a
|
||||
>{#if a.target_rel_path !== `${a.name}.dll`}<span
|
||||
class="secondary">{a.target_rel_path}</span
|
||||
>{/if}
|
||||
{#if update}<span class="secondary"
|
||||
>{update.release?.tag} available</span
|
||||
>{/if}</td
|
||||
>
|
||||
<td>{scopeLabel(a)}</td>
|
||||
<td
|
||||
><LibraryVersions
|
||||
current={a.currentVersion}
|
||||
latest={a.latestVersion}
|
||||
betaId={a.runningBetaId}
|
||||
/></td
|
||||
>
|
||||
<td class="numeric"
|
||||
>{a.scope_type ? a.servers.length : 'Explicit targets'}</td
|
||||
>
|
||||
<td
|
||||
>{#if update}<a
|
||||
href={contextHref(
|
||||
`/plugins/${a.id}#github-releases`,
|
||||
$page.url
|
||||
)}>Review update</a
|
||||
>
|
||||
{:else if a.runningBetaId !== null}<a
|
||||
href={contextHref(
|
||||
`/betas/${a.runningBetaId}`,
|
||||
$page.url
|
||||
)}>View beta</a
|
||||
>
|
||||
{:else if a.latestVersion && a.latestVersion.id !== a.current_version_id}<a
|
||||
href={contextHref(`/plugins/${a.id}`, $page.url)}
|
||||
>Review version</a
|
||||
>{/if}</td
|
||||
>
|
||||
</tr>
|
||||
{/each}</tbody
|
||||
>
|
||||
</table>
|
||||
</div>
|
||||
<ListFooter total={visible.length} bind:limit label="plugins" />
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<Dialog bind:open={addOpen} title="Add plugin" busy={uploading || githubBusy} wide>
|
||||
<Tabs tabs={[{id:'upload',label:'Upload file',disabled:uploading || githubBusy},{id:'github',label:'GitHub release',disabled:uploading || githubBusy}]} bind:value={method} ariaLabel="Plugin source" idPrefix="plugin-source" panelId="plugin-source-panel" />
|
||||
<Tabs
|
||||
tabs={[
|
||||
{ id: 'upload', label: 'Upload file', disabled: uploading || githubBusy },
|
||||
{ id: 'github', label: 'GitHub release', disabled: uploading || githubBusy }
|
||||
]}
|
||||
bind:value={method}
|
||||
ariaLabel="Plugin source"
|
||||
idPrefix="plugin-source"
|
||||
panelId="plugin-source-panel"
|
||||
/>
|
||||
<div id="plugin-source-panel" role="tabpanel" aria-labelledby={'plugin-source-' + method}>
|
||||
{#if method === 'github'}<PluginGithubImport bind:busy={githubBusy} onimport={async result => { importComplete = result; updates = updates.filter(update => update.pluginId !== result.pluginId); importCount++; addOpen = false; await load(); }} />
|
||||
{:else} <form onsubmit={createPlugin} class="upload-form">
|
||||
<Field label="Name">
|
||||
<Input bind:value={newName} placeholder="my plugin" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Release version" hint="Optional. Use the publisher’s version or release tag, such as v3.1.0.">
|
||||
<Input bind:value={newReleaseVersion} placeholder="v3.1.0" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Notes" hint="Optional. What changed in this version.">
|
||||
<Input bind:value={newNotes} placeholder="what changed" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Scope" hint="Where this plugin deploys.">
|
||||
<div class="scope-row">
|
||||
<Select ariaLabel="Scope type" bind:value={newScopeType} options={scopeTypeOptions} disabled={uploading} />
|
||||
{#if newScopeType === 'game' || newScopeType === 'map'}
|
||||
<Select ariaLabel="Scope game" bind:value={newScopeGame} onchange={() => newScopeMap = ''} options={gameOptions} disabled={uploading} />
|
||||
{/if}
|
||||
{#if newScopeType === 'map'}
|
||||
<Select ariaLabel="Scope map" bind:value={newScopeMap} options={mapOptions} disabled={uploading || !newScopeGame} />
|
||||
{/if}
|
||||
</div>
|
||||
</Field>
|
||||
<Field label="Plugin file (.dll)">
|
||||
<Input type="file" accept=".dll" onchange={pickFile} disabled={uploading} />
|
||||
</Field>
|
||||
<div class="form-actions ui-sticky-actions">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={uploading || !newFile || !newName}
|
||||
loading={uploading}
|
||||
{#if method === 'github'}<PluginGithubImport
|
||||
bind:busy={githubBusy}
|
||||
onimport={async (result) => {
|
||||
importComplete = result;
|
||||
updates = updates.filter((update) => update.pluginId !== result.pluginId);
|
||||
importCount++;
|
||||
addOpen = false;
|
||||
await load();
|
||||
}}
|
||||
/>
|
||||
{:else}
|
||||
<form onsubmit={createPlugin} class="upload-form">
|
||||
<Field label="Name">
|
||||
<Input bind:value={newName} placeholder="my plugin" disabled={uploading} />
|
||||
</Field>
|
||||
<Field
|
||||
label="Release version"
|
||||
hint="Optional. Use the publisher’s version or release tag, such as v3.1.0."
|
||||
>
|
||||
Upload plugin
|
||||
</Button>
|
||||
{#if flash}<span class="flash" role="alert">{flash}</span>{/if}
|
||||
</div>
|
||||
</form>
|
||||
{/if}
|
||||
<Input
|
||||
bind:value={newReleaseVersion}
|
||||
placeholder="v3.1.0"
|
||||
disabled={uploading}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Notes" hint="Optional. What changed in this version.">
|
||||
<Input bind:value={newNotes} placeholder="what changed" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Scope" hint="Where this plugin deploys.">
|
||||
<div class="scope-row">
|
||||
<Select
|
||||
ariaLabel="Scope type"
|
||||
bind:value={newScopeType}
|
||||
options={scopeTypeOptions}
|
||||
disabled={uploading}
|
||||
/>
|
||||
{#if newScopeType === 'game' || newScopeType === 'map'}
|
||||
<Select
|
||||
ariaLabel="Scope game"
|
||||
bind:value={newScopeGame}
|
||||
onchange={() => (newScopeMap = '')}
|
||||
options={gameOptions}
|
||||
disabled={uploading}
|
||||
/>
|
||||
{/if}
|
||||
{#if newScopeType === 'map'}
|
||||
<Select
|
||||
ariaLabel="Scope map"
|
||||
bind:value={newScopeMap}
|
||||
options={mapOptions}
|
||||
disabled={uploading || !newScopeGame}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
</Field>
|
||||
<Field label="Plugin file (.dll)">
|
||||
<Input type="file" accept=".dll" onchange={pickFile} disabled={uploading} />
|
||||
</Field>
|
||||
<div class="form-actions ui-sticky-actions">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={uploading || !newFile || !newName}
|
||||
loading={uploading}
|
||||
>
|
||||
Upload plugin
|
||||
</Button>
|
||||
{#if flash}<span class="flash" role="alert">{flash}</span>{/if}
|
||||
</div>
|
||||
</form>
|
||||
{/if}
|
||||
</div>
|
||||
</Dialog>
|
||||
<style>
|
||||
.page { display: flex; flex-direction: column; gap: var(--space-6); }
|
||||
.filter-hint { margin: 0; color: var(--text-secondary); font-size: var(--text-xs); }
|
||||
.loading { text-align: center; padding: var(--space-12); color: var(--text-tertiary); }
|
||||
|
||||
.upload-form { margin-top: 20px; }
|
||||
<style>
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-6);
|
||||
}
|
||||
.filter-hint {
|
||||
margin: 0;
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: var(--space-12);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.upload-form {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.banner {
|
||||
display: flex; flex-direction: column; gap: 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
margin-bottom: var(--space-4);
|
||||
background: rgba(124, 212, 255, 0.06);
|
||||
@@ -279,17 +561,67 @@
|
||||
border-radius: var(--radius-md);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
.banner a { color: var(--state-online); text-decoration: underline; }
|
||||
.banner a {
|
||||
color: var(--state-online);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.upload-form { display: grid; gap: var(--space-4); grid-template-columns: 1fr 1fr; }
|
||||
.scope-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
|
||||
.scope-row :global(.wrap) { flex: 1 1 140px; min-width: 140px; }
|
||||
.form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
|
||||
.flash { color: var(--state-danger); font-family: var(--font-mono); font-size: var(--text-xs); }
|
||||
.upload-form {
|
||||
display: grid;
|
||||
gap: var(--space-4);
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.scope-row {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.scope-row :global(.wrap) {
|
||||
flex: 1 1 140px;
|
||||
min-width: 140px;
|
||||
}
|
||||
.form-actions {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
}
|
||||
.flash {
|
||||
color: var(--state-danger);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
|
||||
.section { display: flex; flex-direction: column; gap: var(--space-3); }
|
||||
.list-heading { display:flex; gap:16px; align-items:center; color:var(--text-secondary); font-size:var(--text-xs); }
|
||||
summary { cursor:pointer; color:var(--text-secondary); font-size:var(--text-sm); margin-bottom:12px; }
|
||||
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
|
||||
@media (max-width: 720px) { .upload-form { grid-template-columns: 1fr; } }
|
||||
.section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.list-heading {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
summary {
|
||||
cursor: pointer;
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--text-sm);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.upload-form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user