diff --git a/controllers/admin/AdminSelfUpgradeController.php b/controllers/admin/AdminSelfUpgradeController.php index 8eac812b3..e572c8801 100644 --- a/controllers/admin/AdminSelfUpgradeController.php +++ b/controllers/admin/AdminSelfUpgradeController.php @@ -458,8 +458,13 @@ public function initContent() $request = Request::createFromGlobals(); $this->addNewUIAssets($request); - // TODO: In the future, the router will return an object instead of a string depending on controller called. - $this->content = (new Router($this->upgradeContainer))->handle($request); + $response = (new Router($this->upgradeContainer))->handle($request); + + if ($response instanceof \Symfony\Component\HttpFoundation\Response) { + $response->send(); + exit; + } + $this->content = $response; return parent::initContent(); } diff --git a/controllers/admin/self-managed/AbstractPageController.php b/controllers/admin/self-managed/AbstractPageController.php index 12c994024..8513280c5 100644 --- a/controllers/admin/self-managed/AbstractPageController.php +++ b/controllers/admin/self-managed/AbstractPageController.php @@ -27,6 +27,7 @@ namespace PrestaShop\Module\AutoUpgrade\Controller; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; abstract class AbstractPageController extends AbstractGlobalController @@ -69,11 +70,11 @@ public function renderPage(string $page, array $params): string /** * @param Request $request * - * @return string + * @return RedirectResponse|string * * @throws \Exception */ - public function index(Request $request): string + public function index(Request $request) { return $this->renderPage( $this::CURRENT_PAGE, diff --git a/controllers/admin/self-managed/UpdatePageBackupController.php b/controllers/admin/self-managed/UpdatePageBackupController.php index c6e53f602..95f8fe210 100644 --- a/controllers/admin/self-managed/UpdatePageBackupController.php +++ b/controllers/admin/self-managed/UpdatePageBackupController.php @@ -66,7 +66,11 @@ protected function getParams(Request $request): array return array_merge( $updateSteps->getStepParams($this::CURRENT_STEP), - [] + [ + // TODO + 'default_backup_files_and_database' => true, + 'default_include_images' => false, + ] ); } } diff --git a/controllers/admin/self-managed/UpdatePagePostUpdateController.php b/controllers/admin/self-managed/UpdatePagePostUpdateController.php index 6a911eef5..c91a13f7f 100644 --- a/controllers/admin/self-managed/UpdatePagePostUpdateController.php +++ b/controllers/admin/self-managed/UpdatePagePostUpdateController.php @@ -66,7 +66,10 @@ protected function getParams(Request $request): array return array_merge( $updateSteps->getStepParams($this::CURRENT_STEP), - [] + [ + // TODO + 'backlog_link' => 'https://myshop.com/my-backlog.txt', + ] ); } } diff --git a/controllers/admin/self-managed/UpdatePageUpdateController.php b/controllers/admin/self-managed/UpdatePageUpdateController.php index edaadcc9c..52dd54ae3 100644 --- a/controllers/admin/self-managed/UpdatePageUpdateController.php +++ b/controllers/admin/self-managed/UpdatePageUpdateController.php @@ -27,7 +27,9 @@ namespace PrestaShop\Module\AutoUpgrade\Controller; +use PrestaShop\Module\AutoUpgrade\Router\Router; use PrestaShop\Module\AutoUpgrade\Twig\UpdateSteps; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Twig\Error\LoaderError; use Twig\Error\RuntimeError; @@ -38,6 +40,13 @@ class UpdatePageUpdateController extends AbstractPageController const CURRENT_STEP = UpdateSteps::STEP_UPDATE; const CURRENT_PAGE = 'update'; + public function index(Request $request): RedirectResponse + { + return new RedirectResponse( + str_replace(Router::UPDATE_PAGE_UPDATE, Router::UPDATE_PAGE_BACKUP, $request->getUri()) + ); + } + /** * @param Request $request * diff --git a/controllers/admin/self-managed/UpdatePageUpdateOptionsController.php b/controllers/admin/self-managed/UpdatePageUpdateOptionsController.php index 62b53ded9..4554f19f5 100644 --- a/controllers/admin/self-managed/UpdatePageUpdateOptionsController.php +++ b/controllers/admin/self-managed/UpdatePageUpdateOptionsController.php @@ -66,7 +66,13 @@ protected function getParams(Request $request): array return array_merge( $updateSteps->getStepParams($this::CURRENT_STEP), - [] + [ + // TODO + 'default_deactive_non_native_modules' => true, + 'default_regenerate_email_templates' => true, + 'switch_the_theme' => '1', + 'disable_all_overrides' => false, + ] ); } } diff --git a/controllers/admin/self-managed/UpdatePageVersionChoiceController.php b/controllers/admin/self-managed/UpdatePageVersionChoiceController.php index 7a0c88e9d..b7a7db394 100644 --- a/controllers/admin/self-managed/UpdatePageVersionChoiceController.php +++ b/controllers/admin/self-managed/UpdatePageVersionChoiceController.php @@ -68,7 +68,7 @@ protected function getParams(Request $request): array if (!$isLastVersion) { $updateType = VersionUtils::getUpdateType($this->getPsVersion(), $this->upgradeContainer->getUpgrader()->getDestinationVersion()); - $releaseNote = VersionUtils::getUpdateType($this->getPsVersion(), $this->upgradeContainer->getUpgrader()->getOnlineDestinationRelease()->getReleaseNoteUrl()); + $releaseNote = $this->upgradeContainer->getUpgrader()->getOnlineDestinationRelease()->getReleaseNoteUrl(); } else { $updateType = null; $releaseNote = null; @@ -87,20 +87,25 @@ protected function getParams(Request $request): array default: $updateLabel = null; } + $archiveRepository = $this->upgradeContainer->getLocalArchiveRepository(); return array_merge( $updateSteps->getStepParams($this::CURRENT_STEP), [ - 'upToDate' => $isLastVersion, - 'noLocalArchive' => !$this->upgradeContainer->getLocalArchiveRepository()->hasLocalArchive(), - 'assetsBasePath' => $this->upgradeContainer->getAssetsEnvironment()->getAssetsBaseUrl($request), - 'currentPrestashopVersion' => $this->getPsVersion(), - 'currentPhpVersion' => VersionUtils::getHumanReadableVersionOf(PHP_VERSION_ID), - 'nextRelease' => [ + 'up_to_date' => $isLastVersion, + 'no_local_archive' => !$this->upgradeContainer->getLocalArchiveRepository()->hasLocalArchive(), + 'assets_base_path' => $this->upgradeContainer->getAssetsEnvironment()->getAssetsBaseUrl($request), + 'current_prestashop_version' => $this->getPsVersion(), + 'current_php_version' => VersionUtils::getHumanReadableVersionOf(PHP_VERSION_ID), + 'local_archives' => [ + 'zip' => $archiveRepository->getZipLocalArchive(), + 'xml' => $archiveRepository->getXmlLocalArchive(), + ], + 'next_release' => [ 'version' => $this->upgradeContainer->getUpgrader()->getDestinationVersion(), - 'badgeLabel' => $updateLabel, - 'badgeStatus' => $updateType, - 'releaseNote' => $releaseNote, + 'badge_label' => $updateLabel, + 'badge_status' => $updateType, + 'release_note' => $releaseNote, ], ] ); diff --git a/storybook/stories/components/RadioCard.stories.js b/storybook/stories/components/RadioCard.stories.js index 369dc6471..94182a450 100644 --- a/storybook/stories/components/RadioCard.stories.js +++ b/storybook/stories/components/RadioCard.stories.js @@ -64,7 +64,7 @@ export const Archive = { checked: true, title: "Local archive", message: - "Save the archive file of the version you want to update to in the following directory: /admin/autoUpdate/download/", + "Save the archive file of the version you want to update to in the following directory: /admin/autoupgrade/download/", disabled: false, disabledMessage: "No backup file found on your store.", badgeLabel: "", diff --git a/views/templates/steps/backup.html.twig b/views/templates/steps/backup.html.twig index 9d388444e..9715a7670 100644 --- a/views/templates/steps/backup.html.twig +++ b/views/templates/steps/backup.html.twig @@ -26,7 +26,7 @@ }, BoolName: "PS_AUTOUP_BACKUP_FILES_DB", BoolId: "PS_AUTOUP_BACKUP_FILES_DB", - val: true, + val: default_backup_files_and_database, } %} {% include "@ModuleAutoUpgrade/components/render-bool.html.twig" with { @@ -40,7 +40,7 @@ }, BoolName: "PS_AUTOUP_BACKUP_WITH_IMAGES", BoolId: "PS_AUTOUP_BACKUP_WITH_IMAGES", - val: false, + val: default_include_images, } %} diff --git a/views/templates/steps/post-update.html.twig b/views/templates/steps/post-update.html.twig index 224a14c0b..a72568e0a 100644 --- a/views/templates/steps/post-update.html.twig +++ b/views/templates/steps/post-update.html.twig @@ -56,7 +56,7 @@
- + {{ 'Download update logs'|trans({}) }} file_upload diff --git a/views/templates/steps/update-options.html.twig b/views/templates/steps/update-options.html.twig index b453e0921..48a6a388d 100644 --- a/views/templates/steps/update-options.html.twig +++ b/views/templates/steps/update-options.html.twig @@ -20,7 +20,7 @@ }, BoolName: "PS_AUTOUP_CUSTOM_MOD_DESACT", BoolId: "PS_AUTOUP_CUSTOM_MOD_DESACT", - val: true + val: default_deactive_non_native_modules } %} {% include "@ModuleAutoUpgrade/components/render-bool.html.twig" with { @@ -34,7 +34,7 @@ }, BoolName: "PS_AUTOUP_REGEN_EMAIL", BoolId: "PS_AUTOUP_REGEN_EMAIL", - val: true + val: default_regenerate_email_templates } %} {% include "@ModuleAutoUpgrade/components/render-select.html.twig" with { @@ -53,7 +53,7 @@ disabled: false }, key: "PS_AUTOUP_SWITCH_THEME", - val: "1" + val: switch_the_theme } %} {% include "@ModuleAutoUpgrade/components/render-bool.html.twig" with { @@ -69,7 +69,7 @@ }, BoolName: "PS_AUTOUP_DISABLE_OVERRIDE", BoolId: "PS_AUTOUP_DISABLE_OVERRIDE", - val: false + val: disable_all_overrides } %}
{% endblock %} diff --git a/views/templates/steps/version-choice.html.twig b/views/templates/steps/version-choice.html.twig index 4b2b09e0d..e3659c8e7 100644 --- a/views/templates/steps/version-choice.html.twig +++ b/views/templates/steps/version-choice.html.twig @@ -9,31 +9,31 @@ {% endblock %} {% block content %} - {% if upToDate %} -
- {% if noLocalArchive %} + {% if up_to_date %} +
+ {% if no_local_archive %} {% endif %} -

