Fix logic plugin update and show installed version
This commit is contained in:
parent
75ef06df23
commit
38992bcc2e
@ -141,11 +141,16 @@ const PluginCatalog = () => {
|
|||||||
)
|
)
|
||||||
.map((item, i) => {
|
.map((item, i) => {
|
||||||
const isActivePlugin = activePlugins.some((x) => x.name === item.name)
|
const isActivePlugin = activePlugins.some((x) => x.name === item.name)
|
||||||
|
const installedPlugin = activePlugins.filter(
|
||||||
|
(p) => p.name === item.name
|
||||||
|
)[0]
|
||||||
const updateVersionPlugins = Number(
|
const updateVersionPlugins = Number(
|
||||||
activePlugins
|
installedPlugin?.version.replaceAll('.', '')
|
||||||
.filter((p) => p.name === item.name)[0]
|
|
||||||
?.version.replaceAll('.', '')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const hasUpdateVersionPlugins =
|
||||||
|
item.version.replaceAll('.', '') > updateVersionPlugins
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
@ -163,16 +168,23 @@ const PluginCatalog = () => {
|
|||||||
<p className="whitespace-pre-wrap leading-relaxed text-gray-600 dark:text-gray-400">
|
<p className="whitespace-pre-wrap leading-relaxed text-gray-600 dark:text-gray-400">
|
||||||
{item.description}
|
{item.description}
|
||||||
</p>
|
</p>
|
||||||
{isActivePlugin &&
|
{isActivePlugin && (
|
||||||
item.version.replaceAll('.', '') < updateVersionPlugins && (
|
<p className="whitespace-pre-wrap leading-relaxed text-gray-600 dark:text-gray-400">
|
||||||
<Button
|
Installed{' '}
|
||||||
size="sm"
|
{hasUpdateVersionPlugins
|
||||||
themes="outline"
|
? `v${installedPlugin.version}`
|
||||||
onClick={() => downloadTarball(item.name)}
|
: 'latest version'}
|
||||||
>
|
</p>
|
||||||
Update
|
)}
|
||||||
</Button>
|
{isActivePlugin && hasUpdateVersionPlugins && (
|
||||||
)}
|
<Button
|
||||||
|
size="sm"
|
||||||
|
themes="outline"
|
||||||
|
onClick={() => downloadTarball(item.name)}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
<Switch
|
||||||
checked={isActivePlugin}
|
checked={isActivePlugin}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user