-
Notifications
You must be signed in to change notification settings - Fork 345
feat: per-user board ordering in the navigation #8150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Lightshadow02
wants to merge
5
commits into
nextcloud:main
Choose a base branch
from
Lightshadow02:feat/user-board-order
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5f7ce12
feat(boards): per-user boardOrder config value
Lightshadow02 f1096c6
feat(boards): per-user drag and drop ordering in the navigation
Lightshadow02 abc1eee
fix(boards): address branch review findings
Lightshadow02 8e433f1
docs(boards): keep config key table alphabetical
Lightshadow02 9caa17e
fix(boards): address review feedback
Lightshadow02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| /** | ||
| * Sort boards by the user defined order (list of board ids), boards not in | ||
| * the list come last, alphabetically. | ||
| * | ||
| * @param {Array} boards array of board objects ({ id, title }) | ||
| * @param {Array|null} order ordered list of board ids or null | ||
| * @return {Array} new sorted array | ||
| */ | ||
| export function sortBoards(boards, order) { | ||
| const position = new Map((order ?? []).map((id, index) => [id, index])) | ||
| return [...boards].sort((a, b) => { | ||
| const positionA = position.has(a.id) ? position.get(a.id) : Number.POSITIVE_INFINITY | ||
| const positionB = position.has(b.id) ? position.get(b.id) : Number.POSITIVE_INFINITY | ||
| if (positionA !== positionB) { | ||
| return positionA - positionB | ||
| } | ||
| return a.title.localeCompare(b.title) | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
| import { sortBoards } from './boardSort.js' | ||
|
|
||
| describe('sortBoards', () => { | ||
| it('sorts alphabetically without a custom order', () => { | ||
| const boards = [{ id: 1, title: 'Zebra' }, { id: 2, title: 'Alpha' }] | ||
| expect(sortBoards(boards, null).map(b => b.id)).toEqual([2, 1]) | ||
| }) | ||
|
|
||
| it('applies the custom order first', () => { | ||
| const boards = [{ id: 1, title: 'Alpha' }, { id: 2, title: 'Beta' }, { id: 3, title: 'Gamma' }] | ||
| expect(sortBoards(boards, [3, 1]).map(b => b.id)).toEqual([3, 1, 2]) | ||
| }) | ||
|
|
||
| it('appends unknown boards alphabetically after ordered ones', () => { | ||
| const boards = [{ id: 5, title: 'Zzz' }, { id: 6, title: 'Aaa' }, { id: 7, title: 'Mmm' }] | ||
| expect(sortBoards(boards, [7]).map(b => b.id)).toEqual([7, 6, 5]) | ||
| }) | ||
|
|
||
| it('ignores ids of removed boards', () => { | ||
| const boards = [{ id: 1, title: 'B' }, { id: 2, title: 'A' }] | ||
| expect(sortBoards(boards, [999, 2]).map(b => b.id)).toEqual([2, 1]) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Deck\Service; | ||
|
|
||
| use OCA\Deck\BadRequestException; | ||
| use OCP\IConfig; | ||
| use OCP\IGroupManager; | ||
| use PHPUnit\Framework\MockObject\MockObject; | ||
| use Test\TestCase; | ||
|
|
||
| class ConfigServiceTest extends TestCase { | ||
|
|
||
| private IConfig&MockObject $config; | ||
| private IGroupManager&MockObject $groupManager; | ||
| /** @var ConfigService|MockObject */ | ||
| private $configService; | ||
|
|
||
| public function setUp(): void { | ||
| parent::setUp(); | ||
| $this->config = $this->createMock(IConfig::class); | ||
| $this->groupManager = $this->createMock(IGroupManager::class); | ||
|
|
||
| // ConfigService::getUserId() resolves the current user through | ||
| // \OCP\Server::get(IUserSession::class) instead of a constructor | ||
| // dependency, so it can't be mocked via the constructor. Stub just | ||
| // that method and keep everything else on the real implementation. | ||
| $this->configService = $this->getMockBuilder(ConfigService::class) | ||
| ->setConstructorArgs([$this->config, $this->groupManager]) | ||
| ->onlyMethods(['getUserId']) | ||
| ->getMock(); | ||
| $this->configService->method('getUserId')->willReturn('admin'); | ||
| } | ||
|
|
||
| public function testBoardOrderRoundTrip() { | ||
| $this->config->expects($this->once()) | ||
| ->method('setUserValue') | ||
| ->with('admin', 'deck', 'boardOrder', '[4,2,9]'); | ||
| $result = $this->configService->set('boardOrder', [4, '2', 9.0]); | ||
| $this->assertSame([4, 2, 9], $result); | ||
| } | ||
|
|
||
| public function testBoardOrderRejectsNonArray() { | ||
| $this->expectException(BadRequestException::class); | ||
| $this->configService->set('boardOrder', 'not-a-list'); | ||
| } | ||
|
|
||
| public function testGetBoardOrderDecodesAndFiltersStoredValue() { | ||
| $this->config->expects($this->once()) | ||
| ->method('getUserValue') | ||
| ->with('admin', 'deck', 'boardOrder', '[]') | ||
| ->willReturn('[3,1,5,"x"]'); | ||
| $this->assertSame([3, 1, 5], $this->configService->get('boardOrder')); | ||
| } | ||
|
|
||
| public function testGetAllIncludesBoardOrder() { | ||
| $this->config->method('getUserValue')->willReturnCallback(function ($userId, $appId, $key, $default) { | ||
| if ($key === 'boardOrder') { | ||
| return '[7,3]'; | ||
| } | ||
| return $default; | ||
| }); | ||
| $this->config->method('getAppValue')->willReturnArgument(2); | ||
| $this->groupManager->method('isAdmin')->willReturn(false); | ||
|
|
||
| $data = $this->configService->getAll(); | ||
| $this->assertSame([7, 3], $data['boardOrder']); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add an icon to indicate and trigger the drag function since it is showing the board url when user trying to drag the board.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense — done in 9caa17e. Boards are now dragged through a dedicated handle icon (
drag-vertical, revealed on row hover,cursor: grab) viadrag-handle-selector, so grabbing the row itself no longer starts a drag and the browser's native link drag (the URL ghost from your screenshot) can't be triggered by the reorder gesture anymore.