+

check_circle {{ 'You\'re up to date'|trans({}) }}

{{ 'Current PrestaShop version:'|trans({}) }} - {{ currentPrestashopVersion }} + {{ current_prestashop_version }}
{{ 'Current PHP version:'|trans({}) }} - {{ currentPhpVersion }} + {{ current_php_version }}

- {% if noLocalArchive %} + {% if no_local_archive %} {% include "@ModuleAutoUpgrade/components/alert.html.twig" with { message: "Unlock the local update feature and manually update your store to your preferred upgrade by saving the archive and XML files of the PrestaShop version in the following directory on your server: %pathToLocalArchive%"|trans({ '%pathToLocalArchive%': '/admin/autoupgrade/download/' @@ -66,13 +66,13 @@

{{ 'Current PrestaShop version:'|trans({}) }} - {{ currentPrestashopVersion }} + {{ current_prestashop_version }}
{{ 'Current PHP version:'|trans({}) }} - {{ currentPhpVersion }} + {{ current_php_version }}

- {% if not noLocalArchive %} + {% if not no_local_archive %}

{{ 'Select version:'|trans({}) }} @@ -88,17 +88,19 @@

{% include "@ModuleAutoUpgrade/components/radio-card.html.twig" with { radioCardId: "", + radioName: "canal_choice", + radioValue: "online", checked: true, - title: "PrestaShop %version%"|trans({'%version%': nextRelease.version}), + title: "PrestaShop %version%"|trans({'%version%': next_release.version}), disabled: false, - badgeLabel: nextRelease.badgeLabel, - badgeStatus: nextRelease.badgeStatus, - releaseNote: nextRelease.releaseNote, + badgeLabel: next_release.badge_label, + badgeStatus: next_release.badge_status, + releaseNote: next_release.release_note, archiveCard: false, checkRequirements: false, } %} - {% if noLocalArchive %} + {% if no_local_archive %} {% include "@ModuleAutoUpgrade/components/alert.html.twig" with { message: "Unlock the local update feature and manually update your store to your preferred upgrade by saving the archive and XML files of the PrestaShop version in the following directory on your server: %pathToLocalArchive%"|trans({ '%pathToLocalArchive%': '/admin/autoupgrade/download/' @@ -110,14 +112,18 @@ {% else %} {% include "@ModuleAutoUpgrade/components/radio-card.html.twig" with { radioCardId: "", + radioName: "canal_choice", + radioValue: "local", checked: false, title: "Local archive"|trans({}), - message: "Save the archive file of the version you want to update to in the following directory: /admin/autoUpdate/download/", + message: "Save the archive file of the version you want to update to in the following directory: /admin/autoupgrade/download/", disabled: false, disabledMessage: "", badgeLabel: "", releaseNote: "", archiveCard: true, + archiveFiles: local_archives.zip, + xmlFiles: local_archives.xml, } %} {% endif %}