Skip to content

Commit

Permalink
Fix logic plugin update and show installed version
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Oct 25, 2023
1 parent c0da5d0 commit 929bba9
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions web/screens/Settings/CorePlugins/PluginsCatalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,16 @@ const PluginCatalog = () => {
)
.map((item, i) => {
const isActivePlugin = activePlugins.some((x) => x.name === item.name)
const installedPlugin = activePlugins.filter(
(p) => p.name === item.name
)[0]
const updateVersionPlugins = Number(
activePlugins
.filter((p) => p.name === item.name)[0]
?.version.replaceAll('.', '')
installedPlugin?.version.replaceAll('.', '')
)

const hasUpdateVersionPlugins =
item.version.replaceAll('.', '') > updateVersionPlugins

return (
<div
key={i}
Expand All @@ -155,16 +160,23 @@ const PluginCatalog = () => {
<p className="whitespace-pre-wrap leading-relaxed text-gray-600 dark:text-gray-400">
{item.description}
</p>
{isActivePlugin &&
item.version.replaceAll('.', '') < updateVersionPlugins && (
<Button
size="sm"
themes="outline"
onClick={() => downloadTarball(item.name)}
>
Update
</Button>
)}
{isActivePlugin && (
<p className="whitespace-pre-wrap leading-relaxed text-gray-600 dark:text-gray-400">
Installed{' '}
{hasUpdateVersionPlugins
? `v${installedPlugin.version}`
: 'latest version'}
</p>
)}
{isActivePlugin && hasUpdateVersionPlugins && (
<Button
size="sm"
themes="outline"
onClick={() => downloadTarball(item.name)}
>
Update
</Button>
)}
</div>
<Switch
checked={isActivePlugin}
Expand Down

0 comments on commit 929bba9

Please sign in to comment.