packaged plugins

This commit is contained in:
Jan Prochazka
2021-04-15 10:52:02 +02:00
parent 4d5cc119f2
commit 5dd03484ea
9 changed files with 700 additions and 87 deletions

View File

@@ -23,7 +23,11 @@
<div class="ml-2">
<div class="flex">
<div class="bold">{packageManifest.name}</div>
<div class="ml-1">{packageManifest.version}</div>
{#if packageManifest.isPackaged}
<div class="ml-1 builtin">(builtin)</div>
{:else}
<div class="ml-1">{packageManifest.version}</div>
{/if}
</div>
<div>
{packageManifest.description}
@@ -48,4 +52,8 @@
width: 50px;
height: 50px;
}
.builtin {
color: var(--theme-font-3);
}
</style>

View File

@@ -5,7 +5,7 @@
<script lang="ts">
import compareVersions from 'compare-versions';
import FormStyledButton from '../elements/FormStyledButton.svelte';
import Markdown from '../elements/Markdown.svelte';
import Markdown from '../elements/Markdown.svelte';
import { extractPluginAuthor, extractPluginIcon } from '../plugins/manifestExtractors';
import axiosInstance from '../utility/axiosInstance';
@@ -24,6 +24,7 @@ import Markdown from '../elements/Markdown.svelte';
});
$: readme = $info?.readme;
$: manifest = $info?.manifest;
$: isPackaged = $info?.isPackaged;
const handleInstall = async () => {
axiosInstance.post('plugins/install', { packageName });
@@ -59,17 +60,21 @@ import Markdown from '../elements/Markdown.svelte';
<span> | </span>
<span>{installedFound ? installedFound.version : manifest.version}</span>
</div>
<div class="mt-1">
{#if hasPermission('plugins/install') && !installedFound}
<FormStyledButton type="button" value="Install" on:click={handleInstall} />
{/if}
{#if hasPermission('plugins/install') && installedFound}
<FormStyledButton type="button" value="Uninstall" on:click={handleUninstall} />
{/if}
{#if hasPermission('plugins/install') && installedFound && onlineFound && compareVersions(onlineFound.version, installedFound.version) > 0}
<FormStyledButton type="button" value="Upgrade" on:click={handleUpgrade} />
{/if}
</div>
{#if isPackaged}
<div class="mt-2">Plugin is part of DbGate installation</div>
{:else}
<div class="mt-1">
{#if hasPermission('plugins/install') && !installedFound}
<FormStyledButton type="button" value="Install" on:click={handleInstall} />
{/if}
{#if hasPermission('plugins/install') && installedFound}
<FormStyledButton type="button" value="Uninstall" on:click={handleUninstall} />
{/if}
{#if hasPermission('plugins/install') && installedFound && onlineFound && compareVersions(onlineFound.version, installedFound.version) > 0}
<FormStyledButton type="button" value="Upgrade" on:click={handleUpgrade} />
{/if}
</div>
{/if}
</div>
</div>
<Markdown source={readme} />