Skip to content

Commit c2294b6

Browse files
authored
Merge pull request #766 from nextcloud/bugfix/noid/13-groups
Use regular groups endpoint to support Nextcloud 13
2 parents 3162ff4 + 8906d12 commit c2294b6

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

js/controller/ListController.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,16 @@ var ListController = function ($scope, $location, $filter, BoardService, $elemen
6565
$scope.groupLimitDisabled = true;
6666
let fetchGroups = function () {
6767
var deferred = $q.defer();
68-
$http.get(OC.linkToOCS('cloud', 2) + 'groups/details').then(function (response) {
69-
$scope.groups = response.data.ocs.data.groups;
70-
deferred.resolve(response.data.ocs.data.groups);
68+
// TODO: move to groups/details once 15 is min version
69+
$http.get(OC.linkToOCS('cloud', 2) + 'groups').then(function (response) {
70+
$scope.groups = response.data.ocs.data.groups.reduce((obj, item) => {
71+
obj.push({
72+
id: item,
73+
displayname: item,
74+
});
75+
return obj;
76+
}, []);
77+
deferred.resolve($scope.groups);
7178
}, function (error) {
7279
deferred.reject('Error while loading groups');
7380
});

lib/Controller/ConfigController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ private function getGroupLimit() {
106106
return [
107107
'id' => $group->getGID(),
108108
'displayname' => $group->getDisplayName(),
109-
'usercount' => $group->count(),
110-
'disabled' => $group->countDisabled(),
111-
'canAdd' => $group->canAddUser(),
112-
'canRemove' => $group->canRemoveUser(),
113109
];
114110
}, $groups);
115111
return $groups;

lib/Controller/PageController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public function index() {
6868
];
6969

7070
if ($this->defaultBoardService->checkFirstRun($this->userId, $this->appName)) {
71-
$this->defaultBoardService->createDefaultBoard($this->l10n->t('Personal'), $this->userId, '000000');
71+
if ($this->permissionService->canCreate()) {
72+
$this->defaultBoardService->createDefaultBoard($this->l10n->t('Personal'), $this->userId, '000000');
73+
}
7274
}
7375

7476
return new TemplateResponse('deck', 'main', $params);

tests/unit/controller/PageControllerTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public function testIndexOnFirstRun() {
6565
->method('checkFirstRun')
6666
->willReturn(true);
6767

68+
$this->permissionService->expects($this->any())
69+
->method('canCreate')
70+
->willReturn(true);
71+
6872
$this->defaultBoardService->expects($this->once())
6973
->method('createDefaultBoard')
7074
->willReturn($board);
@@ -73,6 +77,29 @@ public function testIndexOnFirstRun() {
7377
$this->assertEquals('main', $response->getTemplateName());
7478
}
7579

80+
public function testIndexOnFirstRunNoCreate() {
81+
82+
$board = new Board();
83+
$board->setTitle('Personal');
84+
$board->setOwner($this->userId);
85+
$board->setColor('000000');
86+
87+
$this->defaultBoardService->expects($this->once())
88+
->method('checkFirstRun')
89+
->willReturn(true);
90+
91+
$this->permissionService->expects($this->any())
92+
->method('canCreate')
93+
->willReturn(false);
94+
95+
$this->defaultBoardService->expects($this->never())
96+
->method('createDefaultBoard')
97+
->willReturn($board);
98+
99+
$response = $this->controller->index();
100+
$this->assertEquals('main', $response->getTemplateName());
101+
}
102+
76103
public function testIndexOnSecondRun() {
77104

78105
$this->config->setUserValue($this->userId, 'deck', 'firstRun', 'no');

0 commit comments

Comments
 (0)