mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 16:17:25 +08:00
fix(em): incorrect extension compatibility check (#4155)
This commit is contained in:
parent
e73ffee9e7
commit
9d611d1ee2
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -70,5 +70,6 @@
|
||||
}
|
||||
|
||||
.Badge--success {
|
||||
--badge-bg: var(--success-color);
|
||||
--badge-color: var(--control-success-color);
|
||||
--badge-bg: var(--control-success-bg);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user