Skip to content

Commit

Permalink
Merge pull request #22099 from nextcloud/fix/unified-search
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv committed Aug 5, 2020
2 parents 0581356 + 71b62c4 commit a4d511d
Show file tree
Hide file tree
Showing 74 changed files with 437 additions and 1,458 deletions.
3 changes: 1 addition & 2 deletions apps/comments/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
'OCA\\Comments\\Listener\\LoadSidebarScripts' => $baseDir . '/../lib/Listener/LoadSidebarScripts.php',
'OCA\\Comments\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
'OCA\\Comments\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
'OCA\\Comments\\Search\\CommentsSearchResultEntry' => $baseDir . '/../lib/Search/CommentsSearchResultEntry.php',
'OCA\\Comments\\Search\\CommentsSearchProvider' => $baseDir . '/../lib/Search/CommentsSearchProvider.php',
'OCA\\Comments\\Search\\LegacyProvider' => $baseDir . '/../lib/Search/LegacyProvider.php',
'OCA\\Comments\\Search\\Provider' => $baseDir . '/../lib/Search/Provider.php',
'OCA\\Comments\\Search\\Result' => $baseDir . '/../lib/Search/Result.php',
);
3 changes: 1 addition & 2 deletions apps/comments/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class ComposerStaticInitComments
'OCA\\Comments\\Listener\\LoadSidebarScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarScripts.php',
'OCA\\Comments\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
'OCA\\Comments\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
'OCA\\Comments\\Search\\CommentsSearchResultEntry' => __DIR__ . '/..' . '/../lib/Search/CommentsSearchResultEntry.php',
'OCA\\Comments\\Search\\CommentsSearchProvider' => __DIR__ . '/..' . '/../lib/Search/CommentsSearchProvider.php',
'OCA\\Comments\\Search\\LegacyProvider' => __DIR__ . '/..' . '/../lib/Search/LegacyProvider.php',
'OCA\\Comments\\Search\\Provider' => __DIR__ . '/..' . '/../lib/Search/Provider.php',
'OCA\\Comments\\Search\\Result' => __DIR__ . '/..' . '/../lib/Search/Result.php',
);

Expand Down
2 changes: 1 addition & 1 deletion apps/comments/js/comments.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/comments/js/comments.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/comments/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use OCA\Comments\Listener\LoadSidebarScripts;
use OCA\Comments\Notification\Notifier;
use OCA\Comments\Search\LegacyProvider;
use OCA\Comments\Search\Provider;
use OCA\Comments\Search\CommentsSearchProvider;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCP\AppFramework\App;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function register(IRegistrationContext $context): void {
CommentsEntityEvent::EVENT_ENTITY,
CommentsEntityEventListener::class
);
$context->registerSearchProvider(Provider::class);
$context->registerSearchProvider(CommentsSearchProvider::class);
}

public function boot(IBootContext $context): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
use OCP\Search\IProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
use OCP\Search\SearchResultEntry;
use function array_map;
use function pathinfo;

