Skip to content

Commit

Permalink
Merge pull request #766 from nextcloud/bugfix/noid/13-groups
Browse files Browse the repository at this point in the history
Use regular groups endpoint to support Nextcloud 13
  • Loading branch information
juliusknorr authored Dec 5, 2018
2 parents 3162ff4 + 8906d12 commit c2294b6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
13 changes: 10 additions & 3 deletions js/controller/ListController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
4 changes: 0 additions & 4 deletions lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/controller/PageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
Expand Down

0 comments on commit c2294b6

Please sign in to comment.