1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 15:37:51 +02:00

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
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'); locale = Model.attribute<string>('locale');
latestFlarumVersionSupported = Model.attribute<string>('latestFlarumVersionSupported'); latestFlarumVersionSupported = Model.attribute<string>('latestFlarumVersionSupported');
downloads = Model.attribute<number>('downloads'); downloads = Model.attribute<number>('downloads');
isSupported = Model.attribute<boolean>('isSupported');
readonly installed = false; 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 { public isProductionReady(): boolean {
return isProductionReady(this.highestVersion()); return isProductionReady(this.highestVersion());
} }

View File

@@ -9,6 +9,7 @@
namespace Flarum\ExtensionManager\Api\Resource; namespace Flarum\ExtensionManager\Api\Resource;
use Composer\Semver\Semver;
use Flarum\Api\Endpoint; use Flarum\Api\Endpoint;
use Flarum\Api\Resource\AbstractResource; use Flarum\Api\Resource\AbstractResource;
use Flarum\Api\Resource\Contracts\Countable; use Flarum\Api\Resource\Contracts\Countable;
@@ -81,6 +82,11 @@ class ExternalExtensionResource extends AbstractResource implements Listable, Pa
Schema\Boolean::make('compatibleWithLatestFlarum') Schema\Boolean::make('compatibleWithLatestFlarum')
->property('compatible_with_latest_flarum'), ->property('compatible_with_latest_flarum'),
Schema\Integer::make('downloads'), 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--success {
--badge-bg: var(--success-color); --badge-color: var(--control-success-color);
--badge-bg: var(--control-success-bg);
} }