From 611f9ff6a572d406e1a163f7c623c1e84451b87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 6 May 2020 09:24:41 +0200 Subject: [PATCH 1/3] Do not change participant primary key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Db/Circle.php | 5 +++-- lib/Db/Group.php | 5 +++-- lib/Db/User.php | 5 +++-- src/components/board/Board.vue | 7 +++---- src/components/board/SharingTabSidebar.vue | 10 +++++----- src/components/card/CardSidebar.vue | 11 +++++++++-- src/components/cards/AvatarList.vue | 4 ++-- src/store/main.js | 2 +- 8 files changed, 29 insertions(+), 20 deletions(-) diff --git a/lib/Db/Circle.php b/lib/Db/Circle.php index fad2f0cb7..194cae86b 100644 --- a/lib/Db/Circle.php +++ b/lib/Db/Circle.php @@ -31,7 +31,7 @@ class Circle extends RelationalObject { protected $object; public function __construct(\OCA\Circles\Model\Circle $circle) { - $primaryKey = IShare::TYPE_CIRCLE . ':' . $circle->getUniqueId(); + $primaryKey = $circle->getUniqueId(); parent::__construct($primaryKey, $circle); } @@ -40,7 +40,8 @@ class Circle extends RelationalObject { 'uid' => $this->object->getUniqueId(), 'displayname' => $this->object->getName(), 'typeString' => $this->object->getTypeString(), - 'circleOwner' => $this->object->getOwner() + 'circleOwner' => $this->object->getOwner(), + 'type' => 7 ]; } } diff --git a/lib/Db/Group.php b/lib/Db/Group.php index 451078ae4..516afb323 100644 --- a/lib/Db/Group.php +++ b/lib/Db/Group.php @@ -28,14 +28,15 @@ use OCP\Share\IShare; class Group extends RelationalObject { public function __construct(IGroup $group) { - $primaryKey = IShare::TYPE_GROUP . ':' . $group->getGID(); + $primaryKey = $group->getGID(); parent::__construct($primaryKey, $group); } public function getObjectSerialization() { return [ 'uid' => $this->object->getGID(), - 'displayname' => $this->object->getDisplayName() + 'displayname' => $this->object->getDisplayName(), + 'type' => 1 ]; } } diff --git a/lib/Db/User.php b/lib/Db/User.php index 83ff2fc32..0a1334a35 100644 --- a/lib/Db/User.php +++ b/lib/Db/User.php @@ -28,14 +28,15 @@ use OCP\Share\IShare; class User extends RelationalObject { public function __construct(IUser $user) { - $primaryKey = IShare::TYPE_USER . ':' . $user->getUID(); + $primaryKey = $user->getUID(); parent::__construct($primaryKey, $user); } public function getObjectSerialization() { return [ 'uid' => $this->object->getUID(), - 'displayname' => $this->object->getDisplayName() + 'displayname' => $this->object->getDisplayName(), + 'type' => 0 ]; } diff --git a/src/components/board/Board.vue b/src/components/board/Board.vue index 3d18bdfa2..50e388031 100644 --- a/src/components/board/Board.vue +++ b/src/components/board/Board.vue @@ -24,12 +24,12 @@
-
+

{{ t('deck', 'Loading board') }}

-
+
-
+

{{ t('deck', 'Board not found') }}

-
diff --git a/src/components/board/SharingTabSidebar.vue b/src/components/board/SharingTabSidebar.vue index b4b90002c..e2b4b667d 100644 --- a/src/components/board/SharingTabSidebar.vue +++ b/src/components/board/SharingTabSidebar.vue @@ -7,8 +7,8 @@ :options="formatedSharees" :user-select="true" label="displayName" - track-by="user" - :internal-search="false" + track-by="multiselectKey" + :internal-search="true" @input="clickAddAcl" @search-change="asyncFind" /> @@ -24,7 +24,7 @@ -
  • +
  • @@ -101,11 +101,11 @@ export default { }, formatedSharees() { return this.unallocatedSharees.map(item => { - const sharee = { user: item.label, displayName: item.label, icon: 'icon-user', + multiselectKey: item.shareType + ':' + item.primaryKey, } if (item.value.shareType === 1) { @@ -124,7 +124,7 @@ export default { unallocatedSharees() { return this.sharees.filter((sharee) => { const foundIndex = this.board.acl.findIndex((acl) => { - return acl.participant.uid === sharee.value.shareWith + return acl.participant.uid === sharee.value.shareWith && acl.participant.type === sharee.value.shareType }) if (foundIndex === -1) { return true diff --git a/src/components/card/CardSidebar.vue b/src/components/card/CardSidebar.vue index 6485581a6..2c53cb042 100644 --- a/src/components/card/CardSidebar.vue +++ b/src/components/card/CardSidebar.vue @@ -72,7 +72,7 @@ :auto-limit="false" :placeholder="t('deck', 'Assign a user to this card…')" label="displayname" - track-by="primaryKey" + track-by="multiselectKey" @select="assignUserToCard" @remove="removeUserFromCard"> @@ -89,6 +90,7 @@ :key="option.primaryKey" :user="option.participant.uid" :display-name="option.participant.displayname" + :is-no-user="scope.option.isNoUser" :size="32" />
    @@ -258,6 +260,7 @@ export default { displayName: item.displayname, icon: 'icon-user', isNoUser: false, + multiselectKey: item.type + ':' + item.uid, } if (item.type === 1) { @@ -313,7 +316,11 @@ export default { this.allLabels = this.currentCard.labels if (this.currentCard.assignedUsers && this.currentCard.assignedUsers.length > 0) { - this.assignedUsers = this.currentCard.assignedUsers.map((item) => item.participant) + this.assignedUsers = this.currentCard.assignedUsers.map((item) => ({ + ...item.participant, + isNoUser: item.participant.type !== 0, + multiselectKey: item.participant.type + ':' + item.participant.primaryKey, + })) } else { this.assignedUsers = [] } diff --git a/src/components/cards/AvatarList.vue b/src/components/cards/AvatarList.vue index 95b9f2a6e..2147a6b7d 100644 --- a/src/components/cards/AvatarList.vue +++ b/src/components/cards/AvatarList.vue @@ -33,14 +33,14 @@ :disable-menu="true" :size="32" /> Date: Wed, 6 May 2020 09:34:38 +0200 Subject: [PATCH 2/3] Fix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Db/Circle.php | 2 -- lib/Db/Group.php | 1 - lib/Db/User.php | 1 - tests/unit/Db/GroupTest.php | 6 ++++-- tests/unit/Db/UserTest.php | 6 ++++-- tests/unit/controller/LabelApiControllerTest.php | 4 +++- tests/unit/controller/StackApiControllerTest.php | 8 ++++---- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/Db/Circle.php b/lib/Db/Circle.php index 194cae86b..a8808c102 100644 --- a/lib/Db/Circle.php +++ b/lib/Db/Circle.php @@ -23,8 +23,6 @@ namespace OCA\Deck\Db; -use OCP\Share\IShare; - class Circle extends RelationalObject { /** @var \OCA\Circles\Model\Circle */ diff --git a/lib/Db/Group.php b/lib/Db/Group.php index 516afb323..c06e3f461 100644 --- a/lib/Db/Group.php +++ b/lib/Db/Group.php @@ -24,7 +24,6 @@ namespace OCA\Deck\Db; use OCP\IGroup; -use OCP\Share\IShare; class Group extends RelationalObject { public function __construct(IGroup $group) { diff --git a/lib/Db/User.php b/lib/Db/User.php index 0a1334a35..d595ece75 100644 --- a/lib/Db/User.php +++ b/lib/Db/User.php @@ -24,7 +24,6 @@ namespace OCA\Deck\Db; use OCP\IUser; -use OCP\Share\IShare; class User extends RelationalObject { public function __construct(IUser $user) { diff --git a/tests/unit/Db/GroupTest.php b/tests/unit/Db/GroupTest.php index 195c9268d..f57bccb47 100644 --- a/tests/unit/Db/GroupTest.php +++ b/tests/unit/Db/GroupTest.php @@ -38,7 +38,8 @@ class GroupTest extends \Test\TestCase { $groupRelationalObject = new Group($group); $expected = [ 'uid' => 'mygroup', - 'displayname' => 'My Group' + 'displayname' => 'My Group', + 'type' => 1 ]; $this->assertEquals($expected, $groupRelationalObject->getObjectSerialization()); } @@ -56,7 +57,8 @@ class GroupTest extends \Test\TestCase { $expected = [ 'uid' => 'mygroup', 'displayname' => 'My Group', - 'primaryKey' => '1:mygroup' + 'primaryKey' => 'mygroup', + 'type' => 1 ]; $actual = $groupRelationalObject->jsonSerialize(); diff --git a/tests/unit/Db/UserTest.php b/tests/unit/Db/UserTest.php index 6004deda4..8f7e84816 100644 --- a/tests/unit/Db/UserTest.php +++ b/tests/unit/Db/UserTest.php @@ -38,7 +38,8 @@ class UserTest extends \Test\TestCase { $userRelationalObject = new User($user); $expected = [ 'uid' => 'myuser', - 'displayname' => 'myuser displayname' + 'displayname' => 'myuser displayname', + 'type' => 0 ]; $this->assertEquals($expected, $userRelationalObject->getObjectSerialization()); } @@ -56,7 +57,8 @@ class UserTest extends \Test\TestCase { $expected = [ 'uid' => 'myuser', 'displayname' => 'myuser displayname', - 'primaryKey' => '0:myuser' + 'primaryKey' => 'myuser', + 'type' => 0, ]; $this->assertEquals($expected, $userRelationalObject->jsonSerialize()); } diff --git a/tests/unit/controller/LabelApiControllerTest.php b/tests/unit/controller/LabelApiControllerTest.php index a4de3aad4..86dec24f6 100644 --- a/tests/unit/controller/LabelApiControllerTest.php +++ b/tests/unit/controller/LabelApiControllerTest.php @@ -34,7 +34,9 @@ class LabelApiControllerTest extends \Test\TestCase { private $request; private $labelService; private $userId = 'admin'; - private $exampleLabel; + private $exampleLabel = [ + 'id' => 123 + ]; public function setUp(): void { parent::setUp(); diff --git a/tests/unit/controller/StackApiControllerTest.php b/tests/unit/controller/StackApiControllerTest.php index 64b4ec7e9..5878e560f 100644 --- a/tests/unit/controller/StackApiControllerTest.php +++ b/tests/unit/controller/StackApiControllerTest.php @@ -36,8 +36,8 @@ class StackApiControllerTest extends \Test\TestCase { private $controller; private $boardService; private $stackService; - private $exampleStack; - private $exampleBoard; + private $exampleStack = []; + private $exampleBoard = []; public function setUp(): void { parent::setUp(); @@ -45,13 +45,13 @@ class StackApiControllerTest extends \Test\TestCase { $this->boardService = $this->createMock(BoardService::class); $this->stackService = $this->createMock(StackService::class); + $this->exampleBoard['boardId'] = '89'; + $this->exampleStack['id'] = 345; $this->exampleStack['boardId'] = $this->exampleBoard['boardId']; $this->exampleStack['order'] = 0; $this->exampleStack['title'] = 'Example Stack From API'; - $this->exampleBoard['boardId'] = '89'; - $this->controller = new StackApiController( $this->appName, $this->request, From 7e03cf8ae40336d448bd4766afae9fdcb371114c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 6 May 2020 09:45:33 +0200 Subject: [PATCH 3/3] Remove unneded test files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .gitignore | 1 + tests/.phpunit.result.cache | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 tests/.phpunit.result.cache diff --git a/.gitignore b/.gitignore index f033bd7ef..7ff1cdcd0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ css/style.css css/vendor.css tests/integration/vendor/ tests/integration/composer.lock +tests/.phpunit.result.cache vendor/ *.lock .php_cs.cache diff --git a/tests/.phpunit.result.cache b/tests/.phpunit.result.cache deleted file mode 100644 index 1eb33b5b7..000000000 --- a/tests/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -C:37:"PHPUnit\Runner\DefaultTestResultCache":3426:{a:2:{s:7:"defects";a:5:{s:89:"Test\Authentication\Login\FinishRememberedLoginCommandTest::testProcessNotRememberedLogin";i:4;s:71:"Test\Authentication\Login\FinishRememberedLoginCommandTest::testProcess";i:3;s:102:"Test\Authentication\Login\FinishRememberedLoginCommandTest::testProcessNotRemeberedLoginWithAutologout";i:4;s:52:"OCA\Files_Sharing\Tests\ApiTest::testCreateShareLink";i:4;s:64:"OCA\Files_Sharing\Tests\ApiTest::testCreateShareLinkPublicUpload";i:3;}s:5:"times";a:38:{s:89:"Test\Authentication\Login\FinishRememberedLoginCommandTest::testProcessNotRememberedLogin";d:0.008;s:71:"Test\Authentication\Login\FinishRememberedLoginCommandTest::testProcess";d:0.001;s:102:"Test\Authentication\Login\FinishRememberedLoginCommandTest::testProcessNotRemeberedLoginWithAutologout";d:0.001;s:52:"OCA\Files_Sharing\Tests\ApiTest::testCreateShareLink";d:0.19;s:56:"OCA\Files_Sharing\Tests\ApiTest::testCreateShareUserFile";d:0.485;s:58:"OCA\Files_Sharing\Tests\ApiTest::testCreateShareUserFolder";d:0.226;s:57:"OCA\Files_Sharing\Tests\ApiTest::testCreateShareGroupFile";d:0.244;s:59:"OCA\Files_Sharing\Tests\ApiTest::testCreateShareGroupFolder";d:0.222;s:64:"OCA\Files_Sharing\Tests\ApiTest::testCreateShareLinkPublicUpload";d:0.121;s:56:"OCA\Files_Sharing\Tests\ApiTest::testEnforceLinkPassword";d:0.576;s:53:"OCA\Files_Sharing\Tests\ApiTest::testSharePermissions";d:0.167;s:49:"OCA\Files_Sharing\Tests\ApiTest::testGetAllShares";d:0.129;s:55:"OCA\Files_Sharing\Tests\ApiTest::testGetAllSharesWithMe";d:0.182;s:50:"OCA\Files_Sharing\Tests\ApiTest::testPublicLinkUrl";d:0.133;s:55:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromSource";d:0.135;s:67:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromSourceWithReshares";d:0.162;s:51:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromId";d:0.13;s:55:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromFolder";d:0.165;s:63:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromFolderWithFile";d:0.125;s:63:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromFolderReshares";d:0.185;s:66:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromSubFolderReShares";d:0.183;s:65:"OCA\Files_Sharing\Tests\ApiTest::testGetShareMultipleSharedFolder";d:0.263;s:63:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromFileReReShares";d:0.203;s:58:"OCA\Files_Sharing\Tests\ApiTest::testGetShareFromUnknownId";d:0.11;s:48:"OCA\Files_Sharing\Tests\ApiTest::testUpdateShare";d:0.391;s:54:"OCA\Files_Sharing\Tests\ApiTest::testUpdateShareUpload";d:0.142;s:58:"OCA\Files_Sharing\Tests\ApiTest::testUpdateShareExpireDate";d:0.146;s:48:"OCA\Files_Sharing\Tests\ApiTest::testDeleteShare";d:0.159;s:50:"OCA\Files_Sharing\Tests\ApiTest::testDeleteReshare";d:0.177;s:63:"OCA\Files_Sharing\Tests\ApiTest::testShareFolderWithAMountPoint";d:0.236;s:59:"OCA\Files_Sharing\Tests\ApiTest::testShareStorageMountPoint";d:0.165;s:74:"OCA\Files_Sharing\Tests\ApiTest::testPublicLinkExpireDate with data set #0";d:0.088;s:74:"OCA\Files_Sharing\Tests\ApiTest::testPublicLinkExpireDate with data set #1";d:0.111;s:74:"OCA\Files_Sharing\Tests\ApiTest::testPublicLinkExpireDate with data set #2";d:0.119;s:68:"OCA\Files_Sharing\Tests\ApiTest::testCreatePublicLinkExpireDateValid";d:0.135;s:76:"OCA\Files_Sharing\Tests\ApiTest::testCreatePublicLinkExpireDateInvalidFuture";d:0.119;s:56:"OCA\Files_Sharing\Tests\ApiTest::testInvisibleSharesUser";d:0.154;s:57:"OCA\Files_Sharing\Tests\ApiTest::testInvisibleSharesGroup";d:0.165;}}} \ No newline at end of file