Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd8fd6a66b | ||
|
|
0eba8d0840 | ||
|
|
8fc95dc40d | ||
|
|
ecd3e25588 | ||
|
|
914f912612 | ||
|
|
e68f723095 | ||
|
|
5f71be2e7f | ||
|
|
bc2a72f035 | ||
|
|
cf4be82827 | ||
|
|
23580705aa | ||
|
|
65c8c394a8 | ||
|
|
422788a6a3 | ||
|
|
2d5e29de5d | ||
|
|
2a307b92a7 | ||
|
|
2d8dbc70ad | ||
|
|
cfee259b38 | ||
|
|
f94cdb3ebb | ||
|
|
1ed50fdca6 | ||
|
|
56e460004f | ||
|
|
a95f78d188 | ||
|
|
df09a9a7b2 | ||
|
|
990ee2aef9 | ||
|
|
486ecd12db | ||
|
|
c9cdd7bb11 | ||
|
|
2c753fd084 | ||
|
|
79d2d2f3f5 | ||
|
|
24d9b55bfc | ||
|
|
28cd9fcf77 | ||
|
|
d8a36f0602 | ||
|
|
de06033dcd |
55
.github/workflows/app-code-check.yml
vendored
55
.github/workflows/app-code-check.yml
vendored
@@ -1,55 +0,0 @@
|
||||
name: Nextcloud app code check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
|
||||
env:
|
||||
APP_NAME: deck
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['7.4']
|
||||
server-versions: ['master', 'stable18', 'stable19', 'stable20']
|
||||
|
||||
name: AppCode check php${{ matrix.php-versions }}-${{ matrix.server-versions }}
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: nextcloud/server
|
||||
ref: ${{ matrix.server-versions }}
|
||||
|
||||
- name: Checkout submodules
|
||||
shell: bash
|
||||
run: |
|
||||
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
||||
git submodule sync --recursive
|
||||
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
||||
|
||||
- name: Checkout app
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: apps/${{ env.APP_NAME }}
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v1
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit
|
||||
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite
|
||||
|
||||
- name: Checkout app
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: apps/${{ env.APP_NAME }}
|
||||
|
||||
- name: App code check
|
||||
run: php occ app:check-code ${{ env.APP_NAME }}
|
||||
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,6 +1,26 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 1.4.2 - 2021-05-03
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#3030](https://github.com/nextcloud/deck/pull/3030) Proper error handling when fetching comments fails
|
||||
* [#3031](https://github.com/nextcloud/deck/pull/3031) Allow searching for filters without a query to match all that have a given filter set
|
||||
* [#3039](https://github.com/nextcloud/deck/pull/3039) Catch any error during circle detail fetching
|
||||
* [#3040](https://github.com/nextcloud/deck/pull/3040) Get attachment from the user node instead of the share source
|
||||
|
||||
## 1.4.1 - 2021-04-20
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#2984](https://github.com/nextcloud/deck/pull/2984) Fix codemirror description width
|
||||
* [#2990](https://github.com/nextcloud/deck/pull/2990) Fix unified comments search with postgres
|
||||
* [#2994](https://github.com/nextcloud/deck/pull/2994) Remove notification on unshare and add type hints
|
||||
* [#3006](https://github.com/nextcloud/deck/pull/3006) Only import debounce
|
||||
* [#3008](https://github.com/nextcloud/deck/pull/3008) Do not query the lookupserver when looking for sharees
|
||||
|
||||
|
||||
## 1.4.0 - 2021-04-13
|
||||
|
||||
### Added
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
- 🚀 Get your project organized
|
||||
|
||||
</description>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
<licence>agpl</licence>
|
||||
<author>Julius Härtl</author>
|
||||
<namespace>Deck</namespace>
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
.icon-activity {
|
||||
@include icon-color('activity-dark', 'activity', $color-black);
|
||||
}
|
||||
|
||||
.icon-comment--unread {
|
||||
@include icon-color('comment', 'actions', $color-primary, 1, true);
|
||||
}
|
||||
|
||||
.avatardiv.circles {
|
||||
background: var(--color-primary);
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\ILogger;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IGroupManager;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
private $labelMapper;
|
||||
@@ -35,6 +35,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
private $stackMapper;
|
||||
private $userManager;
|
||||
private $groupManager;
|
||||
private $logger;
|
||||
|
||||
private $circlesEnabled;
|
||||
|
||||
@@ -44,7 +45,8 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
AclMapper $aclMapper,
|
||||
StackMapper $stackMapper,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager
|
||||
IGroupManager $groupManager,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
parent::__construct($db, 'deck_boards', Board::class);
|
||||
$this->labelMapper = $labelMapper;
|
||||
@@ -52,6 +54,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
$this->stackMapper = $stackMapper;
|
||||
$this->userManager = $userManager;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->logger = $logger;
|
||||
|
||||
$this->circlesEnabled = \OC::$server->getAppManager()->isEnabledForUser('circles');
|
||||
}
|
||||
@@ -248,7 +251,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
if ($user !== null) {
|
||||
return new User($user);
|
||||
}
|
||||
\OC::$server->getLogger()->debug('User ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
|
||||
$this->logger->debug('User ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
|
||||
return null;
|
||||
}
|
||||
if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
|
||||
@@ -256,7 +259,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
if ($group !== null) {
|
||||
return new Group($group);
|
||||
}
|
||||
\OC::$server->getLogger()->debug('Group ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
|
||||
$this->logger->debug('Group ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
|
||||
return null;
|
||||
}
|
||||
if ($acl->getType() === Acl::PERMISSION_TYPE_CIRCLE) {
|
||||
@@ -268,11 +271,12 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
if ($circle) {
|
||||
return new Circle($circle);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to get circle details when building ACL', ['exception' => $e]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
\OC::$server->getLogger()->log(ILogger::WARN, 'Unknown permission type for mapping acl ' . $acl->getId());
|
||||
$this->logger->warning('Unknown permission type for mapping acl ' . $acl->getId());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ class Card extends RelationalEntity {
|
||||
protected $notified = false;
|
||||
protected $deletedAt = 0;
|
||||
protected $commentsUnread = 0;
|
||||
protected $commentsCount = 0;
|
||||
|
||||
protected $relatedStack = null;
|
||||
protected $relatedBoard = null;
|
||||
@@ -75,6 +76,7 @@ class Card extends RelationalEntity {
|
||||
$this->addRelation('attachmentCount');
|
||||
$this->addRelation('participants');
|
||||
$this->addRelation('commentsUnread');
|
||||
$this->addRelation('commentsCount');
|
||||
$this->addResolvable('owner');
|
||||
|
||||
$this->addRelation('relatedStack');
|
||||
|
||||
@@ -321,7 +321,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
||||
$this->extendQueryByFilter($qb, $query);
|
||||
|
||||
$qb->innerJoin('c', 'comments', 'comments', $qb->expr()->andX(
|
||||
$qb->expr()->eq('comments.object_id', 'c.id', IQueryBuilder::PARAM_STR),
|
||||
$qb->expr()->eq('comments.object_id', $qb->expr()->castColumn('c.id', IQueryBuilder::PARAM_STR)),
|
||||
$qb->expr()->eq('comments.object_type', $qb->createNamedParameter(Application::COMMENT_ENTITY_TYPE, IQueryBuilder::PARAM_STR))
|
||||
));
|
||||
$qb->selectAlias('comments.id', 'comment_id');
|
||||
@@ -339,7 +339,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
||||
$tokenMatching
|
||||
);
|
||||
|
||||
$qb->groupBy('comments.id');
|
||||
$qb->groupBy('comments.id', 'c.id');
|
||||
$qb->orderBy('comments.id', 'DESC');
|
||||
if ($limit !== null) {
|
||||
$qb->setMaxResults($limit);
|
||||
@@ -383,6 +383,10 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
||||
foreach ($query->getDuedate() as $duedate) {
|
||||
$dueDateColumn = $this->databaseType === 'sqlite3' ? $qb->createFunction('DATETIME(`c`.`duedate`)') : 'c.duedate';
|
||||
$date = $duedate->getValue();
|
||||
if ($date === "") {
|
||||
$qb->andWhere($qb->expr()->isNotNull('c.duedate'));
|
||||
continue;
|
||||
}
|
||||
$supportedFilters = ['overdue', 'today', 'week', 'month', 'none'];
|
||||
if (in_array($date, $supportedFilters, true)) {
|
||||
$currentDate = new DateTime();
|
||||
@@ -430,6 +434,10 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
||||
foreach ($query->getAssigned() as $index => $assignment) {
|
||||
$qb->innerJoin('c', 'deck_assigned_users', 'au' . $index, $qb->expr()->eq('c.id', 'au' . $index . '.card_id'));
|
||||
$assignedQueryValue = $assignment->getValue();
|
||||
if ($assignedQueryValue === "") {
|
||||
$qb->andWhere($qb->expr()->isNotNull('au' . $index . '.participant'));
|
||||
continue;
|
||||
}
|
||||
$searchUsers = $this->userManager->searchDisplayName($assignment->getValue());
|
||||
$users = array_filter($searchUsers, function (IUser $user) use ($assignedQueryValue) {
|
||||
return (mb_strtolower($user->getDisplayName()) === mb_strtolower($assignedQueryValue) || $user->getUID() === $assignedQueryValue);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
@@ -24,19 +27,24 @@
|
||||
namespace OCA\Deck\Notification;
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use OCA\Deck\AppInfo\Application;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\AssignmentMapper;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\User;
|
||||
use OCA\Deck\Service\ConfigService;
|
||||
use OCA\Deck\Service\PermissionService;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\Comments\IComment;
|
||||
use OCP\IConfig;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\Notification\IManager;
|
||||
use OCP\Notification\INotification;
|
||||
|
||||
class NotificationHelper {
|
||||
|
||||
@@ -80,10 +88,10 @@ class NotificationHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $card
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws DoesNotExistException
|
||||
* @throws Exception thrown on invalid due date
|
||||
*/
|
||||
public function sendCardDuedate($card) {
|
||||
public function sendCardDuedate(Card $card): void {
|
||||
// check if notification has already been sent
|
||||
// ideally notifications should not be deleted once seen by the user so we can
|
||||
// also deliver due date notifications for users who have been added later to a board
|
||||
@@ -117,7 +125,7 @@ class NotificationHelper {
|
||||
$notification
|
||||
->setApp('deck')
|
||||
->setUser((string)$user->getUID())
|
||||
->setObject('card', $card->getId())
|
||||
->setObject('card', (string)$card->getId())
|
||||
->setSubject('card-overdue', [
|
||||
$card->getTitle(), $board->getTitle()
|
||||
])
|
||||
@@ -128,25 +136,29 @@ class NotificationHelper {
|
||||
$this->cardMapper->markNotified($card);
|
||||
}
|
||||
|
||||
public function markDuedateAsRead($card) {
|
||||
public function markDuedateAsRead(Card $card): void {
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
$notification
|
||||
->setApp('deck')
|
||||
->setObject('card', $card->getId())
|
||||
->setObject('card', (string)$card->getId())
|
||||
->setSubject('card-overdue', []);
|
||||
$this->notificationManager->markProcessed($notification);
|
||||
}
|
||||
|
||||
public function sendCardAssigned($card, $userId) {
|
||||
public function sendCardAssigned(Card $card, string $userId): void {
|
||||
$boardId = $this->cardMapper->findBoardId($card->getId());
|
||||
$board = $this->getBoard($boardId);
|
||||
try {
|
||||
$board = $this->getBoard($boardId);
|
||||
} catch (Exception $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
$notification
|
||||
->setApp('deck')
|
||||
->setUser((string) $userId)
|
||||
->setUser($userId)
|
||||
->setDateTime(new DateTime())
|
||||
->setObject('card', $card->getId())
|
||||
->setObject('card', (string)$card->getId())
|
||||
->setSubject('card-assigned', [
|
||||
$card->getTitle(),
|
||||
$board->getTitle(),
|
||||
@@ -155,29 +167,56 @@ class NotificationHelper {
|
||||
$this->notificationManager->notify($notification);
|
||||
}
|
||||
|
||||
public function markCardAssignedAsRead(Card $card, string $userId): void {
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
$notification
|
||||
->setApp('deck')
|
||||
->setUser($userId)
|
||||
->setObject('card', (string)$card->getId())
|
||||
->setSubject('card-assigned', []);
|
||||
$this->notificationManager->markProcessed($notification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notifications that a board was shared with a user/group
|
||||
*
|
||||
* @param $boardId
|
||||
* @param Acl $acl
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function sendBoardShared($boardId, $acl) {
|
||||
$board = $this->getBoard($boardId);
|
||||
public function sendBoardShared(int $boardId, Acl $acl, bool $markAsRead = false): void {
|
||||
try {
|
||||
$board = $this->getBoard($boardId);
|
||||
} catch (Exception $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
|
||||
$notification = $this->generateBoardShared($board, $acl->getParticipant());
|
||||
$this->notificationManager->notify($notification);
|
||||
if ($markAsRead) {
|
||||
$this->notificationManager->markProcessed($notification);
|
||||
} else {
|
||||
$notification->setDateTime(new DateTime());
|
||||
$this->notificationManager->notify($notification);
|
||||
}
|
||||
}
|
||||
if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
|
||||
$group = $this->groupManager->get($acl->getParticipant());
|
||||
if ($group === null) {
|
||||
return;
|
||||
}
|
||||
foreach ($group->getUsers() as $user) {
|
||||
if ($user->getUID() === $this->currentUser) {
|
||||
continue;
|
||||
}
|
||||
$notification = $this->generateBoardShared($board, $user->getUID());
|
||||
$this->notificationManager->notify($notification);
|
||||
if ($markAsRead) {
|
||||
$this->notificationManager->markProcessed($notification);
|
||||
} else {
|
||||
$notification->setDateTime(new DateTime());
|
||||
$this->notificationManager->notify($notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function sendMention(IComment $comment) {
|
||||
public function sendMention(IComment $comment): void {
|
||||
foreach ($comment->getMentions() as $mention) {
|
||||
$card = $this->cardMapper->find($comment->getObjectId());
|
||||
$boardId = $this->cardMapper->findBoardId($card->getId());
|
||||
@@ -194,27 +233,22 @@ class NotificationHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $boardId
|
||||
* @return Board
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
private function getBoard($boardId, bool $withLabels = false, bool $withAcl = false) {
|
||||
private function getBoard(int $boardId, bool $withLabels = false, bool $withAcl = false): Board {
|
||||
if (!array_key_exists($boardId, $this->boards)) {
|
||||
$this->boards[$boardId] = $this->boardMapper->find($boardId, $withLabels, $withAcl);
|
||||
}
|
||||
return $this->boards[$boardId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Board $board
|
||||
*/
|
||||
private function generateBoardShared($board, $userId) {
|
||||
|
||||
private function generateBoardShared(Board $board, string $userId): INotification {
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
$notification
|
||||
->setApp('deck')
|
||||
->setUser((string) $userId)
|
||||
->setDateTime(new DateTime())
|
||||
->setObject('board', $board->getId())
|
||||
->setUser($userId)
|
||||
->setObject('board', (string)$board->getId())
|
||||
->setSubject('board-shared', [$board->getTitle(), $this->currentUser]);
|
||||
return $notification;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class AQueryParameter {
|
||||
|
||||
public function getValue() {
|
||||
if (is_string($this->value) && mb_strlen($this->value) > 1) {
|
||||
$param = ($this->value[0] === '"' && $this->value[mb_strlen($this->value) - 1] === '"') ? mb_substr($this->value, 1, -1): $this->value;
|
||||
$param = (mb_substr($this->value, 0, 1) === '"' && mb_substr($this->value, -1, 1) === '"') ? mb_substr($this->value, 1, -1): $this->value;
|
||||
return $param;
|
||||
}
|
||||
return $this->value;
|
||||
|
||||
@@ -74,6 +74,8 @@ class AssignmentService {
|
||||
* @var IEventDispatcher
|
||||
*/
|
||||
private $eventDispatcher;
|
||||
/** @var string|null */
|
||||
private $currentUser;
|
||||
|
||||
public function __construct(
|
||||
PermissionService $permissionService,
|
||||
@@ -138,8 +140,7 @@ class AssignmentService {
|
||||
}
|
||||
|
||||
|
||||
if ($userId !== $this->currentUser) {
|
||||
/* Notifyuser about the card assignment */
|
||||
if ($type === Assignment::TYPE_USER && $userId !== $this->currentUser) {
|
||||
$this->notificationHelper->sendCardAssigned($card, $userId);
|
||||
}
|
||||
|
||||
@@ -183,8 +184,12 @@ class AssignmentService {
|
||||
$assignment = $this->assignedUsersMapper->delete($assignment);
|
||||
$card = $this->cardMapper->find($cardId);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_USER_UNASSIGN, ['assigneduser' => $userId]);
|
||||
if ($type === Assignment::TYPE_USER && $userId !== $this->currentUser) {
|
||||
$this->notificationHelper->markCardAssignedAsRead($card, $userId);
|
||||
}
|
||||
$this->changeHelper->cardChanged($cardId);
|
||||
|
||||
|
||||
$this->eventDispatcher->dispatchTyped(new CardUpdatedEvent($card));
|
||||
|
||||
return $assignment;
|
||||
|
||||
@@ -510,11 +510,10 @@ class BoardService {
|
||||
$acl->setPermissionEdit($edit);
|
||||
$acl->setPermissionShare($share);
|
||||
$acl->setPermissionManage($manage);
|
||||
|
||||
$this->notificationHelper->sendBoardShared($boardId, $acl);
|
||||
|
||||
$newAcl = $this->aclMapper->insert($acl);
|
||||
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $newAcl, ActivityManager::SUBJECT_BOARD_SHARE);
|
||||
$this->notificationHelper->sendBoardShared((int)$boardId, $acl);
|
||||
$this->boardMapper->mapAcl($newAcl);
|
||||
$this->changeHelper->boardChanged($boardId);
|
||||
|
||||
@@ -599,9 +598,8 @@ class BoardService {
|
||||
}
|
||||
}
|
||||
|
||||
$this->notificationHelper->sendBoardShared($acl->getBoardId(), $acl);
|
||||
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $acl, ActivityManager::SUBJECT_BOARD_UNSHARE);
|
||||
$this->notificationHelper->sendBoardShared($acl->getBoardId(), $acl, true);
|
||||
$this->changeHelper->boardChanged($acl->getBoardId());
|
||||
|
||||
$version = \OCP\Util::getVersion()[0];
|
||||
|
||||
@@ -105,8 +105,10 @@ class CardService {
|
||||
$card->setAttachmentCount($this->attachmentService->count($cardId));
|
||||
$user = $this->userManager->get($this->currentUser);
|
||||
$lastRead = $this->commentsManager->getReadMark('deckCard', (string)$card->getId(), $user);
|
||||
$count = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId(), $lastRead);
|
||||
$card->setCommentsUnread($count);
|
||||
$countUnreadComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId(), $lastRead);
|
||||
$countComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId());
|
||||
$card->setCommentsUnread($countUnreadComments);
|
||||
$card->setCommentsCount($countComments);
|
||||
|
||||
$stack = $this->stackMapper->find($card->getStackId());
|
||||
$board = $this->boardService->find($stack->getBoardId());
|
||||
@@ -243,6 +245,7 @@ class CardService {
|
||||
$this->cardMapper->update($card);
|
||||
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_DELETE);
|
||||
$this->notificationHelper->markDuedateAsRead($card);
|
||||
$this->changeHelper->cardChanged($card->getId(), false);
|
||||
$this->eventDispatcher->dispatchTyped(new CardDeletedEvent($card));
|
||||
|
||||
@@ -322,6 +325,15 @@ class CardService {
|
||||
$card->setOrder($order);
|
||||
$card->setOwner($owner);
|
||||
$card->setDuedate($duedate);
|
||||
$resetDuedateNotification = false;
|
||||
if (
|
||||
$card->getDuedate() === null ||
|
||||
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate()))
|
||||
) {
|
||||
$card->setNotified(false);
|
||||
$resetDuedateNotification = true;
|
||||
}
|
||||
|
||||
if ($deletedAt !== null) {
|
||||
$card->setDeletedAt($deletedAt);
|
||||
}
|
||||
@@ -341,6 +353,9 @@ class CardService {
|
||||
|
||||
|
||||
$card = $this->cardMapper->update($card);
|
||||
if ($resetDuedateNotification) {
|
||||
$this->notificationHelper->markDuedateAsRead($card);
|
||||
}
|
||||
$this->changeHelper->cardChanged($card->getId(), true);
|
||||
|
||||
$this->eventDispatcher->dispatchTyped(new CardUpdatedEvent($card));
|
||||
|
||||
@@ -125,7 +125,11 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService {
|
||||
public function extendData(Attachment $attachment) {
|
||||
$userFolder = $this->rootFolder->getUserFolder($this->userId);
|
||||
$share = $this->shareProvider->getShareById($attachment->getId());
|
||||
$file = $share->getNode();
|
||||
$files = $userFolder->getById($share->getNode()->getId());
|
||||
if (count($files) === 0) {
|
||||
return $attachment;
|
||||
}
|
||||
$file = array_shift($files);
|
||||
$attachment->setExtendedData([
|
||||
'path' => $userFolder->getRelativePath($file->getPath()),
|
||||
'fileid' => $file->getId(),
|
||||
|
||||
@@ -73,7 +73,7 @@ import { CollectionList } from 'nextcloud-vue-collections'
|
||||
import { mapGetters, mapState } from 'vuex'
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
import { debounce } from 'lodash'
|
||||
import debounce from 'lodash/debounce'
|
||||
|
||||
export default {
|
||||
name: 'SharingTabSidebar',
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<CommentItem v-if="replyTo" :comment="replyTo" :reply="true" />
|
||||
<CommentItem v-if="replyTo"
|
||||
:comment="replyTo"
|
||||
:reply="true"
|
||||
:preview="true"
|
||||
@cancel="cancelReply" />
|
||||
<CommentForm v-model="newComment" @submit="createComment" />
|
||||
|
||||
<ul v-if="getCommentsForCard(card.id).length > 0" id="commentsFeed">
|
||||
@@ -23,8 +27,8 @@
|
||||
</ul>
|
||||
<div v-else-if="isLoading" class="icon icon-loading" />
|
||||
<div v-else class="emptycontent">
|
||||
<div class="icon-comment" />
|
||||
<p>{{ t('deck', 'No comments yet. Begin the discussion!') }}</p>
|
||||
<div :class="{ 'icon-comment': !error, 'icon-error': error }" />
|
||||
<p>{{ error || t('deck', 'No comments yet. Begin the discussion!') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -36,6 +40,7 @@ import CommentItem from './CommentItem'
|
||||
import CommentForm from './CommentForm'
|
||||
import InfiniteLoading from 'vue-infinite-loading'
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
|
||||
export default {
|
||||
name: 'CardSidebarTabComments',
|
||||
components: {
|
||||
@@ -60,6 +65,7 @@ export default {
|
||||
newComment: '',
|
||||
isLoading: false,
|
||||
currentUser: getCurrentUser(),
|
||||
error: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -85,19 +91,34 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async infiniteHandler($state) {
|
||||
await this.loadMore()
|
||||
if (this.hasMoreComments(this.card.id)) {
|
||||
$state.loaded()
|
||||
} else {
|
||||
this.error = null
|
||||
try {
|
||||
await this.loadMore()
|
||||
if (this.hasMoreComments(this.card.id)) {
|
||||
$state.loaded()
|
||||
} else {
|
||||
$state.complete()
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch more comments during infinite loading', e)
|
||||
this.error = t('deck', 'Failed to load comments')
|
||||
$state.complete()
|
||||
}
|
||||
},
|
||||
async loadComments() {
|
||||
this.$store.dispatch('setReplyTo', null)
|
||||
this.error = null
|
||||
this.isLoading = true
|
||||
await this.$store.dispatch('fetchComments', { cardId: this.card.id })
|
||||
this.isLoading = false
|
||||
if (this.card.commentsUnread > 0) {
|
||||
await this.$store.dispatch('markCommentsAsRead', this.card.id)
|
||||
try {
|
||||
await this.$store.dispatch('fetchComments', { cardId: this.card.id })
|
||||
this.isLoading = false
|
||||
if (this.card.commentsUnread > 0) {
|
||||
await this.$store.dispatch('markCommentsAsRead', this.card.id)
|
||||
}
|
||||
} catch (e) {
|
||||
this.isLoading = false
|
||||
console.error('Failed to fetch more comments during infinite loading', e)
|
||||
this.error = t('deck', 'Failed to load comments')
|
||||
}
|
||||
},
|
||||
async createComment(content) {
|
||||
@@ -115,6 +136,9 @@ export default {
|
||||
await this.$store.dispatch('fetchMore', { cardId: this.card.id })
|
||||
this.isLoading = false
|
||||
},
|
||||
cancelReply() {
|
||||
this.$store.dispatch('setReplyTo', null)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
</span>
|
||||
</template>
|
||||
<div ref="contentEditable"
|
||||
class="comment-form__contenteditable"
|
||||
contenteditable
|
||||
@keydown.enter="handleKeydown"
|
||||
@paste="onPaste"
|
||||
@@ -175,6 +176,11 @@ export default {
|
||||
<style scoped lang="scss">
|
||||
@import '../../css/comments';
|
||||
|
||||
.comment-form__contenteditable {
|
||||
word-break: break-word;
|
||||
border-radius: var(--border-radius-large)
|
||||
}
|
||||
|
||||
.atwho-wrap {
|
||||
width: 100%;
|
||||
& > div[contenteditable] {
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
<template>
|
||||
<div v-if="reply" class="reply">
|
||||
<span class="reply--hint">{{ t('deck', 'In reply to') }} <UserBubble :user="comment.actorId" :display-name="comment.actorDisplayName" /></span>
|
||||
<RichText class="comment--content"
|
||||
:text="richText(comment)"
|
||||
:arguments="richArgs(comment)"
|
||||
:autolink="true" />
|
||||
<div v-if="reply" class="reply" :class="{ 'reply--preview': preview }">
|
||||
<div class="reply--wrapper">
|
||||
<div class="reply--header">
|
||||
<div class="reply--hint">
|
||||
{{ t('deck', 'In reply to') }}
|
||||
<UserBubble :user="comment.actorId" :display-name="comment.actorDisplayName" />
|
||||
</div>
|
||||
<Actions v-if="preview" class="reply--cancel">
|
||||
<ActionButton icon="icon-close" @click="$emit('cancel')">
|
||||
{{ t('deck', 'Cancel reply') }}
|
||||
</ActionButton>
|
||||
</Actions>
|
||||
</div>
|
||||
<RichText class="comment--content"
|
||||
:text="richText(comment)"
|
||||
:arguments="richArgs(comment)"
|
||||
:autolink="true" />
|
||||
</div>
|
||||
</div>
|
||||
<li v-else class="comment">
|
||||
<template>
|
||||
@@ -14,13 +26,19 @@
|
||||
{{ comment.actorDisplayName }}
|
||||
</span>
|
||||
<Actions v-show="!edit" :force-menu="true">
|
||||
<ActionButton icon="icon-reply" @click="replyTo()">
|
||||
<ActionButton icon="icon-reply" :close-after-click="true" @click="replyTo()">
|
||||
{{ t('deck', 'Reply') }}
|
||||
</ActionButton>
|
||||
<ActionButton v-if="canEdit" icon="icon-rename" @click="showUpdateForm()">
|
||||
<ActionButton v-if="canEdit"
|
||||
icon="icon-rename"
|
||||
:close-after-click="true"
|
||||
@click="showUpdateForm()">
|
||||
{{ t('deck', 'Update') }}
|
||||
</ActionButton>
|
||||
<ActionButton v-if="canEdit" icon="icon-delete" @click="deleteComment()">
|
||||
<ActionButton v-if="canEdit"
|
||||
icon="icon-delete"
|
||||
:close-after-click="true"
|
||||
@click="deleteComment()">
|
||||
{{ t('deck', 'Delete') }}
|
||||
</ActionButton>
|
||||
</Actions>
|
||||
@@ -86,6 +104,10 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
preview: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -175,20 +197,41 @@ export default {
|
||||
@import '../../css/comments';
|
||||
|
||||
.reply {
|
||||
border-left: 3px solid var(--color-primary-element);
|
||||
padding-left: 5px;
|
||||
margin-left: 2px;
|
||||
margin-bottom: 5px;
|
||||
margin: 0 0 0 44px;
|
||||
|
||||
&.reply--preview {
|
||||
margin: 4px 0;
|
||||
padding: 8px;
|
||||
background-color: var(--color-background-hover);
|
||||
border-radius: var(--border-radius-large);
|
||||
|
||||
.reply--wrapper {
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.reply--cancel {
|
||||
margin-right: -12px;
|
||||
margin-top: -12px;
|
||||
}
|
||||
}
|
||||
|
||||
.reply--wrapper {
|
||||
border-left: 4px solid var(--color-border-dark);
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
&::v-deep .rich-text--wrapper {
|
||||
margin-top: -3px;
|
||||
color: var(--color-text-light);
|
||||
color: var(--color-text-lighter);
|
||||
}
|
||||
|
||||
.reply--header {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.reply--hint {
|
||||
font-size: 0.9em;
|
||||
color: var(--color-text-lighter);
|
||||
vertical-align: top;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.comment--content {
|
||||
|
||||
@@ -306,6 +306,7 @@ h5 {
|
||||
padding: 0;
|
||||
background-color: var(--color-main-background);
|
||||
color: var(--color-main-text);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.CodeMirror-placeholder {
|
||||
|
||||
@@ -22,7 +22,13 @@
|
||||
|
||||
<template>
|
||||
<div v-if="card" class="badges">
|
||||
<div v-if="card.commentsUnread > 0" class="icon icon-comment" />
|
||||
<div v-if="card.commentsCount > 0"
|
||||
v-tooltip="commentsHint"
|
||||
class="icon icon-comment"
|
||||
:class="{ 'icon-comment--unread': card.commentsUnread > 0 }"
|
||||
@click.stop="openComments">
|
||||
{{ card.commentsCount }}
|
||||
</div>
|
||||
|
||||
<div v-if="card.description && checkListCount > 0" class="card-tasks icon icon-checkmark">
|
||||
{{ checkListCheckedCount }}/{{ checkListCount }}
|
||||
@@ -58,6 +64,21 @@ export default {
|
||||
checkListCheckedCount() {
|
||||
return (this.card.description.match(/^\s*([*+-]|(\d\.))\s+\[\s*x\s*\](.*)$/gim) || []).length
|
||||
},
|
||||
commentsHint() {
|
||||
if (this.card.commentsUnread > 0) {
|
||||
return t('deck', '{count} comments, {unread} unread', {
|
||||
count: this.card.commentsCount,
|
||||
unread: this.card.commentsUnread
|
||||
})
|
||||
}
|
||||
return null
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openComments() {
|
||||
const boardId = this.card && this.card.boardId ? this.card.boardId : this.$route.params.id
|
||||
this.$router.push({ name: 'card', params: { id: boardId, cardId: this.card.id, tabId: 'comments' } })
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -70,7 +91,7 @@ export default {
|
||||
|
||||
.icon {
|
||||
opacity: 0.5;
|
||||
padding: 12px 18px;
|
||||
padding: 10px 20px;
|
||||
padding-right: 4px;
|
||||
margin-right: 5px;
|
||||
background-position: left;
|
||||
@@ -78,8 +99,8 @@ export default {
|
||||
span {
|
||||
margin-left: 18px;
|
||||
}
|
||||
&.icon-edit {
|
||||
opacity: 0.5;
|
||||
&.icon-comment--unread {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
|
||||
<template>
|
||||
<div v-if="searchQuery!==''" class="global-search">
|
||||
<h2><RichText :text="t('deck', 'Search for {searchQuery} in all boards')" :arguments="queryStringArgs" /></h2>
|
||||
<h2>
|
||||
<RichText :text="t('deck', 'Search for {searchQuery} in all boards')" :arguments="queryStringArgs" />
|
||||
<div v-if="loading" class="icon-loading-small" />
|
||||
</h2>
|
||||
<Actions>
|
||||
<ActionButton icon="icon-close" @click="$store.commit('setSearchQuery', '')" />
|
||||
</Actions>
|
||||
@@ -107,23 +110,38 @@ export default {
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
searchQuery() {
|
||||
async searchQuery() {
|
||||
this.cursor = null
|
||||
this.loading = true
|
||||
this.search()
|
||||
try {
|
||||
await this.search()
|
||||
this.loading = false
|
||||
} catch (e) {
|
||||
if (!axios.isCancel(e)) {
|
||||
console.error('Search request failed', e)
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
infiniteHandler($state) {
|
||||
async infiniteHandler($state) {
|
||||
this.loading = true
|
||||
this.search().then((data) => {
|
||||
try {
|
||||
const data = await this.search()
|
||||
if (data.length) {
|
||||
$state.loaded()
|
||||
} else {
|
||||
$state.complete()
|
||||
}
|
||||
this.loading = false
|
||||
})
|
||||
} catch (e) {
|
||||
if (!axios.isCancel(e)) {
|
||||
console.error('Search request failed', e)
|
||||
$state.complete()
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
},
|
||||
async search() {
|
||||
if (this.cancel) {
|
||||
@@ -177,6 +195,13 @@ export default {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
h2 > div {
|
||||
display: inline-block;
|
||||
|
||||
&.icon-loading-small {
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
h2::v-deep span {
|
||||
background-color: var(--color-background-dark);
|
||||
padding: 3px;
|
||||
|
||||
@@ -48,4 +48,5 @@
|
||||
|
||||
.comment--content {
|
||||
margin-left: 44px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@@ -92,24 +92,39 @@ export default {
|
||||
|
||||
const filterOutQuotes = (q) => {
|
||||
if (q[0] === '"' && q[q.length - 1] === '"') {
|
||||
return q.substr(1, -1)
|
||||
return q.substr(1, q.length - 2)
|
||||
}
|
||||
return q
|
||||
}
|
||||
for (const match of matches) {
|
||||
let [filter, query] = match.indexOf(':') !== -1 ? match.split(/:(.+)/) : [null, match]
|
||||
let [filter, query] = match.indexOf(':') !== -1 ? match.split(/:(.*)/) : [null, match]
|
||||
const isEmptyQuery = typeof query === 'undefined' || filterOutQuotes(query) === ''
|
||||
|
||||
if (filter === 'title') {
|
||||
if (isEmptyQuery) {
|
||||
continue
|
||||
}
|
||||
hasMatch = hasMatch && card.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
||||
} else if (filter === 'description') {
|
||||
if (isEmptyQuery) {
|
||||
hasMatch = hasMatch && !!card.description
|
||||
continue
|
||||
}
|
||||
hasMatch = hasMatch && card.description.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
||||
} else if (filter === 'list') {
|
||||
const stack = this.getters.stackById(card.stackId)
|
||||
if (isEmptyQuery) {
|
||||
continue
|
||||
}
|
||||
const stack = getters.stackById(card.stackId)
|
||||
if (!stack) {
|
||||
return false
|
||||
}
|
||||
hasMatch = hasMatch && stack.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
||||
} else if (filter === 'tag') {
|
||||
if (isEmptyQuery) {
|
||||
hasMatch = hasMatch && card.labels.length > 0
|
||||
continue
|
||||
}
|
||||
hasMatch = hasMatch && card.labels.findIndex((label) => label.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())) !== -1
|
||||
} else if (filter === 'date') {
|
||||
const datediffHour = ((new Date(card.duedate) - new Date()) / 3600 / 1000)
|
||||
@@ -158,6 +173,10 @@ export default {
|
||||
}
|
||||
|
||||
} else if (filter === 'assigned') {
|
||||
if (isEmptyQuery) {
|
||||
hasMatch = hasMatch && card.assignedUsers.length > 0
|
||||
continue
|
||||
}
|
||||
hasMatch = hasMatch && card.assignedUsers.findIndex((assignment) => {
|
||||
return assignment.participant.primaryKey.toLowerCase() === filterOutQuotes(query).toLowerCase()
|
||||
|| assignment.participant.displayname.toLowerCase() === filterOutQuotes(query).toLowerCase()
|
||||
|
||||
@@ -420,6 +420,7 @@ export default new Vuex.Store({
|
||||
params.append('format', 'json')
|
||||
params.append('perPage', 20)
|
||||
params.append('itemType', [0, 1, 4, 7])
|
||||
params.append('lookup', false)
|
||||
|
||||
const response = await axios.get(generateOcsUrl('apps/files_sharing/api/v1') + 'sharees', { params })
|
||||
commit('setSharees', response.data.ocs.data)
|
||||
|
||||
@@ -8,4 +8,5 @@ default:
|
||||
baseUrl: http://localhost:8080/
|
||||
- RequestContext
|
||||
- BoardContext
|
||||
- CommentContext
|
||||
- SearchContext
|
||||
|
||||
@@ -27,6 +27,10 @@ class BoardContext implements Context {
|
||||
$this->serverContext = $environment->getContext('ServerContext');
|
||||
}
|
||||
|
||||
public function getLastUsedCard() {
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^creates a board named "([^"]*)" with color "([^"]*)"$/
|
||||
*/
|
||||
|
||||
31
tests/integration/features/bootstrap/CommentContext.php
Normal file
31
tests/integration/features/bootstrap/CommentContext.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class CommentContext implements Context {
|
||||
use RequestTrait;
|
||||
|
||||
/** @var BoardContext */
|
||||
protected $boardContext;
|
||||
|
||||
/** @BeforeScenario */
|
||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||
$environment = $scope->getEnvironment();
|
||||
|
||||
$this->boardContext = $environment->getContext('BoardContext');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^post a comment with content "([^"]*)" on the card$/
|
||||
*/
|
||||
public function postACommentWithContentOnTheCard($content) {
|
||||
$card = $this->boardContext->getLastUsedCard();
|
||||
$this->requestContext->sendOCSRequest('POST', '/apps/deck/api/v1.0/cards/' . $card['id'] . '/comments', [
|
||||
'message' => $content,
|
||||
'parentId' => null
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class SearchContext implements Context {
|
||||
protected $boardContext;
|
||||
|
||||
private $searchResults;
|
||||
private $unifiedSearchResult;
|
||||
|
||||
/** @BeforeScenario */
|
||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||
@@ -32,6 +33,18 @@ class SearchContext implements Context {
|
||||
$this->searchResults = json_decode($data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^searching for "([^"]*)" in comments in unified search$/
|
||||
* @param string $term
|
||||
* https://cloud.nextcloud.com/ocs/v2.php/search/providers/talk-conversations/search?term=an&from=%2Fapps%2Fdashboard%2F
|
||||
*/
|
||||
public function searchingForComments(string $term) {
|
||||
$this->requestContext->sendOCSRequest('GET', '/search/providers/deck-comment/search?term=' . urlencode($term), []);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$data = (string)$this->getResponse()->getBody();
|
||||
$this->unifiedSearchResult = json_decode($data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^searching for '([^']*)'$/
|
||||
* @param string $term
|
||||
@@ -78,4 +91,33 @@ class SearchContext implements Context {
|
||||
public function theCardIsNotFound($arg1) {
|
||||
Assert::assertFalse($this->cardIsFound($arg1), 'Card can not be found');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the comment with "([^"]*)" is found$/
|
||||
*/
|
||||
public function theCommentWithIsFound($arg1) {
|
||||
$ocsData = $this->unifiedSearchResult['ocs']['data']['entries'];
|
||||
$found = null;
|
||||
foreach ($ocsData as $result) {
|
||||
if ($result['subline'] === $arg1) {
|
||||
$found = $result;
|
||||
}
|
||||
}
|
||||
Assert::assertNotNull($found, 'Comment was expected but was not found');
|
||||
Assert::assertEquals('admin on Card with comment', $found['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the comment with "([^"]*)" is not found$/
|
||||
*/
|
||||
public function theCommentWithIsNotFound($arg1) {
|
||||
$ocsData = $this->unifiedSearchResult['ocs']['data']['entries'];
|
||||
$found = null;
|
||||
foreach ($ocsData as $result) {
|
||||
if ($result['subline'] === $arg1) {
|
||||
$found = $result;
|
||||
}
|
||||
}
|
||||
Assert::assertNull($found, 'Comment was found but not expected');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,3 +257,10 @@ Feature: Searching for cards
|
||||
Then the card "Example task 1" is not found
|
||||
And the card "Labeled card" is not found
|
||||
And the card "Multi labeled card" is found
|
||||
|
||||
Scenario: Search for a card comment
|
||||
Given create a card named "Card with comment"
|
||||
And post a comment with content "My first comment" on the card
|
||||
When searching for "My first comment" in comments in unified search
|
||||
Then the comment with "My first comment" is found
|
||||
Then the comment with "Any other" is not found
|
||||
|
||||
@@ -105,7 +105,8 @@
|
||||
<ParamNameMismatch occurrences="1">
|
||||
<code>$boardId</code>
|
||||
</ParamNameMismatch>
|
||||
<UndefinedClass occurrences="1">
|
||||
<UndefinedClass occurrences="2">
|
||||
<code>\OCA\Circles\Api\v1\Circles</code>
|
||||
<code>\OCA\Circles\Api\v1\Circles</code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
@@ -170,11 +171,6 @@
|
||||
<code>$stackId</code>
|
||||
</ParamNameMismatch>
|
||||
</file>
|
||||
<file src="lib/Notification/NotificationHelper.php">
|
||||
<InvalidScalarArgument occurrences="1">
|
||||
<code>$board->getId()</code>
|
||||
</InvalidScalarArgument>
|
||||
</file>
|
||||
<file src="lib/Notification/Notifier.php">
|
||||
<RedundantCast occurrences="7">
|
||||
<code>(string) $l->t('%s has mentioned you in a comment on "%s".', [$dn, $params[0]])</code>
|
||||
@@ -196,12 +192,6 @@
|
||||
<code>$cardId</code>
|
||||
<code>$cardId</code>
|
||||
</InvalidScalarArgument>
|
||||
<UndefinedThisPropertyAssignment occurrences="1">
|
||||
<code>$this->currentUser</code>
|
||||
</UndefinedThisPropertyAssignment>
|
||||
<UndefinedThisPropertyFetch occurrences="1">
|
||||
<code>$this->currentUser</code>
|
||||
</UndefinedThisPropertyFetch>
|
||||
</file>
|
||||
<file src="lib/Service/BoardService.php">
|
||||
<TooManyArguments occurrences="2">
|
||||
@@ -265,7 +255,6 @@
|
||||
</RedundantCondition>
|
||||
</file>
|
||||
<file src="lib/Service/FilesAppService.php">
|
||||
<InvalidCatch occurrences="1"/>
|
||||
<MissingDependency occurrences="4">
|
||||
<code>$this->rootFolder</code>
|
||||
<code>$this->rootFolder</code>
|
||||
@@ -279,13 +268,6 @@
|
||||
<code>\OCA\Circles\Api\v1\Circles</code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="lib/Service/SearchService.php">
|
||||
<UndefinedThisPropertyFetch occurrences="3">
|
||||
<code>$this->l10n</code>
|
||||
<code>$this->urlGenerator</code>
|
||||
<code>$this->userManager</code>
|
||||
</UndefinedThisPropertyFetch>
|
||||
</file>
|
||||
<file src="lib/Service/StackService.php">
|
||||
<UndefinedClass occurrences="1">
|
||||
<code>BadRquestException</code>
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\AppFramework\Db\MapperTestUtility;
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,8 @@ class AclMapperTest extends MapperTestUtility {
|
||||
$this->aclMapper,
|
||||
\OC::$server->query(StackMapper::class),
|
||||
$this->userManager,
|
||||
$this->groupManager
|
||||
$this->groupManager,
|
||||
$this->createMock(LoggerInterface::class)
|
||||
);
|
||||
|
||||
$this->boards = [
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace OCA\Deck\Db;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\AppFramework\Db\MapperTestUtility;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,8 @@ class BoardMapperTest extends MapperTestUtility {
|
||||
\OC::$server->query(AclMapper::class),
|
||||
\OC::$server->query(StackMapper::class),
|
||||
$this->userManager,
|
||||
$this->groupManager
|
||||
$this->groupManager,
|
||||
$this->createMock(LoggerInterface::class)
|
||||
);
|
||||
$this->aclMapper = \OC::$server->query(AclMapper::class);
|
||||
$this->labelMapper = \OC::$server->query(LabelMapper::class);
|
||||
|
||||
@@ -83,6 +83,7 @@ class CardTest extends TestCase {
|
||||
'assignedUsers' => null,
|
||||
'deletedAt' => 0,
|
||||
'commentsUnread' => 0,
|
||||
'commentsCount' => 0,
|
||||
'lastEditor' => null,
|
||||
'ETag' => $card->getETag(),
|
||||
], $card->jsonSerialize());
|
||||
@@ -109,6 +110,7 @@ class CardTest extends TestCase {
|
||||
'assignedUsers' => null,
|
||||
'deletedAt' => 0,
|
||||
'commentsUnread' => 0,
|
||||
'commentsCount' => 0,
|
||||
'lastEditor' => null,
|
||||
'ETag' => $card->getETag(),
|
||||
], $card->jsonSerialize());
|
||||
@@ -145,6 +147,7 @@ class CardTest extends TestCase {
|
||||
'assignedUsers' => ['user1'],
|
||||
'deletedAt' => 0,
|
||||
'commentsUnread' => 0,
|
||||
'commentsCount' => 0,
|
||||
'lastEditor' => null,
|
||||
'ETag' => $card->getETag(),
|
||||
], $card->jsonSerialize());
|
||||
|
||||
@@ -130,7 +130,8 @@ class NotificationHelperTest extends \Test\TestCase {
|
||||
$card = Card::fromParams([
|
||||
'notified' => false,
|
||||
'id' => 123,
|
||||
'title' => 'MyCardTitle'
|
||||
'title' => 'MyCardTitle',
|
||||
'duedate' => '2020-12-24'
|
||||
]);
|
||||
$this->cardMapper->expects($this->once())
|
||||
->method('findBoardId')
|
||||
@@ -225,7 +226,8 @@ class NotificationHelperTest extends \Test\TestCase {
|
||||
$card = Card::fromParams([
|
||||
'notified' => false,
|
||||
'id' => 123,
|
||||
'title' => 'MyCardTitle'
|
||||
'title' => 'MyCardTitle',
|
||||
'duedate' => '2020-12-24'
|
||||
]);
|
||||
$card->setAssignedUsers([
|
||||
new User($users[0])
|
||||
@@ -323,7 +325,8 @@ class NotificationHelperTest extends \Test\TestCase {
|
||||
$card = Card::fromParams([
|
||||
'notified' => false,
|
||||
'id' => 123,
|
||||
'title' => 'MyCardTitle'
|
||||
'title' => 'MyCardTitle',
|
||||
'duedate' => '2020-12-24'
|
||||
]);
|
||||
$card->setAssignedUsers([
|
||||
new User($users[0])
|
||||
@@ -470,7 +473,7 @@ class NotificationHelperTest extends \Test\TestCase {
|
||||
->with(123)
|
||||
->willReturn($board);
|
||||
$user = $this->createMock(IUser::class);
|
||||
$user->expects($this->once())
|
||||
$user->expects($this->any())
|
||||
->method('getUID')
|
||||
->willReturn('userA');
|
||||
$group = $this->createMock(IGroup::class);
|
||||
|
||||
47
tests/unit/Search/Query/AQueryParameterTest.php
Normal file
47
tests/unit/Search/Query/AQueryParameterTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (c) 2021 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Deck\Search\Query;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AQueryParameterTest extends TestCase {
|
||||
public function dataValue() {
|
||||
return [
|
||||
['foo', 'foo'],
|
||||
['spätial character', 'spätial character'],
|
||||
['"spätial character"', 'spätial character'],
|
||||
['"spätial "character"', 'spätial "character'],
|
||||
['"spätial 🐘"', 'spätial 🐘'],
|
||||
['\'spätial character\'', '\'spätial character\''],
|
||||
];
|
||||
}
|
||||
|
||||
/** @dataProvider dataValue */
|
||||
public function testValue($input, $expectedValue) {
|
||||
$parameter = new StringQueryParameter('test', 0, $input);
|
||||
$this->assertEquals($expectedValue, $parameter->getValue());
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class CardServiceTest extends TestCase {
|
||||
$this->userManager->expects($this->once())
|
||||
->method('get')
|
||||
->willReturn($user);
|
||||
$this->commentsManager->expects($this->once())
|
||||
$this->commentsManager->expects($this->any())
|
||||
->method('getNumberOfCommentsForObject')
|
||||
->willReturn(0);
|
||||
$boardMock = $this->createMock(Board::class);
|
||||
|
||||
Reference in New Issue
Block a user