diff --git a/_dev/src/ts/pages/RestorePagePostRestore.ts b/_dev/src/ts/pages/RestorePagePostRestore.ts new file mode 100644 index 000000000..b938e763b --- /dev/null +++ b/_dev/src/ts/pages/RestorePagePostRestore.ts @@ -0,0 +1,13 @@ +import StepPage from './StepPage'; + +export default class RestorePagePostRestore extends StepPage { + protected stepCode = 'post-restore'; + + constructor() { + super(); + } + + public mount() { + this.initStepper(); + } +} diff --git a/_dev/src/ts/routing/ScriptHandler.ts b/_dev/src/ts/routing/ScriptHandler.ts index c9f98b8c6..d92af31c4 100644 --- a/_dev/src/ts/routing/ScriptHandler.ts +++ b/_dev/src/ts/routing/ScriptHandler.ts @@ -8,6 +8,7 @@ import UpdatePagePostUpdate from '../pages/UpdatePagePostUpdate'; import RestorePageBackupSelection from '../pages/RestorePageBackupSelection'; import RestorePageRestore from '../pages/RestorePageRestore'; +import RestorePagePostRestore from '../pages/RestorePagePostRestore'; import StartUpdateDialog from '../dialogs/StartUpdateDialog'; import SendErrorReportDialog from '../dialogs/SendErrorReportDialog'; @@ -35,6 +36,7 @@ export default class ScriptHandler { 'restore-page-backup-selection': RestorePageBackupSelection, 'restore-page-restore': RestorePageRestore, + 'restore-page-post-restore': RestorePagePostRestore, 'start-update-dialog': StartUpdateDialog, 'send-error-report-dialog': SendErrorReportDialog diff --git a/classes/DocumentationLinks.php b/classes/DocumentationLinks.php index 4b39cc989..80e3126b4 100644 --- a/classes/DocumentationLinks.php +++ b/classes/DocumentationLinks.php @@ -10,6 +10,7 @@ class DocumentationLinks public const DEV_DOC_UPGRADE_CLI_URL = self::DEV_DOC_UPGRADE_URL . '/upgrade-cli'; public const DEV_DOC_UPGRADE_WEB_URL = self::DEV_DOC_UP_TO_DATE_URL . '/use-autoupgrade-module'; public const DEV_DOC_UPGRADE_POST_UPGRADE_URL = self:: DEV_DOC_UPGRADE_URL . '/post-update-checklist'; + public const DEV_DOC_UPGRADE_POST_RESTORE_URL = self:: DEV_DOC_UPGRADE_URL . '/post-restore-checklist'; public const PRESTASHOP_PROJECT_URL = 'https://www.prestashop-project.org'; public const PRESTASHOP_PROJECT_DATA_TRANSPARENCY_URL = self::PRESTASHOP_PROJECT_URL . '/data-transparency'; } diff --git a/classes/Router/Router.php b/classes/Router/Router.php index 945a0f424..093eebaad 100644 --- a/classes/Router/Router.php +++ b/classes/Router/Router.php @@ -31,6 +31,7 @@ use PrestaShop\Module\AutoUpgrade\Controller\HomePageController; use PrestaShop\Module\AutoUpgrade\Controller\LogsController; use PrestaShop\Module\AutoUpgrade\Controller\RestorePageBackupSelectionController; +use PrestaShop\Module\AutoUpgrade\Controller\RestorePagePostRestoreController; use PrestaShop\Module\AutoUpgrade\Controller\RestorePageRestoreController; use PrestaShop\Module\AutoUpgrade\Controller\UpdatePageBackupController; use PrestaShop\Module\AutoUpgrade\Controller\UpdatePageBackupOptionsController; @@ -195,14 +196,14 @@ public function __construct(UpgradeContainer $upgradeContainer) 'method' => 'step', ], /* step: post restore */ -// Routes::RESTORE_PAGE_POST_RESTORE => [ -// 'controller' => 'todo', -// 'method' => 'index', -// ], -// Routes::RESTORE_STEP_POST_RESTORE => [ -// 'controller' => 'todo', -// 'method' => 'step', -// ], + Routes::RESTORE_PAGE_POST_RESTORE => [ + 'controller' => RestorePagePostRestoreController::class, + 'method' => 'index', + ], + Routes::RESTORE_STEP_POST_RESTORE => [ + 'controller' => RestorePagePostRestoreController::class, + 'method' => 'step', + ], /* COMMON */ /* error reporting */ Routes::DISPLAY_ERROR_REPORT_MODAL => [ diff --git a/controllers/admin/self-managed/RestorePagePostRestoreController.php b/controllers/admin/self-managed/RestorePagePostRestoreController.php new file mode 100644 index 000000000..36ca050ef --- /dev/null +++ b/controllers/admin/self-managed/RestorePagePostRestoreController.php @@ -0,0 +1,74 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + */ + +namespace PrestaShop\Module\AutoUpgrade\Controller; + +use PrestaShop\Module\AutoUpgrade\DocumentationLinks; +use PrestaShop\Module\AutoUpgrade\Router\Routes; +use PrestaShop\Module\AutoUpgrade\Task\TaskType; +use PrestaShop\Module\AutoUpgrade\Twig\Steps\RestoreSteps; +use PrestaShop\Module\AutoUpgrade\Twig\Steps\Stepper; +use PrestaShop\Module\AutoUpgrade\UpgradeContainer; + +class RestorePagePostRestoreController extends AbstractPageWithStepController +{ + const CURRENT_STEP = RestoreSteps::STEP_POST_RESTORE; + + protected function getPageTemplate(): string + { + return 'restore'; + } + + protected function getStepTemplate(): string + { + return self::CURRENT_STEP; + } + + protected function displayRouteInUrl(): ?string + { + return Routes::RESTORE_PAGE_POST_RESTORE; + } + + /** + * @return array + * + * @throws \Exception + */ + protected function getParams(): array + { + $updateSteps = new Stepper($this->upgradeContainer->getTranslator(), TaskType::TASK_TYPE_RESTORE); + + return array_merge( + $updateSteps->getStepParams($this::CURRENT_STEP), + [ + 'exit_link' => DIRECTORY_SEPARATOR . $this->upgradeContainer->getProperty(UpgradeContainer::PS_ADMIN_SUBDIR) . DIRECTORY_SEPARATOR . 'index.php', + 'dev_doc_link' => DocumentationLinks::DEV_DOC_UPGRADE_POST_RESTORE_URL, + 'download_logs' => $this->upgradeContainer->getLogsService()->getDownloadLogsData(TaskType::TASK_TYPE_RESTORE), + ] + ); + } +} diff --git a/views/templates/steps/post-restore.html.twig b/views/templates/steps/post-restore.html.twig index 0374f0d13..bc82e5c60 100644 --- a/views/templates/steps/post-restore.html.twig +++ b/views/templates/steps/post-restore.html.twig @@ -47,23 +47,25 @@ -
- - {{ 'Download restore logs'|trans({}) }} - file_upload - -
+ {% if download_logs is defined %} +
+ + {{ download_logs.button_label }} + file_upload + +
+ {% endif %} {% endblock %} {% block buttons_inner %} - + - + {% endblock %}