Use absolute URI for action icons

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2017-04-11 09:09:45 +02:00
parent b8c2a8ae36
commit 2c2e1f7988
3 changed files with 29 additions and 8 deletions

View File

@ -58,7 +58,9 @@
+ ' <div class="last-message">{{contact.lastMessage}}</div>' + ' <div class="last-message">{{contact.lastMessage}}</div>'
+ '</div>' + '</div>'
+ '{{#if contact.topAction}}' + '{{#if contact.topAction}}'
+ '<a class="top-action {{contact.topAction.icon}}" href="{{contact.topAction.hyperlink}}" title="{{contact.topAction.title}}"></a>' + '<a class="top-action" href="{{contact.topAction.hyperlink}}" title="{{contact.topAction.title}}">'
+ ' <img src="{{contact.topAction.icon}}">'
+ '</a>'
+ '{{/if}}' + '{{/if}}'
+ '{{#if contact.hasManyActions}}' + '{{#if contact.hasManyActions}}'
+ ' <span class="other-actions icon-more"></span>' + ' <span class="other-actions icon-more"></span>'
@ -67,7 +69,7 @@
+ ' {{#each contact.actions}}' + ' {{#each contact.actions}}'
+ ' <li>' + ' <li>'
+ ' <a href="{{hyperlink}}">' + ' <a href="{{hyperlink}}">'
+ ' <span class="{{icon}}"></span>' + ' <img src="{{icon}}">'
+ ' <span>{{title}}</span>' + ' <span>{{title}}</span>'
+ ' </a>' + ' </a>'
+ ' </li>' + ' </li>'

View File

@ -27,26 +27,32 @@ namespace OC\Contacts\ContactsMenu\Providers;
use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\IActionFactory;
use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\ContactsMenu\IEntry;
use OCP\Contacts\ContactsMenu\IProvider; use OCP\Contacts\ContactsMenu\IProvider;
use OCP\IURLGenerator;
class EMailProvider implements IProvider { class EMailProvider implements IProvider {
/** @var IActionFactory */ /** @var IActionFactory */
private $actionFactory; private $actionFactory;
/** @var IURLGenerator */
private $urlGenerator;
/** /**
* @param IActionFactory $actionFactory * @param IActionFactory $actionFactory
* @param IURLGenerator $urlGenerator
*/ */
public function __construct(IActionFactory $actionFactory) { public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) {
$this->actionFactory = $actionFactory; $this->actionFactory = $actionFactory;
$this->urlGenerator = $urlGenerator;
} }
/** /**
* @param IEntry $entry * @param IEntry $entry
*/ */
public function process(IEntry $entry) { public function process(IEntry $entry) {
$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
foreach ($entry->getEMailAddresses() as $address) { foreach ($entry->getEMailAddresses() as $address) {
// TODO: absolute path $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address);
$action = $this->actionFactory->newEMailAction('icon-mail', $address, $address);
$entry->addAction($action); $entry->addAction($action);
} }
} }

View File

@ -28,6 +28,7 @@ use OC\Contacts\ContactsMenu\Providers\EMailProvider;
use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\IActionFactory;
use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\ContactsMenu\IEntry;
use OCP\Contacts\ContactsMenu\ILinkAction; use OCP\Contacts\ContactsMenu\ILinkAction;
use OCP\IURLGenerator;
use PHPUnit_Framework_MockObject_MockObject; use PHPUnit_Framework_MockObject_MockObject;
use Test\TestCase; use Test\TestCase;
@ -36,6 +37,9 @@ class EMailproviderTest extends TestCase {
/** @var IActionFactory|PHPUnit_Framework_MockObject_MockObject */ /** @var IActionFactory|PHPUnit_Framework_MockObject_MockObject */
private $actionFactory; private $actionFactory;
/** @var IURLGenerator|PHPUnit_Framework_MockObject_MockObject */
private $urlGenerator;
/** @var EMailProvider */ /** @var EMailProvider */
private $provider; private $provider;
@ -43,13 +47,22 @@ class EMailproviderTest extends TestCase {
parent::setUp(); parent::setUp();
$this->actionFactory = $this->createMock(IActionFactory::class); $this->actionFactory = $this->createMock(IActionFactory::class);
$this->provider = new EMailProvider($this->actionFactory); $this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->provider = new EMailProvider($this->actionFactory, $this->urlGenerator);
} }
public function testProcess() { public function testProcess() {
$entry = $this->createMock(IEntry::class); $entry = $this->createMock(IEntry::class);
$action = $this->createMock(ILinkAction::class); $action = $this->createMock(ILinkAction::class);
$iconUrl = 'https://example.com/img/actions/icon.svg';
$this->urlGenerator->expects($this->once())
->method('imagePath')
->willReturn('img/actions/icon.svg');
$this->urlGenerator->expects($this->once())
->method('getAbsoluteURL')
->with('img/actions/icon.svg')
->willReturn($iconUrl);
$entry->expects($this->once()) $entry->expects($this->once())
->method('getEMailAddresses') ->method('getEMailAddresses')
->willReturn([ ->willReturn([
@ -57,7 +70,7 @@ class EMailproviderTest extends TestCase {
]); ]);
$this->actionFactory->expects($this->once()) $this->actionFactory->expects($this->once())
->method('newEMailAction') ->method('newEMailAction')
->with($this->equalTo('icon-mail'), $this->equalTo('Mail'), $this->equalTo('user@example.com')) ->with($this->equalTo($iconUrl), $this->equalTo('user@example.com'), $this->equalTo('user@example.com'))
->willReturn($action); ->willReturn($action);
$entry->expects($this->once()) $entry->expects($this->once())
->method('addAction') ->method('addAction')