diff --git a/extensions/package-manager/js/src/admin/components/ExtensionItem.tsx b/extensions/package-manager/js/src/admin/components/ExtensionItem.tsx index aa313800ac..17eebb4374 100644 --- a/extensions/package-manager/js/src/admin/components/ExtensionItem.tsx +++ b/extensions/package-manager/js/src/admin/components/ExtensionItem.tsx @@ -75,6 +75,6 @@ export default class ExtensionItem +
flarum logo

{app.translator.trans('flarum-package-manager.admin.major_updater.description')}

diff --git a/extensions/package-manager/js/src/admin/components/Updater.tsx b/extensions/package-manager/js/src/admin/components/Updater.tsx index 9cf086fda5..cd0d5732d2 100755 --- a/extensions/package-manager/js/src/admin/components/Updater.tsx +++ b/extensions/package-manager/js/src/admin/components/Updater.tsx @@ -56,12 +56,12 @@ export default class Updater extends Component { ); } - if (!(state.extensionUpdates.length || state.coreUpdate)) { + const hasMinorCoreUpdate = state.coreUpdate && state.coreUpdate.package['latest-minor']; + + if (!(state.extensionUpdates.length || hasMinorCoreUpdate)) { return (
- - {app.translator.trans('flarum-package-manager.admin.updater.up_to_date')} - + {app.translator.trans('flarum-package-manager.admin.updater.up_to_date')}
); } @@ -69,10 +69,10 @@ export default class Updater extends Component { return (
- {state.coreUpdate ? ( + {hasMinorCoreUpdate ? ( state.updateCoreMinor()} whyNotWarning={state.lastUpdateRun.limitedPackages().includes('flarum/core')} diff --git a/extensions/package-manager/less/admin/ControlSection.less b/extensions/package-manager/less/admin/ControlSection.less index 14eafb5f1a..489c738c47 100644 --- a/extensions/package-manager/less/admin/ControlSection.less +++ b/extensions/package-manager/less/admin/ControlSection.less @@ -15,10 +15,12 @@ } .PackageManager-extensions { + width: 100%; + &-grid { --gap: 12px; display: grid; - grid-template-columns: repeat(auto-fit, calc(~"100% / 3 - var(--gap)")); + grid-template-columns: repeat(auto-fit, 310px); gap: var(--gap); } } @@ -86,12 +88,35 @@ grid-template-areas: "title logo" "helpText logo" - "controls logo" - "extensions extensions" - "failure failure"; - grid-gap: 0 var(--space); + "controls logo"; + column-gap: 0 var(--space); align-items: center; + &--failed&--incompatibleExtensions { + grid-template-areas: + "title logo" + "helpText logo" + "controls logo" + "extensions extensions" + "failure failure"; + } + + &--failed { + grid-template-areas: + "title logo" + "helpText logo" + "controls logo" + "failure failure"; + } + + &--incompatibleExtensions { + grid-template-areas: + "title logo" + "helpText logo" + "controls logo" + "extensions extensions"; + } + > img { grid-area: logo; } @@ -116,6 +141,10 @@ padding-top: var(--space); border-top: 1px solid var(--control-bg); } + + .PackageManager-updaterControls { + margin: 0; + } } .WhyNotModal { @@ -131,3 +160,7 @@ width: 300px; } } + +.PackageManager-controlSection .container { + max-width: 1030px; +} diff --git a/extensions/package-manager/locale/en.yml b/extensions/package-manager/locale/en.yml index 607449dfb0..19b7252115 100755 --- a/extensions/package-manager/locale/en.yml +++ b/extensions/package-manager/locale/en.yml @@ -25,7 +25,9 @@ flarum-package-manager: The package manager requires read and write permissions on the following files and directories: composer.json, composer.lock, vendor, storage, storage/.composer major_updater: - description: Major Flarum updates are not backwards compatible, meaning that some of your currently installed extensions, and manually made modifications might not work with this new version. + description: > + Major Flarum updates are not backwards compatible, meaning that some of your currently installed extensions, and manually made modifications might not work with this new version. + Please make sure to make a backup of your database and files before proceeding. dry_run: Dry Run dry_run_help: A dry run emulates the update to see if your current setup can safely update, this does not mean that your manual made custom modifications will work in the newer version. failure: diff --git a/extensions/package-manager/src/Api/Controller/ListTasksController.php b/extensions/package-manager/src/Api/Controller/ListTasksController.php index 1158885007..5bcf475073 100644 --- a/extensions/package-manager/src/Api/Controller/ListTasksController.php +++ b/extensions/package-manager/src/Api/Controller/ListTasksController.php @@ -13,7 +13,7 @@ use Flarum\Http\RequestUtil; use Flarum\Http\UrlGenerator; use Flarum\PackageManager\Api\Serializer\TaskSerializer; -use Flarum\PackageManager\Task\TaskRepository; +use Flarum\PackageManager\Task\Task; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -29,15 +29,9 @@ class ListTasksController extends AbstractListController */ protected $url; - /** - * @var TaskRepository - */ - protected $repository; - - public function __construct(UrlGenerator $url, TaskRepository $repository) + public function __construct(UrlGenerator $url) { $this->url = $url; - $this->repository = $repository; } protected function data(ServerRequestInterface $request, Document $document) @@ -49,14 +43,13 @@ protected function data(ServerRequestInterface $request, Document $document) $limit = $this->extractLimit($request); $offset = $this->extractOffset($request); - $results = $this->repository - ->query() + $results = Task::query() ->latest() ->offset($offset) ->limit($limit) ->get(); - $total = $this->repository->query()->count(); + $total = Task::query()->count(); $document->addMeta('total', (string) $total); diff --git a/extensions/package-manager/src/Command/CheckForUpdatesHandler.php b/extensions/package-manager/src/Command/CheckForUpdatesHandler.php index c7a81865cd..d26000f882 100755 --- a/extensions/package-manager/src/Command/CheckForUpdatesHandler.php +++ b/extensions/package-manager/src/Command/CheckForUpdatesHandler.php @@ -11,6 +11,7 @@ use Flarum\PackageManager\Composer\ComposerAdapter; use Flarum\PackageManager\Exception\ComposerCommandFailedException; +use Flarum\PackageManager\Extension\ExtensionUtils; use Flarum\PackageManager\Settings\LastUpdateCheck; use Symfony\Component\Console\Input\ArrayInput; @@ -58,7 +59,7 @@ public function handle(CheckForUpdates $command) $majorUpdates = false; foreach ($firstOutput['installed'] as $package) { - if (isset($package['latest-status']) && $package['latest-status'] === 'update-possible') { + if (isset($package['latest-status']) && $package['latest-status'] === 'update-possible' && ExtensionUtils::isMajorUpdate($package['version'], $package['latest'])) { $majorUpdates = true; break; } @@ -76,7 +77,7 @@ public function handle(CheckForUpdates $command) foreach ($firstOutput['installed'] as &$mainPackageUpdate) { $mainPackageUpdate['latest-minor'] = $mainPackageUpdate['latest-major'] = null; - if (isset($mainPackageUpdate['latest-status']) && $mainPackageUpdate['latest-status'] === 'update-possible') { + if (isset($mainPackageUpdate['latest-status']) && $mainPackageUpdate['latest-status'] === 'update-possible' && ExtensionUtils::isMajorUpdate($mainPackageUpdate['version'], $mainPackageUpdate['latest'])) { $mainPackageUpdate['latest-major'] = $mainPackageUpdate['latest']; $minorPackageUpdate = array_filter($secondOutput['installed'], function ($package) use ($mainPackageUpdate) { diff --git a/extensions/package-manager/src/Command/MajorUpdateHandler.php b/extensions/package-manager/src/Command/MajorUpdateHandler.php index c6d95bd8b2..6be1c64ffd 100644 --- a/extensions/package-manager/src/Command/MajorUpdateHandler.php +++ b/extensions/package-manager/src/Command/MajorUpdateHandler.php @@ -89,9 +89,6 @@ public function handle(MajorUpdate $command) ); } - /** - * @todo change minimum stability to 'stable' and any other similar params - */ protected function updateComposerJson(string $majorVersion): void { $versionNumber = str_replace('v', '', $majorVersion); diff --git a/extensions/package-manager/src/Extension/ExtensionUtils.php b/extensions/package-manager/src/Extension/ExtensionUtils.php index 20be349e2d..870f1ea662 100755 --- a/extensions/package-manager/src/Extension/ExtensionUtils.php +++ b/extensions/package-manager/src/Extension/ExtensionUtils.php @@ -18,4 +18,25 @@ public static function nameToId(string $name): string return "$vendor-$package"; } + + public static function isMajorUpdate(string $currentVersion, string $latestVersion): bool + { + // Drop any v prefixes + if(str_starts_with($currentVersion, 'v')) { + $currentVersion = substr($currentVersion, 1); + } + + $currentVersion = explode('.', $currentVersion); + $latestVersion = explode('.', $latestVersion); + + if (! is_numeric($currentVersion[0]) || ! is_numeric($latestVersion[0])) { + return false; + } + + if (intval($currentVersion[0]) < intval($latestVersion[0])) { + return true; + } + + return false; + } }