From 57c1e4b4c0b0e8d76ca0b6ff5560595a0e61d5af Mon Sep 17 00:00:00 2001 From: tblivet Date: Thu, 5 Dec 2024 16:47:37 +0100 Subject: [PATCH 1/5] fix: storybook pages + components errors --- storybook/stories/components/Dialog.stories.js | 9 --------- storybook/stories/components/DialogBackup.stories.js | 6 +++++- storybook/stories/components/DialogBackupAll.stories.js | 6 +++++- .../stories/components/DialogBackupDelete.stories.js | 6 +++++- .../stories/components/DialogErrorReport.stories.js | 6 +++++- storybook/stories/components/DialogUpdate.stories.js | 7 ++++++- storybook/stories/components/LogsProgress.stories.js | 6 ++++++ storybook/stories/pages/Backup.stories.js | 8 ++++++-- views/templates/steps/restore.html.twig | 6 +++--- 9 files changed, 41 insertions(+), 19 deletions(-) diff --git a/storybook/stories/components/Dialog.stories.js b/storybook/stories/components/Dialog.stories.js index 8c015143d..171cae4f8 100644 --- a/storybook/stories/components/Dialog.stories.js +++ b/storybook/stories/components/Dialog.stories.js @@ -45,15 +45,6 @@ export const Default = { dialogSize: "lg", psBaseUri: "/", dialogDanger: false, - assets_base_path: "", }, }; - -document.addEventListener("DOMContentLoaded", () => { - const dialogs = document.querySelectorAll(".dialog"); - dialogs.forEach((dialog) => { - dialog.style.display = "block"; - dialog.classList.add("in"); - }); -}); diff --git a/storybook/stories/components/DialogBackup.stories.js b/storybook/stories/components/DialogBackup.stories.js index 70ce5a3de..ee95de0fa 100644 --- a/storybook/stories/components/DialogBackup.stories.js +++ b/storybook/stories/components/DialogBackup.stories.js @@ -34,6 +34,10 @@ export default { export const Backup = { args: { ...Dialog.args, - dialogSize: "md", + dialogSize: "sm", + }, + play: async () => { + const dialog = document.querySelector('.dialog'); + dialog.showModal(); }, }; diff --git a/storybook/stories/components/DialogBackupAll.stories.js b/storybook/stories/components/DialogBackupAll.stories.js index b124d2751..3ce5c6a53 100644 --- a/storybook/stories/components/DialogBackupAll.stories.js +++ b/storybook/stories/components/DialogBackupAll.stories.js @@ -34,6 +34,10 @@ export default { export const BackupWithImg = { args: { ...Dialog.args, - dialogSize: "md", + dialogSize: "sm", + }, + play: async () => { + const dialog = document.querySelector('.dialog'); + dialog.showModal(); }, }; diff --git a/storybook/stories/components/DialogBackupDelete.stories.js b/storybook/stories/components/DialogBackupDelete.stories.js index 275491425..747caf356 100644 --- a/storybook/stories/components/DialogBackupDelete.stories.js +++ b/storybook/stories/components/DialogBackupDelete.stories.js @@ -36,7 +36,11 @@ export const BackupDelete = { ...Dialog.args, title: "Delete backup", message: "You are about to delete the autoupgrade_save_8.1.6 backup made on 15/07/2024 8:00. As it's your only backup, you will be redirected to the module's home page.", - dialogSize: "lg", + dialogSize: "md", dialogDanger: true, }, + play: async () => { + const dialog = document.querySelector('.dialog'); + dialog.showModal(); + }, }; diff --git a/storybook/stories/components/DialogErrorReport.stories.js b/storybook/stories/components/DialogErrorReport.stories.js index ed4035f5b..fe885e21d 100644 --- a/storybook/stories/components/DialogErrorReport.stories.js +++ b/storybook/stories/components/DialogErrorReport.stories.js @@ -37,7 +37,11 @@ export const ErrorReport = { dialogId: "errorDialog", title: "Send error report?", message: "", - dialogSize: "md", + dialogSize: "sm", dataPrivacyLink: "#" }, + play: async () => { + const dialog = document.querySelector('.dialog'); + dialog.showModal(); + }, }; diff --git a/storybook/stories/components/DialogUpdate.stories.js b/storybook/stories/components/DialogUpdate.stories.js index 293934294..db3cbcd3e 100644 --- a/storybook/stories/components/DialogUpdate.stories.js +++ b/storybook/stories/components/DialogUpdate.stories.js @@ -34,7 +34,12 @@ export default { export const Update = { args: { ...Dialog.args, - dialogSize: "lg", + dialogSize: "md", noBackUp: false, + form_route_to_confirm: "/", + }, + play: async () => { + const dialog = document.querySelector('.dialog'); + dialog.showModal(); }, }; diff --git a/storybook/stories/components/LogsProgress.stories.js b/storybook/stories/components/LogsProgress.stories.js index 99a55d0dd..fdfe19211 100644 --- a/storybook/stories/components/LogsProgress.stories.js +++ b/storybook/stories/components/LogsProgress.stories.js @@ -28,6 +28,12 @@ import LogsProgress from "../../../views/templates/components/logs-summary.html. export default { component: LogsProgress, title: "Components/Logs progress", + play: async ({ args }) => { + const textSlots = document.querySelectorAll("[data-slot-component='text']"); + textSlots.forEach((slot) => { + slot.textContent = args.progressStatus; + }); + } }; export const Default = { diff --git a/storybook/stories/pages/Backup.stories.js b/storybook/stories/pages/Backup.stories.js index aec239e44..6877d08c8 100644 --- a/storybook/stories/pages/Backup.stories.js +++ b/storybook/stories/pages/Backup.stories.js @@ -47,8 +47,12 @@ export const Backup = { }, }, - form_route_to_save: "update-step-update-options-save-option", - form_route_to_submit: "update-step-update-options-submit-form", + form_route_to_save: "update-step-backup-save-option", + form_route_to_submit: "update-step-backup-submit-backup", + form_route_to_confirm_update: "update-step-backup-confirm-update", + form_route_to_confirm_backup: "update-step-backup-confirm-backup", + form_route_to_submit_update: "update-step-backup-submit-update", + form_route_to_submit_backup: "update-step-update-options-submit-form", step_parent_id: "ua_container", // Stepper diff --git a/views/templates/steps/restore.html.twig b/views/templates/steps/restore.html.twig index 2380a9639..34b821ce1 100644 --- a/views/templates/steps/restore.html.twig +++ b/views/templates/steps/restore.html.twig @@ -7,9 +7,9 @@ {% endblock %} {% block content %} - {% include "@ModuleAutoUpgrade/components/logs-progress.html.twig" %} - - {% include "@ModuleAutoUpgrade/components/logs.html.twig" %} + {% include "@ModuleAutoUpgrade/components/progress-tracker.html.twig" with { + successRoute: 'restore-step-post-restore' + } %} {% endblock %} {% block buttons_inner %} From c6fe7d35b2f39a30230d4805a18fbc608d8ff9b8 Mon Sep 17 00:00:00 2001 From: tblivet Date: Mon, 9 Dec 2024 18:05:29 +0100 Subject: [PATCH 2/5] fix: dialog --- storybook/stories/components/Dialog.stories.js | 12 ------------ .../stories/components/DialogBackup.stories.js | 5 ----- .../stories/components/DialogBackupAll.stories.js | 5 ----- .../components/DialogBackupDelete.stories.js | 9 +++------ .../components/DialogErrorReport.stories.js | 7 +------ .../stories/components/DialogUpdate.stories.js | 1 - views/templates/components/dialog.html.twig | 4 ++-- .../dialogs/dialog-backup-delete.html.twig | 14 ++++++++++++++ views/templates/dialogs/dialog-backup.html.twig | 2 ++ .../dialogs/dialog-error-report.html.twig | 4 ++++ 10 files changed, 26 insertions(+), 37 deletions(-) diff --git a/storybook/stories/components/Dialog.stories.js b/storybook/stories/components/Dialog.stories.js index 171cae4f8..b1f5bd322 100644 --- a/storybook/stories/components/Dialog.stories.js +++ b/storybook/stories/components/Dialog.stories.js @@ -29,22 +29,10 @@ export default { title: "Components/Dialog", component: Dialog, excludeStories: ["Default"], - argTypes: { - dialogSize: { - control: "select", - options: ["sm", "md", "lg"], - }, - }, }; export const Default = { args: { - dialogId: "dialog_id", - title: "Title goes here", - message: "Message goes here, lorem ipsum dolor site amet", - dialogSize: "lg", - psBaseUri: "/", - dialogDanger: false, assets_base_path: "", }, }; diff --git a/storybook/stories/components/DialogBackup.stories.js b/storybook/stories/components/DialogBackup.stories.js index ee95de0fa..6a906d908 100644 --- a/storybook/stories/components/DialogBackup.stories.js +++ b/storybook/stories/components/DialogBackup.stories.js @@ -24,7 +24,6 @@ */ import DialogBackup from "../../../views/templates/dialogs/dialog-backup.html.twig"; -import { Default as Dialog } from "./Dialog.stories"; export default { title: "Components/Dialog", @@ -32,10 +31,6 @@ export default { }; export const Backup = { - args: { - ...Dialog.args, - dialogSize: "sm", - }, play: async () => { const dialog = document.querySelector('.dialog'); dialog.showModal(); diff --git a/storybook/stories/components/DialogBackupAll.stories.js b/storybook/stories/components/DialogBackupAll.stories.js index 3ce5c6a53..064f4175c 100644 --- a/storybook/stories/components/DialogBackupAll.stories.js +++ b/storybook/stories/components/DialogBackupAll.stories.js @@ -24,7 +24,6 @@ */ import DialogBackup from "../../../views/templates/dialogs/dialog-backup-all.html.twig"; -import { Default as Dialog } from "./Dialog.stories"; export default { title: "Components/Dialog", @@ -32,10 +31,6 @@ export default { }; export const BackupWithImg = { - args: { - ...Dialog.args, - dialogSize: "sm", - }, play: async () => { const dialog = document.querySelector('.dialog'); dialog.showModal(); diff --git a/storybook/stories/components/DialogBackupDelete.stories.js b/storybook/stories/components/DialogBackupDelete.stories.js index 747caf356..14aa08aa2 100644 --- a/storybook/stories/components/DialogBackupDelete.stories.js +++ b/storybook/stories/components/DialogBackupDelete.stories.js @@ -24,7 +24,6 @@ */ import DialogBackupDelete from "../../../views/templates/dialogs/dialog-backup-delete.html.twig"; -import { Default as Dialog } from "./Dialog.stories"; export default { title: "Components/Dialog", @@ -33,11 +32,9 @@ export default { export const BackupDelete = { args: { - ...Dialog.args, - title: "Delete backup", - message: "You are about to delete the autoupgrade_save_8.1.6 backup made on 15/07/2024 8:00. As it's your only backup, you will be redirected to the module's home page.", - dialogSize: "md", - dialogDanger: true, + backup_name: "autoupgrade_save_8.1.6", + backup_date: "15/07/2024 8:00", + is_only_backup: true, }, play: async () => { const dialog = document.querySelector('.dialog'); diff --git a/storybook/stories/components/DialogErrorReport.stories.js b/storybook/stories/components/DialogErrorReport.stories.js index fe885e21d..ce35ab454 100644 --- a/storybook/stories/components/DialogErrorReport.stories.js +++ b/storybook/stories/components/DialogErrorReport.stories.js @@ -33,12 +33,7 @@ export default { export const ErrorReport = { args: { - ...Dialog.args, - dialogId: "errorDialog", - title: "Send error report?", - message: "", - dialogSize: "sm", - dataPrivacyLink: "#" + dataPrivacyLink: "#", }, play: async () => { const dialog = document.querySelector('.dialog'); diff --git a/storybook/stories/components/DialogUpdate.stories.js b/storybook/stories/components/DialogUpdate.stories.js index db3cbcd3e..0b163620f 100644 --- a/storybook/stories/components/DialogUpdate.stories.js +++ b/storybook/stories/components/DialogUpdate.stories.js @@ -34,7 +34,6 @@ export default { export const Update = { args: { ...Dialog.args, - dialogSize: "md", noBackUp: false, form_route_to_confirm: "/", }, diff --git a/views/templates/components/dialog.html.twig b/views/templates/components/dialog.html.twig index c77afc0e1..09dd137a0 100644 --- a/views/templates/components/dialog.html.twig +++ b/views/templates/components/dialog.html.twig @@ -1,5 +1,5 @@ -
diff --git a/views/templates/dialogs/dialog-backup-delete.html.twig b/views/templates/dialogs/dialog-backup-delete.html.twig index 7eb1d1794..9e50e8741 100644 --- a/views/templates/dialogs/dialog-backup-delete.html.twig +++ b/views/templates/dialogs/dialog-backup-delete.html.twig @@ -1,5 +1,19 @@ {% extends "@ModuleAutoUpgrade/components/dialog.html.twig" %} +{% set title = 'Delete backup'|trans({}) %} +{% set message = 'You are about to delete the [1]%backup_name%[/1] backup made on [1]%backup_date%[/1]. %redirect_message%'|trans({ + '%backup_name%': backup_name, + '%backup_date%': backup_date, + '%redirect_message%': is_only_backup ? 'As it\'s your only backup, you will be redirected to the module\'s home page.'|trans : '', + '[1]': '', + '[/1]': '' +}) %} +{% set dialogDanger = true %} + +{% block dialog_content %} + {{ parent() }} +{% endblock %} + {% block dialog_extra_content %}{% endblock %} {% block dialog_footer %} diff --git a/views/templates/dialogs/dialog-backup.html.twig b/views/templates/dialogs/dialog-backup.html.twig index 58d6dd34f..eab9d332e 100644 --- a/views/templates/dialogs/dialog-backup.html.twig +++ b/views/templates/dialogs/dialog-backup.html.twig @@ -1,5 +1,7 @@ {% extends "@ModuleAutoUpgrade/components/dialog.html.twig" %} + {% set title = 'Start backup?'|trans({}) %} +{% set dialogSize = 'sm' %} {% set message = 'Your files and database will be backed up.'|trans({}) %} {% block dialog_content %} diff --git a/views/templates/dialogs/dialog-error-report.html.twig b/views/templates/dialogs/dialog-error-report.html.twig index 6dd6807fa..4bea3fc04 100644 --- a/views/templates/dialogs/dialog-error-report.html.twig +++ b/views/templates/dialogs/dialog-error-report.html.twig @@ -1,5 +1,9 @@ {% extends "@ModuleAutoUpgrade/components/dialog.html.twig" %} +{% set dialogId = 'errorDialog' %} +{% set title = 'Send error report?'|trans({}) %} +{% set dialogSize = 'sm' %} + {% block dialog_content %}

From 86251f1391ab38f7580695822908a9a088638323 Mon Sep 17 00:00:00 2001 From: tblivet Date: Thu, 12 Dec 2024 16:48:10 +0100 Subject: [PATCH 3/5] feat: remove params --- classes/Traits/DisplayErrorReportDialogTrait.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/Traits/DisplayErrorReportDialogTrait.php b/classes/Traits/DisplayErrorReportDialogTrait.php index 285fd0f2f..dc57a93e3 100644 --- a/classes/Traits/DisplayErrorReportDialogTrait.php +++ b/classes/Traits/DisplayErrorReportDialogTrait.php @@ -41,8 +41,6 @@ public function submitErrorReport(): JsonResponse $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, ] ), From 6007d7a1f7548bdb5246ee086c8acb41bec50f36 Mon Sep 17 00:00:00 2001 From: tblivet Date: Thu, 12 Dec 2024 18:38:00 +0100 Subject: [PATCH 4/5] fix: storybook --- storybook/stories/components/Alert.stories.js | 3 +-- .../components/DialogErrorReport.stories.js | 3 +-- .../stories/components/LogsViewer.stories.js | 4 ++++ .../stories/components/Privacy.stories.js | 3 +++ storybook/stories/layouts/Page.stories.js | 1 + storybook/stories/pages/Backup.stories.js | 4 +--- .../stories/pages/BackupSelection.stories.js | 1 + storybook/stories/pages/Home.stories.js | 1 + .../stories/pages/PostRestore.stories.js | 1 + storybook/stories/pages/PostUpdate.stories.js | 1 + storybook/stories/pages/Restore.stories.js | 1 + storybook/stories/pages/Update.stories.js | 6 +++++ .../stories/pages/UpdateOptions.stories.js | 4 +--- .../stories/pages/VersionChoice.stories.js | 1 + views/templates/components/alert.html.twig | 24 +++++++++---------- 15 files changed, 36 insertions(+), 22 deletions(-) diff --git a/storybook/stories/components/Alert.stories.js b/storybook/stories/components/Alert.stories.js index 797085a67..0951e5282 100644 --- a/storybook/stories/components/Alert.stories.js +++ b/storybook/stories/components/Alert.stories.js @@ -45,6 +45,7 @@ export const Default = { alertStatus: "success", buttonLabel: "Download backup logs", buttonUrl: "#", + buttonDownload: "backup.log", }, }; @@ -53,8 +54,6 @@ export const NoLocalArchive = { title: "", message: "It’s available at admin/autoupgrade/backup. You're ready to start the update now.", alertStatus: "success", - buttonLabel: "", - buttonUrl: "", }, }; diff --git a/storybook/stories/components/DialogErrorReport.stories.js b/storybook/stories/components/DialogErrorReport.stories.js index ce35ab454..aae9ce9c8 100644 --- a/storybook/stories/components/DialogErrorReport.stories.js +++ b/storybook/stories/components/DialogErrorReport.stories.js @@ -24,7 +24,6 @@ */ import DialogErrorReport from "../../../views/templates/dialogs/dialog-error-report.html.twig"; -import { Default as Dialog } from "./Dialog.stories"; export default { title: "Components/Dialog", @@ -33,7 +32,7 @@ export default { export const ErrorReport = { args: { - dataPrivacyLink: "#", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", }, play: async () => { const dialog = document.querySelector('.dialog'); diff --git a/storybook/stories/components/LogsViewer.stories.js b/storybook/stories/components/LogsViewer.stories.js index 1c77b64de..2b29e7c84 100644 --- a/storybook/stories/components/LogsViewer.stories.js +++ b/storybook/stories/components/LogsViewer.stories.js @@ -176,6 +176,8 @@ export const Default = { ], downloadLogsButtonUrl: "#", downloadLogsButtonLabel: "Download update logs", + downloadLogsRoute: "/", + download_logs_parent_id: "download_logs" }, }; @@ -325,5 +327,7 @@ export const RestoreLogsViewer = { ], downloadLogsButtonUrl: "#", downloadLogsButtonLabel: "Download restore logs", + downloadLogsRoute: "/", + download_logs_parent_id: "download_logs" }, }; diff --git a/storybook/stories/components/Privacy.stories.js b/storybook/stories/components/Privacy.stories.js index 135f80864..b43357bec 100644 --- a/storybook/stories/components/Privacy.stories.js +++ b/storybook/stories/components/Privacy.stories.js @@ -28,6 +28,9 @@ import Privacy from "../../../views/templates/components/privacy.html.twig"; export default { component: Privacy, title: "Components/Privacy", + args: { + data_transparency_link: "https://www.prestashop-project.org/data-transparency", + }, }; export const Default = {}; diff --git a/storybook/stories/layouts/Page.stories.js b/storybook/stories/layouts/Page.stories.js index d48d7e80f..7638877eb 100644 --- a/storybook/stories/layouts/Page.stories.js +++ b/storybook/stories/layouts/Page.stories.js @@ -36,5 +36,6 @@ export const Default = { args: { ...Stepper.args, step_parent_id: "ua_container", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", }, }; diff --git a/storybook/stories/pages/Backup.stories.js b/storybook/stories/pages/Backup.stories.js index 6877d08c8..cc6c714be 100644 --- a/storybook/stories/pages/Backup.stories.js +++ b/storybook/stories/pages/Backup.stories.js @@ -39,22 +39,20 @@ export const Backup = { code: "backup", title: "Backup", }, - form_fields: { include_images: { field: 'PS_AUTOUP_KEEP_IMAGES', value: true, }, }, - form_route_to_save: "update-step-backup-save-option", form_route_to_submit: "update-step-backup-submit-backup", form_route_to_confirm_update: "update-step-backup-confirm-update", form_route_to_confirm_backup: "update-step-backup-confirm-backup", form_route_to_submit_update: "update-step-backup-submit-update", form_route_to_submit_backup: "update-step-update-options-submit-form", - step_parent_id: "ua_container", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Stepper ...Stepper.args, }, diff --git a/storybook/stories/pages/BackupSelection.stories.js b/storybook/stories/pages/BackupSelection.stories.js index 6ea90ad8a..7b667c1ef 100644 --- a/storybook/stories/pages/BackupSelection.stories.js +++ b/storybook/stories/pages/BackupSelection.stories.js @@ -41,6 +41,7 @@ export const BackupSelection = { title: "Backup selection", }, step_parent_id: "ua_container", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Backup ...BackupSelectionComponent.args, // Stepper diff --git a/storybook/stories/pages/Home.stories.js b/storybook/stories/pages/Home.stories.js index d4c1988c1..08dffcfc1 100644 --- a/storybook/stories/pages/Home.stories.js +++ b/storybook/stories/pages/Home.stories.js @@ -44,6 +44,7 @@ export const Welcome = { form_route: "form_route", form_route_to_save: "update-step-version-choice-save-form", form_route_to_submit: "update-step-version-choice-submit-form", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Radio card ...RadioCard.args, form_fields: { diff --git a/storybook/stories/pages/PostRestore.stories.js b/storybook/stories/pages/PostRestore.stories.js index e94bed3b9..0e15ceae5 100644 --- a/storybook/stories/pages/PostRestore.stories.js +++ b/storybook/stories/pages/PostRestore.stories.js @@ -46,6 +46,7 @@ export const PostRestore = { currentPhpVersion: "8.1", backlog_link: "https://myshop.com/my-backlog.txt", step_parent_id: "ua_container", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Stepper ...Stepper.args, }, diff --git a/storybook/stories/pages/PostUpdate.stories.js b/storybook/stories/pages/PostUpdate.stories.js index 1fa9ea1b3..e7f7a2b8f 100644 --- a/storybook/stories/pages/PostUpdate.stories.js +++ b/storybook/stories/pages/PostUpdate.stories.js @@ -46,6 +46,7 @@ export const PostUpdate = { currentPhpVersion: "8.1", backlog_link: "https://myshop.com/my-backlog.txt", step_parent_id: "ua_container", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Stepper ...Stepper.args }, diff --git a/storybook/stories/pages/Restore.stories.js b/storybook/stories/pages/Restore.stories.js index 6e44a795c..cb2b8f479 100644 --- a/storybook/stories/pages/Restore.stories.js +++ b/storybook/stories/pages/Restore.stories.js @@ -42,6 +42,7 @@ export const Restore = { title: "Restore", }, step_parent_id: "ua_container", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Logs ...LogsProgress.args, ...LogsViewer.args, diff --git a/storybook/stories/pages/Update.stories.js b/storybook/stories/pages/Update.stories.js index 603224b72..dd0ee8672 100644 --- a/storybook/stories/pages/Update.stories.js +++ b/storybook/stories/pages/Update.stories.js @@ -47,6 +47,12 @@ export const Update = { downloadLogsButtonLabel: "", step_parent_id: "ua_container", stepper_parent_id: "stepper_content", + backup_available: true, + restore_route: "restore-page-backup-selection", + success_route: "update-step-post-update", + download_logs_route: "update-step-update-download-logs", + submit_error_report_route: "update-step-update-submit-error-report", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Logs ...LogsProgress.args, ...LogsViewer.args, diff --git a/storybook/stories/pages/UpdateOptions.stories.js b/storybook/stories/pages/UpdateOptions.stories.js index 033bb462b..c14e7fae0 100644 --- a/storybook/stories/pages/UpdateOptions.stories.js +++ b/storybook/stories/pages/UpdateOptions.stories.js @@ -55,14 +55,12 @@ export const UpdateOptions = { }, step_parent_id: "ua_container", stepper_parent_id: "stepper_content", - form_route_to_save: "update-step-update-options-save-option", form_route_to_submit: "update-step-update-options-submit-form", - error: { 'PS_AUTOUP_REGEN_EMAIL': 'Example of an error that occured when switching the value!', }, - + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Stepper ...Stepper.args, }, diff --git a/storybook/stories/pages/VersionChoice.stories.js b/storybook/stories/pages/VersionChoice.stories.js index 8e3d860bb..d63801961 100644 --- a/storybook/stories/pages/VersionChoice.stories.js +++ b/storybook/stories/pages/VersionChoice.stories.js @@ -53,6 +53,7 @@ export const VersionChoice = { radio_card_archive_parent_id: "radio_card_archive", form_route_to_save: "update-step-version-choice-save-form", form_route_to_submit: "update-step-version-choice-submit-form", + data_transparency_link: "https://www.prestashop-project.org/data-transparency", // Radio cards ...Online.args, ...Local.args, diff --git a/views/templates/components/alert.html.twig b/views/templates/components/alert.html.twig index 340a291e6..ce7ba2bd6 100644 --- a/views/templates/components/alert.html.twig +++ b/views/templates/components/alert.html.twig @@ -2,7 +2,7 @@

{% endif %} From 18b033527adcd99d3643074e2aec6e130481b5d1 Mon Sep 17 00:00:00 2001 From: tblivet Date: Fri, 13 Dec 2024 16:47:06 +0100 Subject: [PATCH 5/5] feat: alert refacto --- storybook/stories/components/Alert.stories.js | 24 +++++++++++- .../components/alert-action-form.html.twig | 13 +++++++ .../components/alert-action-link.html.twig | 9 +++++ views/templates/components/alert.html.twig | 39 +++++-------------- .../components/check-requirements.html.twig | 2 - .../components/local-archive.html.twig | 8 +--- views/templates/steps/post-restore.html.twig | 2 - views/templates/steps/post-update.html.twig | 2 - 8 files changed, 56 insertions(+), 43 deletions(-) create mode 100644 views/templates/components/alert-action-form.html.twig create mode 100644 views/templates/components/alert-action-link.html.twig diff --git a/storybook/stories/components/Alert.stories.js b/storybook/stories/components/Alert.stories.js index 0951e5282..de50e7135 100644 --- a/storybook/stories/components/Alert.stories.js +++ b/storybook/stories/components/Alert.stories.js @@ -35,7 +35,6 @@ export default { options: ["info", "success", "warning", "danger"], }, }, - includeStories: ["Default"], }; export const Default = { @@ -43,9 +42,30 @@ export const Default = { title: "Backup completed", message: "It’s available at admin/autoupgrade/backup. You're ready to start the update now.", alertStatus: "success", + }, +}; + +export const AlertWithForm = { + args: { + title: "Update failed", + message: "Your store may not work properly anymore. Select the backup you want to use and restore it to avoid any data loss.", + alertStatus: "warning", + // Required for form + buttonLabel: "Restore", + formRoute: "/", + formName: "alert-form", + }, +}; + +export const AlertWithLink = { + args: { + title: "Backup completed", + message: "It’s available at /your-admin-directory/autoupgrade/backup. You're ready to start the update now.", + alertStatus: "success", + buttonDownload: "backup.log", + // Required for link buttonLabel: "Download backup logs", buttonUrl: "#", - buttonDownload: "backup.log", }, }; diff --git a/views/templates/components/alert-action-form.html.twig b/views/templates/components/alert-action-form.html.twig new file mode 100644 index 000000000..85598bbb7 --- /dev/null +++ b/views/templates/components/alert-action-form.html.twig @@ -0,0 +1,13 @@ +
+ +
diff --git a/views/templates/components/alert-action-link.html.twig b/views/templates/components/alert-action-link.html.twig new file mode 100644 index 000000000..ecf36741c --- /dev/null +++ b/views/templates/components/alert-action-link.html.twig @@ -0,0 +1,9 @@ + diff --git a/views/templates/components/alert.html.twig b/views/templates/components/alert.html.twig index ce7ba2bd6..d590374c1 100644 --- a/views/templates/components/alert.html.twig +++ b/views/templates/components/alert.html.twig @@ -1,43 +1,24 @@ -{% if title or message %} +{% if title is defined or message is defined %} {% endif %} diff --git a/views/templates/components/check-requirements.html.twig b/views/templates/components/check-requirements.html.twig index 9d9cbf09a..d85d5fdea 100644 --- a/views/templates/components/check-requirements.html.twig +++ b/views/templates/components/check-requirements.html.twig @@ -41,8 +41,6 @@ title: '', message: 'The requirements check is complete, you can update your store to this version of PrestaShop.'|trans({}), alertStatus: 'success', - buttonLabel: '', - buttonUrl: '', } %}
{% endif %} diff --git a/views/templates/components/local-archive.html.twig b/views/templates/components/local-archive.html.twig index bef33f35c..a1f0b40ee 100644 --- a/views/templates/components/local-archive.html.twig +++ b/views/templates/components/local-archive.html.twig @@ -68,11 +68,9 @@ {% if errors['global'] %}
{% include "@ModuleAutoUpgrade/components/alert.html.twig" with { - title: "", + title: '', message: errors['global'], - alertStatus: "warning", - buttonLabel: "", - buttonUrl: "", + alertStatus: 'warning', } %}
{% endif %} @@ -83,7 +81,5 @@ title: '', message: 'No archive found in the following directory: /your-admin-directory/autoupgrade/download/'|trans({}), alertStatus: 'warning', - buttonLabel: '', - buttonUrl: '', } %} {% endif %} diff --git a/views/templates/steps/post-restore.html.twig b/views/templates/steps/post-restore.html.twig index 7184dca79..0374f0d13 100644 --- a/views/templates/steps/post-restore.html.twig +++ b/views/templates/steps/post-restore.html.twig @@ -12,8 +12,6 @@ title: 'Your restoration is complete'|trans({}), message: 'Before continuing with your tasks, please review the following checklist to ensure smooth operation after recent recovery.'|trans({}), alertStatus: 'success', - buttonLabel: '', - buttonUrl: '', } %}
diff --git a/views/templates/steps/post-update.html.twig b/views/templates/steps/post-update.html.twig index bbb4215ca..8eb762215 100644 --- a/views/templates/steps/post-update.html.twig +++ b/views/templates/steps/post-update.html.twig @@ -12,8 +12,6 @@ title: 'Your store is up to date'|trans({}), message: 'Before continuing with your tasks, please review the following checklist to ensure smooth operation after recent updates.'|trans({}), alertStatus: 'success', - buttonLabel: '', - buttonUrl: '', } %}