-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(devmanual): Document contacts menu basics #11222
Merged
+90
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
developer_manual/digging_deeper/groupware/contacts_menu.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
============= | ||
Contacts Menu | ||
============= | ||
|
||
Nextcloud shows a *Contacts menu* in the right corner of the header. This menu lists a user's contacts. These contact entries can be extended by apps. | ||
|
||
Apps that extend the contacts menu implement an IProvider. The providers ``process`` method is called for every entry show in the contacts menu. | ||
|
||
.. code-block:: php | ||
:caption: lib/ContactsMenu/MyProvider.php | ||
<?php | ||
namespace OCA\MyApp\ContactsMenu; | ||
use OCP\Contacts\ContactsMenu\IEntry; | ||
use OCP\Contacts\ContactsMenu\IProvider; | ||
class MyProvider implements IProvider { | ||
public function process(IEntry $entry): void { | ||
// todo: something useful | ||
} | ||
} | ||
.. code-block:: xml | ||
:caption: appinfo/info.xml | ||
:emphasize-lines: 6-8 | ||
<?xml version="1.0"?> | ||
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd"> | ||
<id>my_app</id> | ||
<name>My App</name> | ||
<contactsmenu> | ||
<provider>OCA\MyApp\ContactsMenu\LinkActionProvider</provider> | ||
</contactsmenu> | ||
</info> | ||
Accessing contact info | ||
^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
The ``IEntry`` objects offer getters to contact infos: | ||
|
||
* ``getFullName()``: Get full name. Falls back to an empty string if no full name is set. | ||
* ``getEMailAddresses()``: Get all email addresses. | ||
* ``getAvatar()``: Get the avatar URI. | ||
* ``getProperty(string $name)``: Read a `vCard property <https://www.rfc-editor.org/rfc/rfc6350#page-23>`_ of the contact. Return NULL if the property is not set. | ||
|
||
Actions | ||
^^^^^^^ | ||
|
||
Providers can add actions to contact entries. Right now email and link actions are supported. These are created with the help of the ``IActionFactory``. | ||
|
||
.. code-block:: php | ||
:caption: lib/ContactsMenu/LinkProvider.php | ||
<?php | ||
namespace OCA\MyApp\ContactsMenu; | ||
use OCP\Contacts\ContactsMenu\IEntry; | ||
use OCP\Contacts\ContactsMenu\IProvider; | ||
class LinkProvider implements IProvider { | ||
private IActionFactory $actionFactory; | ||
public function __construct(IActionFactory $actionFactory) { | ||
$this->actionFactory = $actionFactory | ||
} | ||
public function process(IEntry $entry): void { | ||
$emailAction = $this->actionFactory->newEMailAction( | ||
'/apps/myapp/img/link.png', // icon URL | ||
'Click me', // name | ||
'user@domain.tld', // email address | ||
'my_app', // app ID (optional) | ||
); | ||
$linkAction = $this->actionFactory->newLinkAction( | ||
'/apps/myapp/img/link.png', // icon URL | ||
'Click me', // name | ||
'https://.....', // href | ||
'my_app', // app ID (optional) | ||
); | ||
$entry->addAction($emailAction); | ||
$entry->addAction($linkAction); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ Groupware integration | |
|
||
calendar | ||
calendar_provider | ||
contacts_menu |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
An image (as an example might be nice here).
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.
I'm not a fan of too many screenshots in the docs because they are getting outdated so fast and redoing all screenshots for a release is a lot of work
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 was just a suggestion. Feel free to resolve this comment.