-
-
Notifications
You must be signed in to change notification settings - Fork 102
feat: add dashboard pending signatures widget #6256
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
base: main
Are you sure you want to change the base?
Conversation
42755c8 to
75371a1
Compare
|
Nice! Make a rebase with main branch. I fixed the integration tests. |
Signed-off-by: samuelsonmesquita <samuelsonma@gmail.com>
4343635 to
67205cd
Compare
Signed-off-by: samuelsonmesquita <samuelsonma@gmail.com>
67205cd to
e3b9eea
Compare
Signed-off-by: samuelsonmesquita <samuelsonma@gmail.com>
f531813 to
b58d236
Compare
Signed-off-by: samuelsonmesquita <samuelsonma@gmail.com>
b58d236 to
1d36bae
Compare
|
|
||
| $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); | ||
|
|
||
| // Register Dashboard Widget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method called already says this
| // Register Dashboard Widget |
| try { | ||
| $user = $this->userSession->getUser(); | ||
| if (!$user) { | ||
| return new WidgetItems([], $this->l10n->t('User not found')); | ||
| } | ||
|
|
||
| $result = $this->signRequestMapper->getFilesAssociatedFilesWithMe( | ||
| $user, | ||
| ['status' => [\OCA\Libresign\Db\File::STATUS_ABLE_TO_SIGN, \OCA\Libresign\Db\File::STATUS_PARTIAL_SIGNED]], | ||
| 1, | ||
| $limit, | ||
| ['sortBy' => 'created_at', 'sortDirection' => 'desc'] | ||
| ); | ||
|
|
||
| $items = []; | ||
|
|
||
| foreach ($result['data'] as $fileEntity) { | ||
| try { | ||
| $signRequest = $this->getSignRequestForUser($fileEntity, $user); | ||
|
|
||
| if (!$signRequest || $signRequest->getSigned()) { | ||
| continue; | ||
| } | ||
|
|
||
| $item = new WidgetItem( | ||
| $this->getDocumentTitle($fileEntity), | ||
| $this->getSubtitle($signRequest, $fileEntity), | ||
| $this->urlGenerator->linkToRouteAbsolute('libresign.page.signFPath', ['uuid' => $signRequest->getUuid(), 'path' => 'pdf']), | ||
| $this->urlGenerator->getAbsoluteURL( | ||
| $this->urlGenerator->imagePath('core', 'filetypes/application-pdf.svg') | ||
| ), | ||
| $this->getTimestamp($fileEntity) | ||
| ); | ||
|
|
||
| $items[] = $item; | ||
| } catch (\Exception $e) { | ||
| continue; | ||
| } | ||
| } | ||
|
|
||
| return new WidgetItems( | ||
| $items, | ||
| empty($items) ? $this->l10n->t('No pending signatures') : '', | ||
| ); | ||
| } catch (\Exception $e) { | ||
| return new WidgetItems( | ||
| [], | ||
| $this->l10n->t('Error loading pending signatures'), | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's strange a very big try catch. Maybe could be removed and believe into the requested methods.
The insider try catch also sounds strange because it's a controlled environment, isn't this?
| return null; | ||
| } | ||
|
|
||
| private function signRequestBelongsToUser(\OCA\Libresign\Db\SignRequest $signRequest, \OCP\IUser $user): bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method isn't necessary because the method to list already will ensures this and only will return files that belongs to the signer.
Review the related logic because removing this, will affect other places of this class.
| private function getDocumentTitle(\OCA\Libresign\Db\File $fileEntity): string { | ||
| if ($fileEntity->getName()) { | ||
| return $fileEntity->getName(); | ||
| } | ||
|
|
||
| try { | ||
| $files = $this->signFileService->getNextcloudFiles($fileEntity); | ||
| if (!empty($files)) { | ||
| $file = current($files); | ||
| return $file->getName(); | ||
| } | ||
| } catch (\Exception $e) { | ||
| } | ||
|
|
||
| return $this->l10n->t('Document'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't necessary, the table file already have a column name, you can use the name, isn't a nullable value..
vitormattos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! Visually it looks great.
I sent some comments regarding the backend; it needs some improvements.
| $displayName = $signRequest->getDisplayName(); | ||
| if ($displayName) { | ||
| $parts[] = $this->l10n->t('From: %s', [$displayName]); | ||
| } | ||
|
|
||
| $createdAt = $fileEntity->getCreatedAt(); | ||
| if ($createdAt instanceof \DateTime) { | ||
| $date = $createdAt->format('d/m/Y'); | ||
| $parts[] = $this->l10n->t('Date: %s', [$date]); | ||
| } | ||
|
|
||
| return implode(' • ', $parts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't good to use implode with translated words. This could generate problems when the user language is RTL and not LTR.
Created at always exists and the name too.
Also is good to use // TRANSLATORS to add the translation context to translators.


Pull Request Description
This pull request introduces a new Dashboard widget that displays documents with pending signatures for the current user. The widget lists only files that are associated with the user and are still awaiting their signature, providing quick access directly from the Dashboard.
The implementation reuses existing LibreSign services and mappers to ensure consistent permission checks and filtering logic. Each item shows relevant document information and links directly to the signing page, improving visibility and usability for users who need to complete pending signatures.
Pull Request Type