fix(em): incorrect extension compatibility check (#4155)

This commit is contained in:
Sami Mazouz 2025-01-04 11:05:38 +01:00 committed by GitHub
parent e73ffee9e7
commit 9d611d1ee2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 14 deletions

View File

@ -22,21 +22,9 @@ export default class ExternalExtension extends Model {
locale = Model.attribute<string>('locale');
latestFlarumVersionSupported = Model.attribute<string>('latestFlarumVersionSupported');
downloads = Model.attribute<number>('downloads');
isSupported = Model.attribute<boolean>('isSupported');
readonly installed = false;
public isSupported(): boolean {
const currentVersion = app.data.settings.version;
const latestCompatibleVersion = this.latestFlarumVersionSupported();
// If stability is not the same, it's not compatible.
if (currentVersion.split('-')[1] !== latestCompatibleVersion.split('-')[1]) {
return false;
}
// Minor versions are compatible.
return currentVersion.split('.')[0] === latestCompatibleVersion.split('.')[0];
}
public isProductionReady(): boolean {
return isProductionReady(this.highestVersion());
}

View File

@ -9,6 +9,7 @@
namespace Flarum\ExtensionManager\Api\Resource;
use Composer\Semver\Semver;
use Flarum\Api\Endpoint;
use Flarum\Api\Resource\AbstractResource;
use Flarum\Api\Resource\Contracts\Countable;
@ -81,6 +82,11 @@ class ExternalExtensionResource extends AbstractResource implements Listable, Pa
Schema\Boolean::make('compatibleWithLatestFlarum')
->property('compatible_with_latest_flarum'),
Schema\Integer::make('downloads'),
Schema\Boolean::make('isSupported')
->get(function (Extension $extension) {
return Semver::satisfies(Application::VERSION, $extension->latest_flarum_version_supported);
}),
];
}

View File

@ -70,5 +70,6 @@
}
.Badge--success {
--badge-bg: var(--success-color);
--badge-color: var(--control-success-color);
--badge-bg: var(--control-success-bg);
}