class Provider implements IProvider {
class CommentsSearchProvider implements IProvider {

/** @var IUserManager */
private $userManager;
Expand All @@ -59,14 +60,30 @@ public function __construct(IUserManager $userManager,
$this->legacyProvider = $legacyProvider;
}

/**
* @inheritDoc
*/
public function getId(): string {
return 'comments';
}

/**
* @inheritDoc
*/
public function getName(): string {
return $this->l10n->t('Comments');
}

/**
* @inheritDoc
*/
public function getOrder(): int {
return 10;
}

/**
* @inheritDoc
*/
public function search(IUser $user, ISearchQuery $query): SearchResult {
return SearchResult::complete(
$this->l10n->t('Comments'),
Expand All @@ -77,7 +94,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
$avatarUrl = $isUser
? $this->urlGenerator->linkToRoute('core.avatar.getAvatar', ['userId' => $result->authorId, 'size' => 42])
: $this->urlGenerator->linkToRoute('core.GuestAvatar.getAvatar', ['guestName' => $result->authorId, 'size' => 42]);
return new CommentsSearchResultEntry(
return new SearchResultEntry(
$avatarUrl,
$result->name,
$path,
Expand Down
31 changes: 0 additions & 31 deletions apps/comments/lib/Search/CommentsSearchResultEntry.php

This file was deleted.

1 change: 0 additions & 1 deletion apps/comments/src/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import './commentstabview'
import './commentsmodifymenu'
import './filesplugin'
import './activitytabviewplugin'
import './search'

import './vendor/Caret.js/dist/jquery.caret.min'
import './vendor/At.js/dist/js/jquery.atwho.min'
Expand Down
137 changes: 0 additions & 137 deletions apps/comments/src/search.js

This file was deleted.

3 changes: 0 additions & 3 deletions apps/dav/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,8 @@
'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php',
'OCA\\DAV\\Search\\ACalendarSearchProvider' => $baseDir . '/../lib/Search/ACalendarSearchProvider.php',
'OCA\\DAV\\Search\\ContactsSearchProvider' => $baseDir . '/../lib/Search/ContactsSearchProvider.php',
'OCA\\DAV\\Search\\ContactsSearchResultEntry' => $baseDir . '/../lib/Search/ContactsSearchResultEntry.php',
'OCA\\DAV\\Search\\EventsSearchProvider' => $baseDir . '/../lib/Search/EventsSearchProvider.php',
'OCA\\DAV\\Search\\EventsSearchResultEntry' => $baseDir . '/../lib/Search/EventsSearchResultEntry.php',
'OCA\\DAV\\Search\\TasksSearchProvider' => $baseDir . '/../lib/Search/TasksSearchProvider.php',
'OCA\\DAV\\Search\\TasksSearchResultEntry' => $baseDir . '/../lib/Search/TasksSearchResultEntry.php',
'OCA\\DAV\\Server' => $baseDir . '/../lib/Server.php',
'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir . '/../lib/Settings/CalDAVSettings.php',
'OCA\\DAV\\Storage\\PublicOwnerWrapper' => $baseDir . '/../lib/Storage/PublicOwnerWrapper.php',
Expand Down
3 changes: 0 additions & 3 deletions apps/dav/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,8 @@ class ComposerStaticInitDAV
'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php',
'OCA\\DAV\\Search\\ACalendarSearchProvider' => __DIR__ . '/..' . '/../lib/Search/ACalendarSearchProvider.php',
'OCA\\DAV\\Search\\ContactsSearchProvider' => __DIR__ . '/..' . '/../lib/Search/ContactsSearchProvider.php',
'OCA\\DAV\\Search\\ContactsSearchResultEntry' => __DIR__ . '/..' . '/../lib/Search/ContactsSearchResultEntry.php',
'OCA\\DAV\\Search\\EventsSearchProvider' => __DIR__ . '/..' . '/../lib/Search/EventsSearchProvider.php',
'OCA\\DAV\\Search\\EventsSearchResultEntry' => __DIR__ . '/..' . '/../lib/Search/EventsSearchResultEntry.php',
'OCA\\DAV\\Search\\TasksSearchProvider' => __DIR__ . '/..' . '/../lib/Search/TasksSearchProvider.php',
'OCA\\DAV\\Search\\TasksSearchResultEntry' => __DIR__ . '/..' . '/../lib/Search/TasksSearchResultEntry.php',
'OCA\\DAV\\Server' => __DIR__ . '/..' . '/../lib/Server.php',
'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__ . '/..' . '/../lib/Settings/CalDAVSettings.php',
'OCA\\DAV\\Storage\\PublicOwnerWrapper' => __DIR__ . '/..' . '/../lib/Storage/PublicOwnerWrapper.php',
Expand Down
12 changes: 10 additions & 2 deletions apps/dav/lib/Search/ContactsSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\Search\IProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
use OCP\Search\SearchResultEntry;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Reader;

Expand Down Expand Up @@ -92,6 +93,13 @@ public function getName(): string {
return $this->l10n->t('Contacts');
}

/**
* @inheritDoc
*/
public function getOrder(): int {
return 7;
}

/**
* @inheritDoc
*/
Expand All @@ -116,7 +124,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
'offset' => $query->getCursor(),
]
);
$formattedResults = \array_map(function (array $contactRow) use ($addressBooksById):ContactsSearchResultEntry {
$formattedResults = \array_map(function (array $contactRow) use ($addressBooksById):SearchResultEntry {
$addressBook = $addressBooksById[$contactRow['addressbookid']];

/** @var VCard $vCard */
Expand All @@ -130,7 +138,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
$subline = $this->generateSubline($vCard);
$resourceUrl = $this->getDeepLinkToContactsApp($addressBook['uri'], (string) $vCard->UID);

return new ContactsSearchResultEntry($thumbnailUrl, $title, $subline, $resourceUrl, 'icon-contacts-dark', true);
return new SearchResultEntry($thumbnailUrl, $title, $subline, $resourceUrl, 'icon-contacts-dark', true);
}, $searchResults);

return SearchResult::paginated(
Expand Down
30 changes: 0 additions & 30 deletions apps/dav/lib/Search/ContactsSearchResultEntry.php

This file was deleted.

Loading

0 comments on commit a4d511d

Please sign in to comment.