fix search provider names/ids, set results thumbnail urls, use them in ref provider

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
Julien Veyssier
2023-02-01 00:20:12 +01:00
parent 5830dbd467
commit 264be93a74
7 changed files with 39 additions and 21 deletions

3
img/card.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" style="height: 240px; width: 240px;" viewBox="0 0 24 24">
<path d="M8 3H16C18.76 3 21 5.24 21 8V16C21 18.76 18.76 21 16 21H8C5.24 21 3 18.76 3 16V8C3 5.24 5.24 3 8 3M8 5C6.34 5 5 6.34 5 8V16C5 17.66 6.34 19 8 19H16C17.66 19 19 17.66 19 16V8C19 6.34 17.66 5 16 5H8Z" />
</svg>

After

Width:  |  Height:  |  Size: 317 B

View File

@@ -70,7 +70,7 @@ class CardReferenceProvider extends ADiscoverableReferenceProvider implements IS
* @inheritDoc * @inheritDoc
*/ */
public function getTitle(): string { public function getTitle(): string {
return $this->l10n->t('Deck cards'); return $this->l10n->t('Deck boards, cards and comments');
} }
/** /**
@@ -93,7 +93,10 @@ class CardReferenceProvider extends ADiscoverableReferenceProvider implements IS
* @inheritDoc * @inheritDoc
*/ */
public function getSupportedSearchProviderIds(): array { public function getSupportedSearchProviderIds(): array {
return ['deck']; return [
'search-deck-card-board',
'search-deck-comment',
];
} }
/** /**

View File

@@ -26,13 +26,16 @@ declare(strict_types=1);
namespace OCA\Deck\Search; namespace OCA\Deck\Search;
use OCA\Deck\AppInfo\Application;
use OCA\Deck\Db\Board; use OCA\Deck\Db\Board;
use OCP\Search\SearchResultEntry; use OCP\Search\SearchResultEntry;
class BoardSearchResultEntry extends SearchResultEntry { class BoardSearchResultEntry extends SearchResultEntry {
public function __construct(Board $board, $urlGenerator) { public function __construct(Board $board, $urlGenerator) {
parent::__construct( parent::__construct(
'', $urlGenerator->getAbsoluteURL(
$urlGenerator->imagePath(Application::APP_ID, 'deck-dark.svg')
),
$board->getTitle(), $board->getTitle(),
'', '',
$urlGenerator->linkToRouteAbsolute('deck.page.index') . '#/board/' . $board->getId(), $urlGenerator->linkToRouteAbsolute('deck.page.index') . '#/board/' . $board->getId(),

View File

@@ -49,7 +49,7 @@ class CardCommentProvider implements IProvider {
} }
public function getId(): string { public function getId(): string {
return 'deck-comment'; return 'search-deck-comment';
} }
public function getName(): string { public function getName(): string {
@@ -65,7 +65,7 @@ class CardCommentProvider implements IProvider {
$results $results
); );
} }
return SearchResult::paginated( return SearchResult::paginated(
$this->l10n->t('Card comments'), $this->l10n->t('Card comments'),
$results, $results,

View File

@@ -26,6 +26,7 @@ declare(strict_types=1);
namespace OCA\Deck\Search; namespace OCA\Deck\Search;
use OCA\Deck\AppInfo\Application;
use OCA\Deck\Db\Board; use OCA\Deck\Db\Board;
use OCA\Deck\Db\Card; use OCA\Deck\Db\Card;
use OCA\Deck\Db\Stack; use OCA\Deck\Db\Stack;
@@ -33,6 +34,14 @@ use OCP\Search\SearchResultEntry;
class CardSearchResultEntry extends SearchResultEntry { class CardSearchResultEntry extends SearchResultEntry {
public function __construct(Board $board, Stack $stack, Card $card, $urlGenerator) { public function __construct(Board $board, Stack $stack, Card $card, $urlGenerator) {
parent::__construct('', $card->getTitle(), $board->getTitle() . ' » ' . $stack->getTitle(), $urlGenerator->linkToRouteAbsolute('deck.page.index') . '#/board/' . $board->getId() . '/card/' . $card->getId(), 'icon-deck'); parent::__construct(
$urlGenerator->getAbsoluteURL(
$urlGenerator->imagePath(Application::APP_ID, 'card.svg')
),
$card->getTitle(),
$board->getTitle() . ' » ' . $stack->getTitle(),
$urlGenerator->linkToRouteAbsolute('deck.page.index') . '#/board/' . $board->getId() . '/card/' . $card->getId(),
'icon-deck'
);
} }
} }

View File

@@ -26,6 +26,7 @@ declare(strict_types=1);
namespace OCA\Deck\Search; namespace OCA\Deck\Search;
use OCA\Deck\AppInfo\Application;
use OCA\Deck\Db\Card; use OCA\Deck\Db\Card;
use OCP\IL10N; use OCP\IL10N;
use OCP\IURLGenerator; use OCP\IURLGenerator;
@@ -36,7 +37,9 @@ class CommentSearchResultEntry extends SearchResultEntry {
public function __construct(string $commentId, string $commentMessage, string $commentAuthor, Card $card, IURLGenerator $urlGenerator, IL10N $l10n) { public function __construct(string $commentId, string $commentMessage, string $commentAuthor, Card $card, IURLGenerator $urlGenerator, IL10N $l10n) {
parent::__construct( parent::__construct(
'', $urlGenerator->getAbsoluteURL(
$urlGenerator->imagePath('core', 'actions/comment.svg')
),
// TRANSLATORS This is describing the author and card title related to a comment e.g. "Jane on MyTask" // TRANSLATORS This is describing the author and card title related to a comment e.g. "Jane on MyTask"
$l10n->t('%s on %s', [$commentAuthor, $card->getTitle()]), $l10n->t('%s on %s', [$commentAuthor, $card->getTitle()]),
$commentMessage, $commentMessage,

View File

@@ -29,6 +29,7 @@ namespace OCA\Deck\Search;
use OCA\Deck\Db\Board; use OCA\Deck\Db\Board;
use OCA\Deck\Db\Card; use OCA\Deck\Db\Card;
use OCA\Deck\Service\SearchService; use OCA\Deck\Service\SearchService;
use OCP\IL10N;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\IUser; use OCP\IUser;
use OCP\Search\IProvider; use OCP\Search\IProvider;
@@ -36,30 +37,26 @@ use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult; use OCP\Search\SearchResult;
class DeckProvider implements IProvider { class DeckProvider implements IProvider {
private IL10N $l10n;
/** private SearchService $searchService;
* @var SearchService private IURLGenerator $urlGenerator;
*/
private $searchService;
/**
* @var IURLGenerator
*/
private $urlGenerator;
public function __construct( public function __construct(
SearchService $searchService, SearchService $searchService,
IURLGenerator $urlGenerator IURLGenerator $urlGenerator,
IL10N $l10n
) { ) {
$this->l10n = $l10n;
$this->searchService = $searchService; $this->searchService = $searchService;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
} }
public function getId(): string { public function getId(): string {
return 'deck'; return 'search-deck-card-board';
} }
public function getName(): string { public function getName(): string {
return 'Deck'; return $this->l10n->t('Deck boards and cards');
} }
public function search(IUser $user, ISearchQuery $query): SearchResult { public function search(IUser $user, ISearchQuery $query): SearchResult {
@@ -99,14 +96,14 @@ class DeckProvider implements IProvider {
// if both cards and boards results are less then the limit, we know we won't get more // if both cards and boards results are less then the limit, we know we won't get more
if (count($resultEntries) < $query->getLimit()) { if (count($resultEntries) < $query->getLimit()) {
return SearchResult::complete( return SearchResult::complete(
'Deck', $this->getName(),
$resultEntries $resultEntries
); );
} }
$newCursor = $this->getNewCursor($boardObjects, $cardObjects); $newCursor = $this->getNewCursor($boardObjects, $cardObjects);
return SearchResult::paginated( return SearchResult::paginated(
'Deck', $this->getName(),
$resultEntries, $resultEntries,
$newCursor $newCursor
); );