From 8906d12a47654be6fd9eca5789f643bdf53fa013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 5 Dec 2018 16:23:17 +0100 Subject: [PATCH] Use regular groups endpoint to support Nextcloud 13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- js/controller/ListController.js | 13 +++++++--- lib/Controller/ConfigController.php | 4 --- lib/Controller/PageController.php | 4 ++- tests/unit/controller/PageControllerTest.php | 27 ++++++++++++++++++++ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/js/controller/ListController.js b/js/controller/ListController.js index 6f2a0205f..c88d43226 100644 --- a/js/controller/ListController.js +++ b/js/controller/ListController.js @@ -65,9 +65,16 @@ var ListController = function ($scope, $location, $filter, BoardService, $elemen $scope.groupLimitDisabled = true; let fetchGroups = function () { var deferred = $q.defer(); - $http.get(OC.linkToOCS('cloud', 2) + 'groups/details').then(function (response) { - $scope.groups = response.data.ocs.data.groups; - deferred.resolve(response.data.ocs.data.groups); + // TODO: move to groups/details once 15 is min version + $http.get(OC.linkToOCS('cloud', 2) + 'groups').then(function (response) { + $scope.groups = response.data.ocs.data.groups.reduce((obj, item) => { + obj.push({ + id: item, + displayname: item, + }); + return obj; + }, []); + deferred.resolve($scope.groups); }, function (error) { deferred.reject('Error while loading groups'); }); diff --git a/lib/Controller/ConfigController.php b/lib/Controller/ConfigController.php index 98390fd58..539c19e79 100644 --- a/lib/Controller/ConfigController.php +++ b/lib/Controller/ConfigController.php @@ -106,10 +106,6 @@ private function getGroupLimit() { return [ 'id' => $group->getGID(), 'displayname' => $group->getDisplayName(), - 'usercount' => $group->count(), - 'disabled' => $group->countDisabled(), - 'canAdd' => $group->canAddUser(), - 'canRemove' => $group->canRemoveUser(), ]; }, $groups); return $groups; diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 4cb9f79e6..0842ef14b 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -68,7 +68,9 @@ public function index() { ]; if ($this->defaultBoardService->checkFirstRun($this->userId, $this->appName)) { - $this->defaultBoardService->createDefaultBoard($this->l10n->t('Personal'), $this->userId, '000000'); + if ($this->permissionService->canCreate()) { + $this->defaultBoardService->createDefaultBoard($this->l10n->t('Personal'), $this->userId, '000000'); + } } return new TemplateResponse('deck', 'main', $params); diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php index 0f2038ee6..8f6d1c47c 100644 --- a/tests/unit/controller/PageControllerTest.php +++ b/tests/unit/controller/PageControllerTest.php @@ -65,6 +65,10 @@ public function testIndexOnFirstRun() { ->method('checkFirstRun') ->willReturn(true); + $this->permissionService->expects($this->any()) + ->method('canCreate') + ->willReturn(true); + $this->defaultBoardService->expects($this->once()) ->method('createDefaultBoard') ->willReturn($board); @@ -73,6 +77,29 @@ public function testIndexOnFirstRun() { $this->assertEquals('main', $response->getTemplateName()); } + public function testIndexOnFirstRunNoCreate() { + + $board = new Board(); + $board->setTitle('Personal'); + $board->setOwner($this->userId); + $board->setColor('000000'); + + $this->defaultBoardService->expects($this->once()) + ->method('checkFirstRun') + ->willReturn(true); + + $this->permissionService->expects($this->any()) + ->method('canCreate') + ->willReturn(false); + + $this->defaultBoardService->expects($this->never()) + ->method('createDefaultBoard') + ->willReturn($board); + + $response = $this->controller->index(); + $this->assertEquals('main', $response->getTemplateName()); + } + public function testIndexOnSecondRun() { $this->config->setUserValue($this->userId, 'deck', 'firstRun', 'no');