From 3fd93f23f5f51eb381b257cfe1578da4c04850d1 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 20 Mar 2017 13:42:32 +0100 Subject: [PATCH 1/9] Add contacts menu integration Signed-off-by: Christoph Wurst --- ContactsMenu/Provider/DetailsProvider.php | 71 +++++++++++++++ .../Provider/DetailsProviderTest.php | 91 +++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 ContactsMenu/Provider/DetailsProvider.php create mode 100644 tests/unit/ContactsMenu/Provider/DetailsProviderTest.php diff --git a/ContactsMenu/Provider/DetailsProvider.php b/ContactsMenu/Provider/DetailsProvider.php new file mode 100644 index 0000000000..17b22dd081 --- /dev/null +++ b/ContactsMenu/Provider/DetailsProvider.php @@ -0,0 +1,71 @@ + + * + * @author 2017 Christoph Wurst + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OC\Contacts\ContactsMenu\Providers; + +use OCP\Contacts\ContactsMenu\IActionFactory; +use OCP\Contacts\ContactsMenu\IEntry; +use OCP\Contacts\ContactsMenu\IProvider; +use OCP\IURLGenerator; + +/** + * @todo move to contacts app + */ +class DetailsProvider implements IProvider { + + /** @var IURLGenerator */ + private $urlGenerator; + + /** @var IActionFactory */ + private $actionFactory; + + /** + * @param IURLGenerator $urlGenerator + * @param IActionFactory $actionFactory + */ + public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory) { + $this->actionFactory = $actionFactory; + $this->urlGenerator = $urlGenerator; + } + + /** + * @param IEntry $entry + */ + public function process(IEntry $entry) { + $uid = $entry->getProperty('UID'); + + if (is_null($uid)) { + // Nothing to do + return; + } + + // TODO: unique contact URL to the contacts app + // TODO: l10n + $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts'); + $action = $this->actionFactory->newLinkAction('icon-info', 'Details', $contactsUrl); + $action->setPriority(0); + $entry->addAction($action); + } + +} diff --git a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php new file mode 100644 index 0000000000..6e9871eb85 --- /dev/null +++ b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php @@ -0,0 +1,91 @@ + + * + * @author 2017 Christoph Wurst + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace Tests\Contacts\ContactsMenu\Providers; + +use OC\Contacts\ContactsMenu\Providers\DetailsProvider; +use OCP\Contacts\ContactsMenu\IActionFactory; +use OCP\Contacts\ContactsMenu\IEntry; +use OCP\Contacts\ContactsMenu\ILinkAction; +use OCP\IURLGenerator; +use PHPUnit_Framework_MockObject_MockObject; +use Test\TestCase; + +class DetailsProviderTest extends TestCase { + + /** @var IURLGenerator|PHPUnit_Framework_MockObject_MockObject */ + private $urlGenerator; + + /** @var IActionFactory|PHPUnit_Framework_MockObject_MockObject */ + private $actionFactory; + + /** @var DetailsProvider */ + private $provider; + + protected function setUp() { + parent::setUp(); + + $this->urlGenerator = $this->createMock(IURLGenerator::class); + $this->actionFactory = $this->createMock(IActionFactory::class); + $this->provider = new DetailsProvider($this->urlGenerator, $this->actionFactory); + } + + public function testProcess() { + $entry = $this->createMock(IEntry::class); + $action = $this->createMock(ILinkAction::class); + + $entry->expects($this->once()) + ->method('getProperty') + ->with($this->equalTo('UID')) + ->willReturn('e3a71614-c602-4eb5-9994-47eec551542b'); + $this->urlGenerator->expects($this->once()) + ->method('getAbsoluteURL') + ->with('/index.php/apps/contacts') + ->willReturn('cloud.example.com/index.php/apps/contacts'); + $this->actionFactory->expects($this->once()) + ->method('newLinkAction') + ->with($this->equalTo('icon-info'), $this->equalTo('Details'), $this->equalTo('cloud.example.com/index.php/apps/contacts')) + ->willReturn($action); + $action->expects($this->once()) + ->method('setPriority') + ->with($this->equalTo(0)); + $entry->expects($this->once()) + ->method('addAction') + ->with($action); + + $this->provider->process($entry); + } + + public function testProcessNoUID() { + $entry = $this->createMock(IEntry::class); + + $entry->expects($this->once()) + ->method('getProperty') + ->with($this->equalTo('UID')) + ->willReturn(null); + + $this->provider->process($entry); + } + +} From 7df5447c251330227649ae6609e48d8b0dabe68e Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 3 Apr 2017 17:23:30 +0200 Subject: [PATCH 2/9] Register contactsmenu provider via info.xml Signed-off-by: Christoph Wurst --- appinfo/info.xml | 3 + .../Providers/DetailsProvider.php | 71 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 lib/ContactsMenu/Providers/DetailsProvider.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 03ca2f64a8..51c01de74c 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -26,4 +26,7 @@ 168708 + + OCA\Contacts\ContactsMenu\Providers\DetailsProvider + diff --git a/lib/ContactsMenu/Providers/DetailsProvider.php b/lib/ContactsMenu/Providers/DetailsProvider.php new file mode 100644 index 0000000000..3a45156486 --- /dev/null +++ b/lib/ContactsMenu/Providers/DetailsProvider.php @@ -0,0 +1,71 @@ + + * + * @author 2017 Christoph Wurst + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Contacts\ContactsMenu\Providers; + +use OCP\Contacts\ContactsMenu\IActionFactory; +use OCP\Contacts\ContactsMenu\IEntry; +use OCP\Contacts\ContactsMenu\IProvider; +use OCP\IURLGenerator; + +/** + * @todo move to contacts app + */ +class DetailsProvider implements IProvider { + + /** @var IURLGenerator */ + private $urlGenerator; + + /** @var IActionFactory */ + private $actionFactory; + + /** + * @param IURLGenerator $urlGenerator + * @param IActionFactory $actionFactory + */ + public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory) { + $this->actionFactory = $actionFactory; + $this->urlGenerator = $urlGenerator; + } + + /** + * @param IEntry $entry + */ + public function process(IEntry $entry) { + $uid = $entry->getProperty('UID'); + + if (is_null($uid)) { + // Nothing to do + return; + } + + // TODO: unique contact URL to the contacts app + // TODO: l10n + $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts'); + $action = $this->actionFactory->newLinkAction('icon-info', 'Details', $contactsUrl); + $action->setPriority(0); + $entry->addAction($action); + } + +} From f564f17cd4880d4fd92f6a726bdc069560fc9284 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 10 Apr 2017 16:58:31 +0200 Subject: [PATCH 3/9] fixup! Add contacts menu integration Signed-off-by: Christoph Wurst --- ContactsMenu/Provider/DetailsProvider.php | 71 ----------------------- 1 file changed, 71 deletions(-) delete mode 100644 ContactsMenu/Provider/DetailsProvider.php diff --git a/ContactsMenu/Provider/DetailsProvider.php b/ContactsMenu/Provider/DetailsProvider.php deleted file mode 100644 index 17b22dd081..0000000000 --- a/ContactsMenu/Provider/DetailsProvider.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * @author 2017 Christoph Wurst - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -namespace OC\Contacts\ContactsMenu\Providers; - -use OCP\Contacts\ContactsMenu\IActionFactory; -use OCP\Contacts\ContactsMenu\IEntry; -use OCP\Contacts\ContactsMenu\IProvider; -use OCP\IURLGenerator; - -/** - * @todo move to contacts app - */ -class DetailsProvider implements IProvider { - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var IActionFactory */ - private $actionFactory; - - /** - * @param IURLGenerator $urlGenerator - * @param IActionFactory $actionFactory - */ - public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory) { - $this->actionFactory = $actionFactory; - $this->urlGenerator = $urlGenerator; - } - - /** - * @param IEntry $entry - */ - public function process(IEntry $entry) { - $uid = $entry->getProperty('UID'); - - if (is_null($uid)) { - // Nothing to do - return; - } - - // TODO: unique contact URL to the contacts app - // TODO: l10n - $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts'); - $action = $this->actionFactory->newLinkAction('icon-info', 'Details', $contactsUrl); - $action->setPriority(0); - $entry->addAction($action); - } - -} From 07f1bb1013f1427d14d4b4c3b93a7e4fce4a261f Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 11 Apr 2017 08:40:52 +0200 Subject: [PATCH 4/9] Ignore system contacts Signed-off-by: Christoph Wurst --- .../Providers/DetailsProvider.php | 8 +++-- .../Provider/DetailsProviderTest.php | 31 ++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/ContactsMenu/Providers/DetailsProvider.php b/lib/ContactsMenu/Providers/DetailsProvider.php index 3a45156486..03231720ad 100644 --- a/lib/ContactsMenu/Providers/DetailsProvider.php +++ b/lib/ContactsMenu/Providers/DetailsProvider.php @@ -29,9 +29,6 @@ use OCP\Contacts\ContactsMenu\IProvider; use OCP\IURLGenerator; -/** - * @todo move to contacts app - */ class DetailsProvider implements IProvider { /** @var IURLGenerator */ @@ -60,6 +57,11 @@ public function process(IEntry $entry) { return; } + if ($entry->getProperty('isLocalSystemBook') === true) { + // Cannot show details -> ignore + return; + } + // TODO: unique contact URL to the contacts app // TODO: l10n $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts'); diff --git a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php index 6e9871eb85..85f34cb4d5 100644 --- a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php +++ b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php @@ -24,15 +24,15 @@ namespace Tests\Contacts\ContactsMenu\Providers; -use OC\Contacts\ContactsMenu\Providers\DetailsProvider; +use OCA\Contacts\ContactsMenu\Providers\DetailsProvider; use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\ContactsMenu\ILinkAction; use OCP\IURLGenerator; use PHPUnit_Framework_MockObject_MockObject; -use Test\TestCase; +use PHPUnit_Framework_TestCase; -class DetailsProviderTest extends TestCase { +class DetailsProviderTest extends PHPUnit_Framework_TestCase { /** @var IURLGenerator|PHPUnit_Framework_MockObject_MockObject */ private $urlGenerator; @@ -55,10 +55,12 @@ public function testProcess() { $entry = $this->createMock(IEntry::class); $action = $this->createMock(ILinkAction::class); - $entry->expects($this->once()) + $entry->expects($this->exactly(2)) ->method('getProperty') - ->with($this->equalTo('UID')) - ->willReturn('e3a71614-c602-4eb5-9994-47eec551542b'); + ->will($this->returnValueMap([ + ['UID', 'e3a71614-c602-4eb5-9994-47eec551542b'], + ['isLocalSystemBook', null] + ])); $this->urlGenerator->expects($this->once()) ->method('getAbsoluteURL') ->with('/index.php/apps/contacts') @@ -79,11 +81,26 @@ public function testProcess() { public function testProcessNoUID() { $entry = $this->createMock(IEntry::class); - $entry->expects($this->once()) ->method('getProperty') ->with($this->equalTo('UID')) ->willReturn(null); + $entry->expects($this->never()) + ->method('addAction'); + + $this->provider->process($entry); + } + + public function testProcessSystemContact() { + $entry = $this->createMock(IEntry::class); + $entry->expects($this->exactly(2)) + ->method('getProperty') + ->will($this->returnValueMap([ + ['UID', 1234], + ['isLocalSystemBook', true] + ])); + $entry->expects($this->never()) + ->method('addAction'); $this->provider->process($entry); } From a309d7c2802f654c5c13b76672620f438cffb9be Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 11 Apr 2017 09:22:46 +0200 Subject: [PATCH 5/9] Use absolute path for icon url Signed-off-by: Christoph Wurst --- .../Providers/DetailsProvider.php | 3 ++- .../Provider/DetailsProviderTest.php | 25 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/ContactsMenu/Providers/DetailsProvider.php b/lib/ContactsMenu/Providers/DetailsProvider.php index 03231720ad..a2223555a8 100644 --- a/lib/ContactsMenu/Providers/DetailsProvider.php +++ b/lib/ContactsMenu/Providers/DetailsProvider.php @@ -64,8 +64,9 @@ public function process(IEntry $entry) { // TODO: unique contact URL to the contacts app // TODO: l10n + $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/info.svg')); $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts'); - $action = $this->actionFactory->newLinkAction('icon-info', 'Details', $contactsUrl); + $action = $this->actionFactory->newLinkAction($iconUrl, 'Details', $contactsUrl); $action->setPriority(0); $entry->addAction($action); } diff --git a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php index 85f34cb4d5..26f00575c8 100644 --- a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php +++ b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php @@ -58,16 +58,23 @@ public function testProcess() { $entry->expects($this->exactly(2)) ->method('getProperty') ->will($this->returnValueMap([ - ['UID', 'e3a71614-c602-4eb5-9994-47eec551542b'], - ['isLocalSystemBook', null] - ])); + ['UID', 'e3a71614-c602-4eb5-9994-47eec551542b'], + ['isLocalSystemBook', null] + ])); $this->urlGenerator->expects($this->once()) + ->method('imagePath') + ->with('core', 'actions/info.svg') + ->willReturn('core/img/actions/info.svg'); + $iconUrl = 'https://example.com/core/img/actions/info.svg'; + $this->urlGenerator->expects($this->exactly(2)) ->method('getAbsoluteURL') - ->with('/index.php/apps/contacts') - ->willReturn('cloud.example.com/index.php/apps/contacts'); + ->will($this->returnValueMap([ + ['/index.php/apps/contacts', 'cloud.example.com/index.php/apps/contacts'], + ['core/img/actions/info.svg', $iconUrl], + ])); $this->actionFactory->expects($this->once()) ->method('newLinkAction') - ->with($this->equalTo('icon-info'), $this->equalTo('Details'), $this->equalTo('cloud.example.com/index.php/apps/contacts')) + ->with($this->equalTo($iconUrl), $this->equalTo('Details'), $this->equalTo('cloud.example.com/index.php/apps/contacts')) ->willReturn($action); $action->expects($this->once()) ->method('setPriority') @@ -96,9 +103,9 @@ public function testProcessSystemContact() { $entry->expects($this->exactly(2)) ->method('getProperty') ->will($this->returnValueMap([ - ['UID', 1234], - ['isLocalSystemBook', true] - ])); + ['UID', 1234], + ['isLocalSystemBook', true] + ])); $entry->expects($this->never()) ->method('addAction'); From 026d509336775b9d6bf4c1d10849f03a2e9e5692 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 24 Apr 2017 11:31:49 +0200 Subject: [PATCH 6/9] Redirect from UID to GID+UID Signed-off-by: Christoph Wurst --- js/main.js | 6 ++++++ lib/ContactsMenu/Providers/DetailsProvider.php | 3 +-- tests/unit/ContactsMenu/Provider/DetailsProviderTest.php | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/main.js b/js/main.js index 32dbf24e45..8e2c43df0e 100644 --- a/js/main.js +++ b/js/main.js @@ -15,6 +15,12 @@ angular.module('contactsApp', ['uuid4', 'angular-cache', 'ngRoute', 'ui.bootstra template: '' }); + $routeProvider.when('/contact/:uid', { + redirectTo: function(parameters) { + return '/' + t('contacts', 'All contacts') + '?uid=' + parameters.uid; + } + }); + $routeProvider.when('/:gid/:uid', { template: '' }); diff --git a/lib/ContactsMenu/Providers/DetailsProvider.php b/lib/ContactsMenu/Providers/DetailsProvider.php index a2223555a8..5bbcd08701 100644 --- a/lib/ContactsMenu/Providers/DetailsProvider.php +++ b/lib/ContactsMenu/Providers/DetailsProvider.php @@ -62,10 +62,9 @@ public function process(IEntry $entry) { return; } - // TODO: unique contact URL to the contacts app // TODO: l10n $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/info.svg')); - $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts'); + $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts#/contact/' . $uid); $action = $this->actionFactory->newLinkAction($iconUrl, 'Details', $contactsUrl); $action->setPriority(0); $entry->addAction($action); diff --git a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php index 26f00575c8..8ee73d8753 100644 --- a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php +++ b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php @@ -69,12 +69,12 @@ public function testProcess() { $this->urlGenerator->expects($this->exactly(2)) ->method('getAbsoluteURL') ->will($this->returnValueMap([ - ['/index.php/apps/contacts', 'cloud.example.com/index.php/apps/contacts'], + ['/index.php/apps/contacts#/contact/e3a71614-c602-4eb5-9994-47eec551542b', 'cloud.example.com/index.php/apps/contacts#/contact/e3a71614-c602-4eb5-9994-47eec551542b'], ['core/img/actions/info.svg', $iconUrl], ])); $this->actionFactory->expects($this->once()) ->method('newLinkAction') - ->with($this->equalTo($iconUrl), $this->equalTo('Details'), $this->equalTo('cloud.example.com/index.php/apps/contacts')) + ->with($this->equalTo($iconUrl), $this->equalTo('Details'), $this->equalTo('cloud.example.com/index.php/apps/contacts#/contact/e3a71614-c602-4eb5-9994-47eec551542b')) ->willReturn($action); $action->expects($this->once()) ->method('setPriority') From 04f992654203050d28bf6f41ab8ac2ea1019d6b0 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 24 Apr 2017 11:35:18 +0200 Subject: [PATCH 7/9] Translate details action Signed-off-by: Christoph Wurst --- lib/ContactsMenu/Providers/DetailsProvider.php | 10 +++++++--- .../ContactsMenu/Provider/DetailsProviderTest.php | 11 ++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/ContactsMenu/Providers/DetailsProvider.php b/lib/ContactsMenu/Providers/DetailsProvider.php index 5bbcd08701..c5d103c209 100644 --- a/lib/ContactsMenu/Providers/DetailsProvider.php +++ b/lib/ContactsMenu/Providers/DetailsProvider.php @@ -27,6 +27,7 @@ use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\ContactsMenu\IProvider; +use OCP\IL10N; use OCP\IURLGenerator; class DetailsProvider implements IProvider { @@ -37,13 +38,17 @@ class DetailsProvider implements IProvider { /** @var IActionFactory */ private $actionFactory; + /** @var IL10N */ + private $l10n; + /** * @param IURLGenerator $urlGenerator * @param IActionFactory $actionFactory */ - public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory) { + public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory, IL10N $l10n) { $this->actionFactory = $actionFactory; $this->urlGenerator = $urlGenerator; + $this->l10n = $l10n; } /** @@ -62,10 +67,9 @@ public function process(IEntry $entry) { return; } - // TODO: l10n $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/info.svg')); $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts#/contact/' . $uid); - $action = $this->actionFactory->newLinkAction($iconUrl, 'Details', $contactsUrl); + $action = $this->actionFactory->newLinkAction($iconUrl, $this->l10n->t('Details'), $contactsUrl); $action->setPriority(0); $entry->addAction($action); } diff --git a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php index 8ee73d8753..d1945c3acd 100644 --- a/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php +++ b/tests/unit/ContactsMenu/Provider/DetailsProviderTest.php @@ -28,6 +28,7 @@ use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\ContactsMenu\ILinkAction; +use OCP\IL10N; use OCP\IURLGenerator; use PHPUnit_Framework_MockObject_MockObject; use PHPUnit_Framework_TestCase; @@ -40,6 +41,9 @@ class DetailsProviderTest extends PHPUnit_Framework_TestCase { /** @var IActionFactory|PHPUnit_Framework_MockObject_MockObject */ private $actionFactory; + /** @var IL10n|PHPUnit_Framework_MockObject_MockObject */ + private $l10n; + /** @var DetailsProvider */ private $provider; @@ -48,7 +52,8 @@ protected function setUp() { $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->actionFactory = $this->createMock(IActionFactory::class); - $this->provider = new DetailsProvider($this->urlGenerator, $this->actionFactory); + $this->l10n = $this->createMock(IL10N::class); + $this->provider = new DetailsProvider($this->urlGenerator, $this->actionFactory, $this->l10n); } public function testProcess() { @@ -72,6 +77,10 @@ public function testProcess() { ['/index.php/apps/contacts#/contact/e3a71614-c602-4eb5-9994-47eec551542b', 'cloud.example.com/index.php/apps/contacts#/contact/e3a71614-c602-4eb5-9994-47eec551542b'], ['core/img/actions/info.svg', $iconUrl], ])); + $this->l10n->expects($this->once()) + ->method('t') + ->with('Details') + ->willReturnArgument(0); $this->actionFactory->expects($this->once()) ->method('newLinkAction') ->with($this->equalTo($iconUrl), $this->equalTo('Details'), $this->equalTo('cloud.example.com/index.php/apps/contacts#/contact/e3a71614-c602-4eb5-9994-47eec551542b')) From 013423e271cbbabd4b5c791b9b5ff8d84e2f57e2 Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Mon, 24 Apr 2017 22:27:08 +0200 Subject: [PATCH 8/9] Fix contacts always showing first contact. --- js/components/contactList/contactList_controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/components/contactList/contactList_controller.js b/js/components/contactList/contactList_controller.js index a22180d2e8..0ec837aae6 100644 --- a/js/components/contactList/contactList_controller.js +++ b/js/components/contactList/contactList_controller.js @@ -149,7 +149,7 @@ angular.module('contactsApp') if(ctrl.contactList && ctrl.contactList.length > 0) { $route.updateParams({ gid: $routeParams.gid, - uid: ctrl.contactList[0].uid() + uid: $routeParams.uid || ctrl.contactList[0].uid() }); } unbindWatch(); // unbind as we only want one update From 737d63f2a8c71cb42969e46fe4ef7e8d86758280 Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Mon, 24 Apr 2017 22:37:16 +0200 Subject: [PATCH 9/9] Use correct link for redirect. --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 8e2c43df0e..c9a22218fb 100644 --- a/js/main.js +++ b/js/main.js @@ -17,7 +17,7 @@ angular.module('contactsApp', ['uuid4', 'angular-cache', 'ngRoute', 'ui.bootstra $routeProvider.when('/contact/:uid', { redirectTo: function(parameters) { - return '/' + t('contacts', 'All contacts') + '?uid=' + parameters.uid; + return '/' + t('contacts', 'All contacts') + '/' + parameters.uid; } });