diff --git a/admin.php b/admin.php index ed73880d..97c1dca6 100644 --- a/admin.php +++ b/admin.php @@ -6,6 +6,7 @@ use Grav\Common\Cache; use Grav\Common\Data\Data; use Grav\Common\Debugger; use Grav\Common\File\CompiledYamlFile; +use Grav\Common\GPM\Upgrader; use Grav\Common\Grav; use Grav\Common\Helpers\LogViewer; use Grav\Common\Inflector; @@ -743,6 +744,21 @@ class AdminPlugin extends Plugin switch ($this->template) { case 'dashboard': $twig->twig_vars['popularity'] = $this->popularity; + + // Cross-family migration notice: when the remote advertises a new major, + // surface a one-time banner on the dashboard. Uses cached GPM data; failures + // must not break the dashboard. + try { + $upgrader = new Upgrader(); + if (method_exists($upgrader, 'isNextMajorAvailable') && $upgrader->isNextMajorAvailable()) { + $twig->twig_vars['grav_next_major'] = [ + 'version' => $upgrader->getNextMajorVersion(), + 'migration_url' => $upgrader->getMigrationUrl(), + ]; + } + } catch (\Throwable $e) { + // Swallow — notice is informational only. + } break; } diff --git a/languages/en.yaml b/languages/en.yaml index 9738edc2..938d4357 100644 --- a/languages/en.yaml +++ b/languages/en.yaml @@ -498,6 +498,10 @@ PLUGIN_ADMIN: MODAL_DELETE_PAGE_CONFIRMATION_REQUIRED_DESC: "Are you sure you want to delete this page and all its children? If the page is translated in other languages, those translations will be kept and must be deleted separately. Otherwise the page folder will be deleted along with its subpages. This action cannot be undone." AND: "and" UPDATE_AVAILABLE: "Update available" + GRAV_NEXT_MAJOR_AVAILABLE: "Grav %s is available" + GRAV_NEXT_MAJOR_DESCRIPTION: "A new major version of Grav is now available. This is not an automatic upgrade — moving from 1.x to 2.x is a migration. Follow the guide for details on what's new and how to import your existing site." + GRAV_NEXT_MAJOR_LEARN_MORE: "Learn how to migrate" + GRAV_NEXT_MAJOR_START_MIGRATION: "Start migration" METADATA_KEY: "Key (e.g. 'Keywords')" METADATA_VALUE: "Value (e.g. 'Blog, Grav')" USERNAME_HELP: "Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed" diff --git a/themes/grav/templates/dashboard.html.twig b/themes/grav/templates/dashboard.html.twig index 67cd2c21..a24fbb4e 100644 --- a/themes/grav/templates/dashboard.html.twig +++ b/themes/grav/templates/dashboard.html.twig @@ -35,6 +35,7 @@ {% endif %} {# System notifications, cannot be turned off #} + {% include 'partials/dashboard-migration-notice.html.twig' %} {% include 'partials/dashboard-problems.html.twig' %}
diff --git a/themes/grav/templates/partials/dashboard-migration-notice.html.twig b/themes/grav/templates/partials/dashboard-migration-notice.html.twig new file mode 100644 index 00000000..4a4117d9 --- /dev/null +++ b/themes/grav/templates/partials/dashboard-migration-notice.html.twig @@ -0,0 +1,148 @@ +{% if grav_next_major and grav_next_major.migration_url %} + +
+
+
+ {{ grav_next_major.version|split('.')|slice(0,2)|join('.') }} + Grav +
+
+

+ {{ "PLUGIN_ADMIN.GRAV_NEXT_MAJOR_AVAILABLE"|t(grav_next_major.version) }} + New +

+

{{ "PLUGIN_ADMIN.GRAV_NEXT_MAJOR_DESCRIPTION"|t }}

+
+ +
+
+{% endif %}