From 7671f4a74956c5a3b548584fa2d54a378f762acf Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 7 Oct 2024 14:20:17 -0700 Subject: [PATCH] first_boot: Add notification for next steps after first setup - Since there is no way to reach the next steps page from the interface, provide a notification for it. Until the notification is dismissed, the user can reach this page with the notification. Tests: - On testing and stable containers, remove the sqlite file start the service. Complete the first setup wizard. After reaching the 'setup complete' page, notice that there is a notification for next steps to take. Title, icon, message and button text and styling are as expected. - Clicking on 'See next steps' takes us to next steps page. - Clicking on dismiss removes the notification. - Restarting the service does not bring back the notification. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/modules/first_boot/__init__.py | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plinth/modules/first_boot/__init__.py b/plinth/modules/first_boot/__init__.py index 771de746f..ded007d11 100644 --- a/plinth/modules/first_boot/__init__.py +++ b/plinth/modules/first_boot/__init__.py @@ -8,6 +8,7 @@ import os import sys from django.urls import reverse +from django.utils.translation import gettext_noop from plinth import app as app_module from plinth import cfg @@ -48,8 +49,38 @@ class FirstBootApp(app_module.App): def setup(self, old_version): """Install and configure the app.""" super().setup(old_version) + + if not old_version: + self._show_next_steps_notification() + self.enable() + def _show_next_steps_notification(self): + """After first setup, show notification for next steps.""" + from plinth.notification import Notification + title = gettext_noop('Setup complete! Next steps:') + message = gettext_noop( + 'Initial setup has been completed. Perform the next steps to make ' + 'your {box_name} operational.') + data = { + 'app_name': 'translate:' + gettext_noop('Next steps'), + 'app_icon': 'fa-arrow-right', + 'box_name': 'translate:' + cfg.box_name + } + actions = [{ + 'type': 'link', + 'class': 'primary', + 'text': gettext_noop('See next steps'), + 'url': 'first_boot:complete' + }, { + 'type': 'dismiss' + }] + Notification.update_or_create(id='first-boot-complete', + app_id='first_boot', severity='info', + title=title, message=message, + actions=actions, data=data, + group='admin', dismissed=False) + def _clear_first_boot_steps(sender, module_name, **kwargs): """Flush the cache of first boot steps so it is recreated."""