From 64512c90d6cd75ea8334f1c96cd09945872ab4a2 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Thu, 11 Jul 2024 00:30:36 -0300 Subject: [PATCH] feat: implement intros Signed-off-by: Vitor Mattos --- lib/AppInfo/Application.php | 4 ++ lib/Listener/FetchIntrosListener.php | 91 ++++++++++++++++++++++++++++ tests/psalm-baseline.xml | 18 ++++++ 3 files changed, 113 insertions(+) create mode 100644 lib/Listener/FetchIntrosListener.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index f5dbfce01f..1dc9932560 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -9,11 +9,13 @@ namespace OCA\Libresign\AppInfo; use OCA\Files\Event\LoadSidebar; +use OCA\Intros\Events\FetchIntrosEvent; use OCA\Libresign\Activity\Listener as ActivityListener; use OCA\Libresign\Events\SendSignNotificationEvent; use OCA\Libresign\Events\SignedEvent; use OCA\Libresign\Files\TemplateLoader as FilesTemplateLoader; use OCA\Libresign\Listener\BeforeNodeDeletedListener; +use OCA\Libresign\Listener\FetchIntrosListener; use OCA\Libresign\Listener\LoadSidebarListener; use OCA\Libresign\Listener\MailNotifyListener; use OCA\Libresign\Listener\NotificationListener; @@ -69,5 +71,7 @@ public function register(IRegistrationContext $context): void { $context->registerEventListener(SendSignNotificationEvent::class, MailNotifyListener::class); $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); + + $context->registerEventListener(FetchIntrosEvent::class, FetchIntrosListener::class); } } diff --git a/lib/Listener/FetchIntrosListener.php b/lib/Listener/FetchIntrosListener.php new file mode 100644 index 0000000000..299bbc5372 --- /dev/null +++ b/lib/Listener/FetchIntrosListener.php @@ -0,0 +1,91 @@ + + */ +class FetchIntrosListener implements IEventListener { + public function __construct( + private IL10N $l10n, + private CertificateEngineHandler $certificateEngineHandler, + ) { + } + + public function handle(Event $event): void { + if (!($event instanceof FetchIntrosEvent)) { + return; + } + if (!$this->certificateEngineHandler->getEngine()->isSetupOk()) { + return; + } + $event->setData([ + Application::APP_ID => [ + 'name' => $this->l10n->t('LibreSign'), + 'steps' => [ + [ + 'title' => $this->l10n->t('Welcome!'), + 'paragraphs' => [ + $this->l10n->t('The LibreSign app allows you to sign documents using your digital certificate or the certificate generated by LibreSign.'), + ], + 'choices' => [ + [ + 'success' => false, + 'label' => $this->l10n->t('Skip this tutorial'), + ] + ], + 'element' => '', + ], + [ + 'paragraphs' => [ + $this->l10n->t('Choose the file to request signatures.'), + ], + 'element' => 'div#container-request', + ], + [ + 'paragraphs' => [ + $this->l10n->t('List the files that are associated to you.'), + ], + 'element' => 'li#timeline', + ], + [ + 'paragraphs' => [ + $this->l10n->t('Validate signature'), + ], + 'element' => 'li#validation', + ], + [ + 'title' => $this->l10n->t('Settings'), + 'paragraphs' => [ + $this->l10n->t('Your personal settings.'), + $this->l10n->t('Here you can manage your digital certificate or your visible signature.'), + ], + 'element' => 'div#app-settings', + 'open' => 'div#app-settings__header > .settings-button', + 'position' => 'top', + ], + [ + 'title' => 'See you!', + 'paragraphs' => [ + $this->l10n->t('Help maintain the development of this app by contributing via GitHub Sponsors.'), + ], + ], + ], + ], + ]); + } +} diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 71964acf94..a23034d4cc 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -2,9 +2,13 @@ + + + + @@ -74,6 +78,20 @@ + + + + + + + + + + + + + +