Add interface languages and improve themes and workspace controls for 0.1.36
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { onDestroy } from "svelte";
|
||||
import { invoke, isTauri } from "@tauri-apps/api/core";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
@@ -54,7 +55,7 @@
|
||||
async function install(enabled: boolean) {
|
||||
await run(async () => {
|
||||
const result = await invoke<{ name: string; error: string | null }[]>("plugins_install", { tokens: selected, enabled });
|
||||
message = result.filter(item => !item.error).map(item => `${item.name} installed${enabled ? " and enabled" : ""}.`).join(" ");
|
||||
message = result.filter(item => !item.error).map(item => $t(enabled ? "{name} installed and enabled." : "{name} installed.", { name: item.name })).join(" ");
|
||||
error = result.filter(item => item.error).map(item => `${item.name}: ${item.error}`).join("\n");
|
||||
await invoke("plugins_cancel", { tokens: candidates.map(item => item.token) });
|
||||
candidates = []; selected = []; await refreshPlugins(); previous?.focus();
|
||||
@@ -74,7 +75,7 @@
|
||||
async function toggle(id: string, enabled: boolean, hash?: string) {
|
||||
await run(async () => {
|
||||
await setPluginEnabled(id, enabled, hash);
|
||||
message = "Changes saved.";
|
||||
message = $t("Changes saved.");
|
||||
});
|
||||
}
|
||||
async function prepare(plugin: InstalledPlugin) {
|
||||
@@ -84,7 +85,7 @@
|
||||
if (!plan) return;
|
||||
const current = plan;
|
||||
await run(async () => {
|
||||
try { await invoke("plugins_remove", { token: current.token }); message = `${current.plugin.manifest.name} uninstalled. Settings and workspace documents were kept.`; }
|
||||
try { await invoke("plugins_remove", { token: current.token }); message = $t("{name} uninstalled. Settings and workspace documents were kept.", { name: current.plugin.manifest.name }); }
|
||||
finally { plan = null; await refreshPlugins(); previous?.focus(); }
|
||||
});
|
||||
}
|
||||
@@ -100,91 +101,91 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<h2>Plug-ins</h2>
|
||||
<p>Install a plugin ZIP file or get a release from a Git repository link.</p>
|
||||
<h2>{$t("Plug-ins")}</h2>
|
||||
<p>{$t("Install a plugin ZIP file or get a release from a Git repository link.")}</p>
|
||||
<div class="toolbar">
|
||||
<button disabled={!desktop || busy} onclick={() => choose()}><Icon icon="file-plus" />Install plugin ZIP</button>
|
||||
<button disabled={!desktop || busy} onclick={() => { error = ""; gitForm = true; }}><Icon icon="link" />Install from Git link</button>
|
||||
<IconButton icon="folder-open" label="Open plugins folder" disabled={!desktop || busy} onclick={() => reveal()} />
|
||||
<button disabled={!desktop || busy} onclick={() => run(refreshPlugins)}><Icon icon="refresh" />Refresh</button>
|
||||
<button disabled={!desktop || busy} onclick={() => choose()}><Icon icon="file-plus" />{$t("Install plugin ZIP")}</button>
|
||||
<button disabled={!desktop || busy} onclick={() => { error = ""; gitForm = true; }}><Icon icon="link" />{$t("Install from Git link")}</button>
|
||||
<IconButton icon="folder-open" label={$t("Open plugins folder")} disabled={!desktop || busy} onclick={() => reveal()} />
|
||||
<button disabled={!desktop || busy} onclick={() => run(refreshPlugins)}><Icon icon="refresh" />{$t("Refresh")}</button>
|
||||
</div>
|
||||
{#if $installedPlugins.root}<p class="path">{$installedPlugins.root}</p>{/if}
|
||||
{#if !desktop}<p>Installation requires the RuneStone desktop app.</p>{/if}
|
||||
{#if !desktop}<p>{$t("Installation requires the RuneStone desktop app.")}</p>{/if}
|
||||
{#if $pluginServiceError}<p class="error" role="alert">{$pluginServiceError}</p>{/if}
|
||||
<h3>Installed plugins</h3>
|
||||
<p class="note">Plugins run with RuneStone's access. Only enable code you trust.</p>
|
||||
{#if !external.length}<p>No plugins installed.</p>{/if}
|
||||
<h3>{$t("Installed plugins")}</h3>
|
||||
<p class="note">{$t("Plugins run with RuneStone's access. Only enable code you trust.")}</p>
|
||||
{#if !external.length}<p>{$t("No plugins installed.")}</p>{/if}
|
||||
{#each external as plugin (plugin.manifest.id)}
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<div class="plugin-copy"><label for={`external-${plugin.manifest.id}`}>{plugin.manifest.name}</label><p>{plugin.manifest.description}</p><small>{plugin.manifest.author} · {plugin.manifest.version} · Full app access</small>
|
||||
<div class="plugin-copy"><label for={`external-${plugin.manifest.id}`}>{plugin.manifest.name}</label><p>{plugin.manifest.description}</p><small>{plugin.manifest.author} · {plugin.manifest.version} · {$t("Full app access")}</small>
|
||||
<div class="status">
|
||||
<span class="badge">{plugin.manifest.id === "runestone.browser" ? "Included with RuneStone" : plugin.removal ? "Removal incomplete" : plugin.enabled ? "Enabled" : "Disabled"}</span>
|
||||
<span class="badge">{plugin.manifest.id === "runestone.browser" ? $t("Included with RuneStone") : plugin.removal ? $t("Removal incomplete") : plugin.enabled ? $t("Enabled") : $t("Disabled")}</span>
|
||||
<span class="note">
|
||||
{#if plugin.installedAt != null}
|
||||
Installed <time datetime={new Date(plugin.installedAt).toISOString()}>{installDateFormat.format(plugin.installedAt)}</time>
|
||||
{$t("Installed")} <time datetime={new Date(plugin.installedAt).toISOString()}>{installDateFormat.format(plugin.installedAt)}</time>
|
||||
{:else}
|
||||
Install date unknown
|
||||
{$t("Install date unknown")}
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id={`external-${plugin.manifest.id}`} type="checkbox" role="switch" checked={plugin.manifest.id === "runestone.browser" || plugin.enabled} disabled={busy || plugin.removal || plugin.manifest.id === "runestone.browser"} onchange={event => { const value = event.currentTarget.checked; event.currentTarget.checked = plugin.enabled; void toggle(plugin.manifest.id, value, plugin.hash); }} />
|
||||
<IconButton icon="folder-open" label="Show files" disabled={busy || plugin.removal} onclick={() => reveal(plugin.manifest.id)} />
|
||||
<IconButton icon="folder-open" label={$t("Show files")} disabled={busy || plugin.removal} onclick={() => reveal(plugin.manifest.id)} />
|
||||
{#if plugin.removal}
|
||||
<button disabled={busy} onclick={() => run(async () => { await invoke("plugins_retry_remove", { id: plugin.manifest.id }); await refreshPlugins(); message = "Plugin file cleanup completed."; })}><Icon icon="refresh" />Retry cleanup</button>
|
||||
<button disabled={busy} onclick={() => run(async () => { await invoke("plugins_retry_remove", { id: plugin.manifest.id }); await refreshPlugins(); message = $t("Plugin file cleanup completed."); })}><Icon icon="refresh" />{$t("Retry cleanup")}</button>
|
||||
{:else}
|
||||
<span class="danger"><IconButton icon="trash" label="Uninstall" disabled={busy} onclick={() => prepare(plugin)} /></span>
|
||||
<span class="danger"><IconButton icon="trash" label={$t("Uninstall")} disabled={busy} onclick={() => prepare(plugin)} /></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if plugin.manifest.id === "runestone.browser"}<p class="note">Browser is now built in. You can remove this old package. Your browser profiles and bookmarks stay available.</p>{/if}
|
||||
{#if plugin.manifest.id === "runestone.browser"}<p class="note">{$t("Browser is now built in. You can remove this old package. Your browser profiles and bookmarks stay available.")}</p>{/if}
|
||||
{#if plugin.error || $externalErrors[plugin.manifest.id]}<p class="error" role="alert">{plugin.error || $externalErrors[plugin.manifest.id]}</p>{/if}
|
||||
</div>
|
||||
{/each}
|
||||
{#if $restartPlugins.length}<p class="note" role="status">Restart RuneStone to clear all code from plugins that stopped in this window.</p>{/if}
|
||||
{#if $restartPlugins.length}<p class="note" role="status">{$t("Restart RuneStone to clear all code from plugins that stopped in this window.")}</p>{/if}
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
{#if message}<p class="saved" role="status">{message}</p>{/if}
|
||||
|
||||
{#if candidates.length || plan || gitForm}
|
||||
<dialog bind:this={modal} aria-labelledby="plugin-dialog-title" onkeydown={trap} oncancel={event => { event.preventDefault(); event.stopPropagation(); void cancel(); }}>
|
||||
{#if gitForm}
|
||||
<h2 id="plugin-dialog-title">Install from Git link</h2>
|
||||
<p>Get a Gitea release ZIP, then review it before installation. Git-link installation is an experimental feature.</p>
|
||||
<h2 id="plugin-dialog-title">{$t("Install from Git link")}</h2>
|
||||
<p>{$t("Get a Gitea release ZIP, then review it before installation. Git-link installation is an experimental feature.")}</p>
|
||||
<form onsubmit={event => { event.preventDefault(); if (!busy) void fromGit(); }}>
|
||||
<label class="field">Repository link<input type="url" required bind:value={gitUrl} disabled={busy} placeholder="https://host/owner/repository" /></label>
|
||||
<label class="field">Release tag (optional)<input bind:value={gitTag} disabled={busy} placeholder="Latest release" maxlength="200" /></label>
|
||||
<label class="field">Access token (optional)<input type="password" bind:value={gitToken} disabled={busy} autocomplete="off" /></label>
|
||||
<p class="note">Private repositories need a token with read access. RuneStone does not save the token.</p>
|
||||
{#if gitUrl.trim().startsWith("http:")}<p class="note">HTTP sends the token and package without encryption. Use it only for a trusted local server.</p>{/if}
|
||||
<label class="field">{$t("Repository link")}<input type="url" required bind:value={gitUrl} disabled={busy} placeholder="https://host/owner/repository" /></label>
|
||||
<label class="field">{$t("Release tag (optional)")}<input bind:value={gitTag} disabled={busy} placeholder={$t("Latest release")} maxlength="200" /></label>
|
||||
<label class="field">{$t("Access token (optional)")}<input type="password" bind:value={gitToken} disabled={busy} autocomplete="off" /></label>
|
||||
<p class="note">{$t("Private repositories need a token with read access. RuneStone does not save the token.")}</p>
|
||||
{#if gitUrl.trim().startsWith("http:")}<p class="note">{$t("HTTP sends the token and package without encryption. Use it only for a trusted local server.")}</p>{/if}
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<footer><button type="button" bind:this={cancelButton} disabled={busy} onclick={() => cancel()}>Cancel</button><button type="submit" disabled={busy || !gitUrl.trim()}><Icon icon="link" />{busy ? "Downloading…" : "Review release"}</button></footer>
|
||||
<footer><button type="button" bind:this={cancelButton} disabled={busy} onclick={() => cancel()}>{$t("Cancel")}</button><button type="submit" disabled={busy || !gitUrl.trim()}><Icon icon="link" />{busy ? $t("Downloading…") : $t("Review release")}</button></footer>
|
||||
</form>
|
||||
{:else if plan}
|
||||
<h2 id="plugin-dialog-title">{`Uninstall ${plan.plugin.manifest.name}?`}</h2>
|
||||
<h2 id="plugin-dialog-title">{$t("Uninstall {name}?", { name: plan.plugin.manifest.name })}</h2>
|
||||
<p>{plan.plugin.manifest.author} · {plan.plugin.manifest.version}</p>
|
||||
<p class="path">{plan.plugin.path}</p>
|
||||
<p>This stops the plugin in every window and permanently deletes its installed folder. Settings, source packages, and workspace documents stay intact.</p>
|
||||
<p>{$t("This stops the plugin in every window and permanently deletes its installed folder. Settings, source packages, and workspace documents stay intact.")}</p>
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<footer>
|
||||
<button bind:this={cancelButton} disabled={busy} onclick={() => cancel()}>Cancel</button>
|
||||
<button disabled={busy} onclick={async () => { const current = plan; await cancel(); if (current) await toggle(current.plugin.manifest.id, false); }}>Disable instead</button>
|
||||
<button class="danger" disabled={busy} onclick={event => { if (event.detail < 2) void remove(); }}>{busy ? "Removing…" : "Uninstall and delete files"}</button>
|
||||
<button bind:this={cancelButton} disabled={busy} onclick={() => cancel()}>{$t("Cancel")}</button>
|
||||
<button disabled={busy} onclick={async () => { const current = plan; await cancel(); if (current) await toggle(current.plugin.manifest.id, false); }}>{$t("Disable instead")}</button>
|
||||
<button class="danger" disabled={busy} onclick={event => { if (event.detail < 2) void remove(); }}>{busy ? $t("Removing…") : $t("Uninstall and delete files")}</button>
|
||||
</footer>
|
||||
{:else}
|
||||
<h2 id="plugin-dialog-title">Review plugin installation</h2>
|
||||
<p>Plugins run with RuneStone's access. Only enable code you trust.</p>
|
||||
<h2 id="plugin-dialog-title">{$t("Review plugin installation")}</h2>
|
||||
<p>{$t("Plugins run with RuneStone's access. Only enable code you trust.")}</p>
|
||||
{#each candidates as candidate (candidate.token)}
|
||||
<div class="candidate">
|
||||
<label><input type="checkbox" bind:group={selected} value={candidate.token} disabled={busy || !!candidate.error} />{candidate.manifest?.name ?? "Invalid package"}</label>
|
||||
{#if candidate.manifest}<p>{candidate.manifest.author} · {candidate.manifest.version}</p><p>{candidate.manifest.description}</p><p class="path">Destination: {$installedPlugins.root}\{candidate.manifest.id}</p>{/if}
|
||||
<p class="path">Source: {candidate.source}</p>
|
||||
<label><input type="checkbox" bind:group={selected} value={candidate.token} disabled={busy || !!candidate.error} />{candidate.manifest?.name ?? $t("Invalid package")}</label>
|
||||
{#if candidate.manifest}<p>{candidate.manifest.author} · {candidate.manifest.version}</p><p>{candidate.manifest.description}</p><p class="path">{$t("Destination: {path}", { path: `${$installedPlugins.root}\\${candidate.manifest.id}` })}</p>{/if}
|
||||
<p class="path">{$t("Source: {path}", { path: candidate.source })}</p>
|
||||
{#if candidate.error}<p class="error">{candidate.error}</p>{/if}
|
||||
</div>
|
||||
{/each}
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<footer><button bind:this={cancelButton} disabled={busy} onclick={() => cancel()}>Cancel</button><button disabled={busy || !selected.length} onclick={() => install(false)}>Install</button><button disabled={busy || !selected.length} onclick={() => install(true)}>Install and enable</button></footer>
|
||||
<footer><button bind:this={cancelButton} disabled={busy} onclick={() => cancel()}>{$t("Cancel")}</button><button disabled={busy || !selected.length} onclick={() => install(false)}>{$t("Install")}</button><button disabled={busy || !selected.length} onclick={() => install(true)}>{$t("Install and enable")}</button></footer>
|
||||
{/if}
|
||||
</dialog>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user