Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: plugins with updates disabled are still shown as updatable #1772

Merged
merged 6 commits into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/server-admin-ui/src/views/appstore/Apps/Apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Apps = function (props) {
(allApps[app.name] = {
...app,
installed: true,
newVersion: app.installedVersion !== app.version ? app.version : null,
newVersion: updateAvailable(app, props.appStore) ? app.version : null,
})
)
props.appStore.installing.forEach(
Expand Down Expand Up @@ -70,7 +70,7 @@ const Apps = function (props) {
'Please restart the server after installing, updating or deleting a plugin'
}

const selectedViewFilter = selectedViewToFilter(view)
const selectedViewFilter = selectedViewToFilter(view, props.appStore)
const selectedCategoryFilter =
category === 'All' ? () => true : (app) => app.categories.includes(category)
const textSearchFilter =
Expand Down Expand Up @@ -176,14 +176,24 @@ const Apps = function (props) {
)
}

const selectedViewToFilter = (selectedView) => {
const selectedViewToFilter = (selectedView, appStore) => {
if (selectedView === 'Installed') {
return (app) => app.installing || app.installedVersion
} else if (selectedView === 'Updates') {
return (app) => app.installedVersion && app.version !== app.installedVersion
return (app) => updateAvailable(app, appStore)
}
return () => true
}

const updateAvailable = (app, appStore) => {
return (
app.installedVersion &&
app.version !== app.installedVersion &&
//Don't allow updates for plugins in the PLUGINS_WITH_UPDATE_DISABLED
//environment variable
appStore.updates.find((update) => update.name === app.name)
)
}

const mapStateToProps = ({ appStore }) => ({ appStore })
export default connect(mapStateToProps)(Apps)