Improve editor, plugin updates, and window transfers for 0.1.41
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
let cancelButton: HTMLButtonElement | undefined = $state();
|
||||
let previous: HTMLElement | null = null;
|
||||
const external = $derived($installedPlugins.plugins);
|
||||
const hasUpdates = $derived(candidates.some(candidate => external.some(plugin => plugin.manifest.id === candidate.manifest?.id)));
|
||||
$effect(() => {
|
||||
if (modal && (plan || candidates.length || gitForm)) {
|
||||
if (!modal.open) { previous = document.activeElement instanceof HTMLElement ? document.activeElement : null; modal.showModal(); }
|
||||
@@ -55,7 +56,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 => $t(enabled ? "{name} installed and enabled." : "{name} installed.", { name: item.name })).join(" ");
|
||||
message = result.filter(item => !item.error).map(item => $t("{name}: package applied.", { 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();
|
||||
@@ -103,6 +104,7 @@
|
||||
|
||||
<h2>{$t("Plug-ins")}</h2>
|
||||
<p>{$t("Install a plugin ZIP file or get a release from a Git repository link.")}</p>
|
||||
<p>{$t("To update a plugin, select its new ZIP or release link. Its settings and enabled state stay the same.")}</p>
|
||||
<div class="toolbar">
|
||||
<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>
|
||||
@@ -180,12 +182,15 @@
|
||||
<div class="candidate">
|
||||
<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}
|
||||
{#each external.filter(plugin => plugin.manifest.id === candidate.manifest?.id) as installed}
|
||||
<p>{$t("Update {current} → {next}. Settings and enabled state stay the same.", { current: installed.manifest.version, next: candidate.manifest!.version })}</p>
|
||||
{/each}
|
||||
<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()}>{$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>
|
||||
<footer><button bind:this={cancelButton} disabled={busy} onclick={() => cancel()}>{$t("Cancel")}</button><button disabled={busy || !selected.length} onclick={() => install(false)}>{$t(hasUpdates ? "Apply packages" : "Install")}</button>{#if !hasUpdates}<button disabled={busy || !selected.length} onclick={() => install(true)}>{$t("Install and enable")}</button>{/if}</footer>
|
||||
{/if}
|
||||
</dialog>
|
||||
{/if}
|
||||
@@ -221,6 +226,7 @@
|
||||
footer { justify-content: flex-end; margin-top: var(--rs-settings-section-gap); }
|
||||
.candidate { padding: var(--rs-settings-row-padding) 0; border-bottom: 1px solid var(--rs-border); }
|
||||
.candidate label { display: flex; gap: 8px; }
|
||||
input[type=checkbox] { accent-color: var(--rs-accent); }
|
||||
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
|
||||
.field input { min-width: 0; min-height: var(--rs-settings-control-height); padding: 4px 8px; color: var(--rs-text); background: var(--rs-bg-elevated); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); }
|
||||
@media (max-width: 420px) {
|
||||
|
||||
Reference in New Issue
Block a user