Skip to content

Commit

Permalink
feat: implement intros
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <vitor@php.rio>
  • Loading branch information
vitormattos committed Jul 11, 2024
1 parent 62fe828 commit 894188a
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Check failure on line 75 in lib/AppInfo/Application.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/AppInfo/Application.php:75:35: UndefinedClass: Class, interface or enum named OCA\Intros\Events\FetchIntrosEvent does not exist (see https://psalm.dev/019)

Check failure on line 75 in lib/AppInfo/Application.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidArgument

lib/AppInfo/Application.php:75:60: InvalidArgument: Argument 2 of OCP\AppFramework\Bootstrap\IRegistrationContext::registerEventListener expects class-string<OCP\EventDispatcher\IEventListener<OCP\EventDispatcher\Event>>, but OCA\Libresign\Listener\FetchIntrosListener::class provided (see https://psalm.dev/004)
}
}
91 changes: 91 additions & 0 deletions lib/Listener/FetchIntrosListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024-2024 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Libresign\Listener;

use OCA\Files\Event\LoadSidebar;
use OCA\Intros\Events\FetchIntrosEvent;
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Handler\CertificateEngine\Handler as CertificateEngineHandler;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IL10N;

/**
* @template-implements IEventListener<Event|LoadSidebar>
*/
class FetchIntrosListener implements IEventListener {

Check failure on line 22 in lib/Listener/FetchIntrosListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedDocblockClass

lib/Listener/FetchIntrosListener.php:22:7: UndefinedDocblockClass: Docblock-defined class, interface or enum named OCA\Files\Event\LoadSidebar does not exist (see https://psalm.dev/200)

Check failure on line 22 in lib/Listener/FetchIntrosListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidTemplateParam

lib/Listener/FetchIntrosListener.php:22:38: InvalidTemplateParam: Extended template param T expects type OCP\EventDispatcher\Event, type OCA\Files\Event\LoadSidebar|OCP\EventDispatcher\Event given (see https://psalm.dev/183)
public function __construct(
private IL10N $l10n,
private CertificateEngineHandler $certificateEngineHandler,
) {
}

public function handle(Event $event): void {

Check failure on line 29 in lib/Listener/FetchIntrosListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

MoreSpecificImplementedParamType

lib/Listener/FetchIntrosListener.php:29:31: MoreSpecificImplementedParamType: Argument 1 of OCA\Libresign\Listener\FetchIntrosListener::handle has the more specific type 'OCP\EventDispatcher\Event', expecting 'OCA\Files\Event\LoadSidebar|OCP\EventDispatcher\Event' as defined by OCP\EventDispatcher\IEventListener::handle (see https://psalm.dev/140)
if (!($event instanceof FetchIntrosEvent)) {

Check failure on line 30 in lib/Listener/FetchIntrosListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Listener/FetchIntrosListener.php:30:27: UndefinedClass: Class, interface or enum named OCA\Intros\Events\FetchIntrosEvent does not exist (see https://psalm.dev/019)
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.'),
],
],
],
],
]);
}
}

0 comments on commit 894188a

Please sign in to comment.