Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement intros #3332

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
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 {
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.'),
],
],
],
],
]);
}
}
18 changes: 18 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
<file src="lib/AppInfo/Application.php">
<InvalidArgument>
<code><![CDATA[FetchIntrosListener::class]]></code>
<code><![CDATA[LoadSidebarListener::class]]></code>
<code><![CDATA[registerEventListener]]></code>
</InvalidArgument>
<UndefinedClass>
<code><![CDATA[FetchIntrosEvent]]></code>
</UndefinedClass>
</file>
<file src="lib/Command/Configure/Cfssl.php">
<MissingDependency>
Expand Down Expand Up @@ -74,6 +78,20 @@
<code><![CDATA[Pagination]]></code>
</MissingTemplateParam>
</file>
<file src="lib/Listener/FetchIntrosListener.php">
<InvalidTemplateParam>
<code><![CDATA[IEventListener]]></code>
</InvalidTemplateParam>
<MoreSpecificImplementedParamType>
<code><![CDATA[$event]]></code>
</MoreSpecificImplementedParamType>
<UndefinedClass>
<code><![CDATA[FetchIntrosEvent]]></code>
</UndefinedClass>
<UndefinedDocblockClass>
<code><![CDATA[FetchIntrosListener]]></code>
</UndefinedDocblockClass>
</file>
<file src="lib/Listener/LoadSidebarListener.php">
<InvalidTemplateParam>
<code><![CDATA[IEventListener]]></code>
Expand Down
Loading