diff --git a/extensions/package-manager/js/src/admin/components/Updater.tsx b/extensions/package-manager/js/src/admin/components/Updater.tsx index bfc47b7d72..898dad6af5 100755 --- a/extensions/package-manager/js/src/admin/components/Updater.tsx +++ b/extensions/package-manager/js/src/admin/components/Updater.tsx @@ -7,6 +7,7 @@ import MajorUpdater from './MajorUpdater'; import ExtensionItem from './ExtensionItem'; import { Extension } from 'flarum/admin/AdminApplication'; import ItemList from 'flarum/common/utils/ItemList'; +import { isProductionReady } from '../utils/versions'; export interface IUpdaterAttrs extends ComponentAttrs {} @@ -24,7 +25,7 @@ export default class Updater extends Component {
{this.controlItems().toArray()}
{this.availableUpdatesView()} , - core && core.package['latest-major'] ? ( + core && core.package['latest-major'] && isProductionReady(core.package['latest-major']) ? ( ) : null, ]; diff --git a/extensions/package-manager/js/src/admin/utils/versions.ts b/extensions/package-manager/js/src/admin/utils/versions.ts new file mode 100644 index 0000000000..175c00f1e1 --- /dev/null +++ b/extensions/package-manager/js/src/admin/utils/versions.ts @@ -0,0 +1,32 @@ +export enum VersionStability { + Stable = 'stable', + Alpha = 'alpha', + Beta = 'beta', + RC = 'rc', + Dev = 'dev', +} + +export function isProductionReady(version: string): boolean { + return [VersionStability.Stable].includes(stability(version)); +} + +export function stability(version: string): VersionStability { + const split = version.split('-'); + + if (split.length === 1) { + return VersionStability.Stable; + } + + const stab = split[1].split('.')[0].toLowerCase(); + + switch (stab) { + case 'alpha': + return VersionStability.Alpha; + case 'beta': + return VersionStability.Beta; + case 'rc': + return VersionStability.RC; + default: + return VersionStability.Dev; + } +}