From b48320c892491da97130b3c8b8fd517532ec3c4e Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Tue, 26 Nov 2024 21:42:43 +0100 Subject: [PATCH] fixup! feat(contacts-menu): implement custom javascript hook action --- core/src/components/ContactsMenu/Contact.vue | 40 +++++------ .../Contacts/ContactsMenu/ActionFactory.php | 19 ----- .../ContactsMenu/Actions/JavascriptAction.php | 71 ------------------- .../ContactsMenu/Actions/LinkAction.php | 3 - .../Contacts/ContactsMenu/IActionFactory.php | 18 ----- 5 files changed, 18 insertions(+), 133 deletions(-) delete mode 100644 lib/private/Contacts/ContactsMenu/Actions/JavascriptAction.php diff --git a/core/src/components/ContactsMenu/Contact.vue b/core/src/components/ContactsMenu/Contact.vue index 18c2d86a732a9..4a2b284286065 100644 --- a/core/src/components/ContactsMenu/Contact.vue +++ b/core/src/components/ContactsMenu/Contact.vue @@ -22,7 +22,7 @@ {{ action.title }} - + {{ action.title }} - - - {{ action.title }} - + + + {{ action.displayName(contact) }} + @@ -60,10 +58,8 @@ import NcActionText from '@nextcloud/vue/dist/Components/NcActionText.js' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js' -import { - callContactsMenuHook, - hasContactsMenuHook, -} from '@nextcloud/vue/dist/Functions/contactsMenu.js' +import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js' +import { getEnabledContactsMenuActions } from '@nextcloud/vue/dist/Functions/contactsMenu.js' export default { name: 'Contact', @@ -73,6 +69,7 @@ export default { NcActionButton, NcActions, NcAvatar, + NcIconSvgWrapper, }, props: { contact: { @@ -87,6 +84,9 @@ export default { } return this.contact.actions }, + jsActions() { + return getEnabledContactsMenuActions(this.contact) + }, preloadedUserStatus() { if (this.contact.status) { return { @@ -98,10 +98,6 @@ export default { return undefined }, }, - methods: { - hasContactsMenuHook, - callContactsMenuHook, - }, } diff --git a/lib/private/Contacts/ContactsMenu/ActionFactory.php b/lib/private/Contacts/ContactsMenu/ActionFactory.php index f8ecccb288a8b..71ebe575fdd80 100644 --- a/lib/private/Contacts/ContactsMenu/ActionFactory.php +++ b/lib/private/Contacts/ContactsMenu/ActionFactory.php @@ -5,9 +5,7 @@ */ namespace OC\Contacts\ContactsMenu; -use OC\Contacts\ContactsMenu\Actions\JavascriptAction; use OC\Contacts\ContactsMenu\Actions\LinkAction; -use OCP\Contacts\ContactsMenu\IAction; use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\ILinkAction; @@ -30,21 +28,4 @@ public function newLinkAction(string $icon, string $name, string $href, string $ public function newEMailAction(string $icon, string $name, string $email, string $appId = ''): ILinkAction { return $this->newLinkAction($icon, $name, 'mailto:' . $email, $appId); } - - /** - * {@inheritDoc} - */ - public function newJavascriptAction( - string $icon, - string $name, - string $hook, - string $appId = '', - ): IAction { - $action = new JavascriptAction(); - $action->setIcon($icon); - $action->setName($name); - $action->setHook($hook); - $action->setAppId($appId); - return $action; - } } diff --git a/lib/private/Contacts/ContactsMenu/Actions/JavascriptAction.php b/lib/private/Contacts/ContactsMenu/Actions/JavascriptAction.php deleted file mode 100644 index 73591e18612d3..0000000000000 --- a/lib/private/Contacts/ContactsMenu/Actions/JavascriptAction.php +++ /dev/null @@ -1,71 +0,0 @@ -icon = $icon; - } - - public function getName(): string { - return $this->name; - } - - public function setName(string $name) { - $this->name = $name; - } - - public function setPriority(int $priority) { - $this->priority = $priority; - } - - public function getPriority(): int { - return $this->priority; - } - - public function setAppId(string $appId) { - $this->appId = $appId; - } - - public function getAppId(): string { - return $this->appId; - } - - public function getHook(): string { - return $this->hook; - } - - public function setHook(string $hook): void { - $this->hook = $hook; - } - - function jsonSerialize() { - return [ - 'type' => self::TYPE, - 'title' => $this->name, - 'icon' => $this->icon, - 'appId' => $this->appId, - 'hook' => $this->hook, - ]; - } -} diff --git a/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php b/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php index 5104a6c669c6f..0d4cc9b9b013c 100644 --- a/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php +++ b/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php @@ -8,8 +8,6 @@ use OCP\Contacts\ContactsMenu\ILinkAction; class LinkAction implements ILinkAction { - public const TYPE = 'LinkAction'; - private string $icon = ''; private string $name = ''; private string $href = ''; @@ -66,7 +64,6 @@ public function getAppId(): string { */ public function jsonSerialize(): array { return [ - 'type' => self::TYPE, 'title' => $this->name, 'icon' => $this->icon, 'hyperlink' => $this->href, diff --git a/lib/public/Contacts/ContactsMenu/IActionFactory.php b/lib/public/Contacts/ContactsMenu/IActionFactory.php index 64da0f68ebe42..a4785d1c70c30 100644 --- a/lib/public/Contacts/ContactsMenu/IActionFactory.php +++ b/lib/public/Contacts/ContactsMenu/IActionFactory.php @@ -34,22 +34,4 @@ public function newLinkAction(string $icon, string $name, string $href, string $ * @return ILinkAction */ public function newEMailAction(string $icon, string $name, string $email, string $appId = ''): ILinkAction; - - /** - * Construct and return a new javascript hook action for the contacts menu - * - * @since 31.0.0 - * - * @param string $icon full path to the action's icon - * @param string $name localized name of the action - * @param string $hook id of the javascript hook as registered in the frontend - * @param string $appId the appName registering the action - * @return IAction - */ - public function newJavascriptAction( - string $icon, - string $name, - string $hook, - string $appId = '', - ): IAction; }