Skip to content

Commit

Permalink
Move display of error report modal in a common controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Quetzacoalt91 committed Dec 12, 2024
1 parent db88c12 commit 7e2ab82
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
19 changes: 10 additions & 9 deletions classes/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

namespace PrestaShop\Module\AutoUpgrade\Router;

use PrestaShop\Module\AutoUpgrade\Controller\ErrorReportController;
use PrestaShop\Module\AutoUpgrade\Controller\HomePageController;
use PrestaShop\Module\AutoUpgrade\Controller\LogsController;
use PrestaShop\Module\AutoUpgrade\Controller\UpdatePageBackupController;
Expand Down Expand Up @@ -140,14 +141,6 @@ public function __construct(UpgradeContainer $upgradeContainer)
'controller' => UpdatePageUpdateController::class,
'method' => 'step',
],
Routes::UPDATE_STEP_UPDATE_SUBMIT_ERROR_REPORT => [
'controller' => UpdatePageUpdateController::class,
'method' => 'submitErrorReport',
],
Routes::DOWNLOAD_LOGS => [
'controller' => LogsController::class,
'method' => 'getDownloadLogsButton',
],
Routes::UPDATE_PAGE_POST_UPDATE => [
'controller' => UpdatePagePostUpdateController::class,
'method' => 'index',
Expand All @@ -159,7 +152,15 @@ public function __construct(UpgradeContainer $upgradeContainer)
// self::RESTORE_PAGE_BACKUP_SELECTION => [
// 'controller' => 'todo',
// 'method' => 'index',
// ]
// ],
Routes::DISPLAY_ERROR_REPORT_MODAL => [
'controller' => ErrorReportController::class,
'method' => 'displayErrorReportModal',
],
Routes::DOWNLOAD_LOGS => [
'controller' => LogsController::class,
'method' => 'getDownloadLogsButton',
],
];

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/Router/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Routes
/* step: update */
const UPDATE_PAGE_UPDATE = 'update-page-update';
const UPDATE_STEP_UPDATE = 'update-step-update';
const UPDATE_STEP_UPDATE_SUBMIT_ERROR_REPORT = 'update-step-update-submit-error-report';
const DISPLAY_ERROR_REPORT_MODAL = 'update-step-update-submit-error-report';

/* step: post update */
const UPDATE_PAGE_POST_UPDATE = 'update-page-post-update';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,22 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/

namespace PrestaShop\Module\AutoUpgrade\Traits;
namespace PrestaShop\Module\AutoUpgrade\Controller;

use PrestaShop\Module\AutoUpgrade\AjaxResponseBuilder;
use PrestaShop\Module\AutoUpgrade\DocumentationLinks;
use PrestaShop\Module\AutoUpgrade\Twig\PageSelectors;
use Symfony\Component\HttpFoundation\JsonResponse;

trait DisplayErrorReportDialogTrait
class ErrorReportController extends AbstractGlobalController
{
public function submitErrorReport(): JsonResponse
public function displayErrorReportModal(): JsonResponse
{
return AjaxResponseBuilder::hydrationResponse(
PageSelectors::DIALOG_PARENT_ID,
$this->getTwig()->render(
'@ModuleAutoUpgrade/dialogs/dialog-error-report.html.twig',
[
'dialogSize' => 'sm',
'title' => $this->upgradeContainer->getTranslator()->trans('Send error report?'),
'data_transparency_link' => DocumentationLinks::PRESTASHOP_PROJECT_DATA_TRANSPARENCY_URL,
]
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ protected function getParams(): array
'download_logs_route' => Routes::DOWNLOAD_LOGS,
'download_logs_type' => TaskType::TASK_TYPE_BACKUP,
'retry_route' => Routes::UPDATE_PAGE_BACKUP_OPTIONS,
// TODO: Move in a common controller
'submit_error_report_route' => Routes::UPDATE_STEP_UPDATE_SUBMIT_ERROR_REPORT,
'submit_error_report_route' => Routes::DISPLAY_ERROR_REPORT_MODAL,
'initial_process_action' => TaskName::TASK_BACKUP_INITIALIZATION,
'download_logs_parent_id' => PageSelectors::DOWNLOAD_LOGS_PARENT_ID,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@
use PrestaShop\Module\AutoUpgrade\Router\Routes;
use PrestaShop\Module\AutoUpgrade\Task\TaskName;
use PrestaShop\Module\AutoUpgrade\Task\TaskType;
use PrestaShop\Module\AutoUpgrade\Traits\DisplayErrorReportDialogTrait;
use PrestaShop\Module\AutoUpgrade\Twig\PageSelectors;
use PrestaShop\Module\AutoUpgrade\Twig\UpdateSteps;

class UpdatePageUpdateController extends AbstractPageWithStepController
{
use DisplayErrorReportDialogTrait;

const CURRENT_STEP = UpdateSteps::STEP_UPDATE;

protected function getPageTemplate(): string
Expand Down Expand Up @@ -72,8 +69,7 @@ protected function getParams(): array
'download_logs_route' => Routes::DOWNLOAD_LOGS,
'download_logs_type' => TaskType::TASK_TYPE_UPDATE,
'restore_route' => Routes::RESTORE_PAGE_BACKUP_SELECTION,
// TODO: Move in a common controller
'submit_error_report_route' => Routes::UPDATE_STEP_UPDATE_SUBMIT_ERROR_REPORT,
'submit_error_report_route' => Routes::DISPLAY_ERROR_REPORT_MODAL,
'initial_process_action' => TaskName::TASK_UPDATE_INITIALIZATION,
'backup_available' => !empty($backupFinder->getAvailableBackups()),
'download_logs_parent_id' => PageSelectors::DOWNLOAD_LOGS_PARENT_ID,
Expand Down

0 comments on commit 7e2ab82

Please sign in to comment.