Website: a visitor who never chose a view sees the board's own default view.

The view resolver was handed the browser's fallback, Swimlanes, as if the
visitor had asked for it, so a public board whose Board View is Website showed
its kanban to everybody arriving at its address. storedBoardView() can now
return only a view somebody chose (chosenOnly), and the board's default
decides when there is none.

tests/boardViewSettings pins the default for somebody with no view of their
own; the tests that pin the stored view follow the new shape.

Thanks to xet7 !
This commit is contained in:
Lauri Ojansivu committed 2026-11-22 07:21:01 +02:00
1 parent 1032b472f3
commit fd7836e99c
7 files changed
+33 -12

No files matched your search

+11 -4
View File
@@ -336,12 +336,18 @@ export const Utils = {
// returned as it is. A view the instance disabled (#6736, Admin Panel /
// Settings / Visibility / Features) is not offered either.
boardView() {
const stored = Utils.storedBoardView();
const board = Utils.getCurrentBoard();
return board ? resolveBoardView(board, stored, allowBoardView, Meteor.userId()) : stored;
if (!board) return Utils.storedBoardView();
// Somebody who never chose a view on this board - a visitor of a public
// board above all - gets the board's own default (Board Settings / Board
// View), not Swimlanes passed off as their choice: that made "Default on
// Public Board" do nothing for everybody who had not picked a view.
return resolveBoardView(board, Utils.storedBoardView({ chosenOnly: true }), allowBoardView, Meteor.userId());
},
storedBoardView() {
// The view this person chose, or - unless only a choice is asked for -
// Swimlanes when they chose none.
storedBoardView({ chosenOnly = false } = {}) {
const pendingChoice = pendingBoardView.get();
// #6745: only the view fields. boardView() is read by every list's card
// loop (listBody's idOrNull/containerSwimlaneId); reading the whole user here
@@ -379,7 +385,8 @@ export const Utils = {
// lacked the four Scrum views, so a visitor's Product Backlog, Sprints,
// Sprint Report or Velocity opened as Swimlanes.
const browserView = window.localStorage.getItem('boardView');
return isKnownBoardView(browserView) ? browserView : DEFAULT_BOARD_VIEW;
if (isKnownBoardView(browserView)) return browserView;
return chosenOnly ? null : DEFAULT_BOARD_VIEW;
},
// `swimlaneId` scopes a BOARD-WIDE list's collapse state to the one
+1 -1
View File
@@ -39,7 +39,7 @@ assert.match(read('client/components/boards/boardHeader.js'), /'click \.js-open-
// Stored and restored without an account: client/lib/utils.js checks the
// browser's view against BOARD_VIEWS (above) rather than its own copy.
assert.match(read('client/lib/utils.js'), /setItem\('boardView', isKnownBoardView\(view\) \? view : DEFAULT_BOARD_VIEW\)/, 'stored');
assert.match(read('client/lib/utils.js'), /return isKnownBoardView\(browserView\) \? browserView : DEFAULT_BOARD_VIEW;/, 'and restored');
assert.match(read('client/lib/utils.js'), /if \(isKnownBoardView\(browserView\)\) return browserView;/, 'and restored');
assert.match(read('models/users.js'), /'board-view-size-cycle-time',\s*'board-view-map',/);
const cards = read('models/cards.js');
assert.match(cards, /mapX: \{[\s\S]*?type: Number,\s*optional: true,\s*min: 0,\s*max: 100,/);
+1 -1
View File
@@ -196,7 +196,7 @@ test('the anonymous-user fallback (no logged-in profile) accepts every view', ()
const known = require('../models/lib/boardViewSettings').isKnownBoardView;
VIEWS.forEach(v => assert.ok(known(v.view), `${v.view} is in BOARD_VIEWS`));
assert.match(utilsJs, /setItem\('boardView', isKnownBoardView\(view\) \? view : DEFAULT_BOARD_VIEW\)/, 'storing accepts every view');
assert.match(utilsJs, /return isKnownBoardView\(browserView\) \? browserView : DEFAULT_BOARD_VIEW;/, 'and so does reading it back');
assert.match(utilsJs, /if \(isKnownBoardView\(browserView\)\) return browserView;/, 'and so does reading it back');
assert.ok(!utilsJs.includes("'board-view-product-backlog',"),
'no hand-written view list is left to drift (negative)');
});
+17 -3
View File
@@ -349,9 +349,11 @@ test('moveBoardView moves one step, and the first up / last down / unknown are n
});
test('Utils.boardView() resolves the stored choice through the current board', () => {
assert.ok(/boardView\(\) \{\s*const stored = Utils\.storedBoardView\(\);\s*const board = Utils\.getCurrentBoard\(\);\s*return board \? resolveBoardView\(board, stored, allowBoardView, Meteor\.userId\(\)\) : stored;/.test(utilsJs), 'a view the instance disabled falls back too (#6736); the viewer decides public or private');
// On a board, only a view the person chose goes in; none is null, so the
// board's default applies (the last test of this file).
assert.ok(/boardView\(\) \{\s*const board = Utils\.getCurrentBoard\(\);\s*if \(!board\) return Utils\.storedBoardView\(\);[\s\S]{0,400}return resolveBoardView\(board, Utils\.storedBoardView\(\{ chosenOnly: true \}\), allowBoardView, Meteor\.userId\(\)\);/.test(utilsJs), 'a view the instance disabled falls back too (#6736); the viewer decides public or private');
// #4906 / #4256: the stored choice is this board's own, else the shared one.
assert.ok(/storedBoardView\(\) \{\s*const pendingChoice = pendingBoardView\.get\(\);/.test(utilsJs), 'the previous body is the stored choice');
assert.ok(/storedBoardView\(\{ chosenOnly = false \} = \{\}\) \{\s*const pendingChoice = pendingBoardView\.get\(\);/.test(utilsJs), 'the previous body is the stored choice');
assert.ok(utilsJs.includes("require('/models/lib/boardViewSettings')"));
});
@@ -559,7 +561,7 @@ test('a public board shows its public views to visitors and its private views to
test('the client resolves and draws the menu for the person looking', () => {
const utils = read('client/lib/utils.js');
const header = read('client/components/boards/boardHeader.js');
assert.match(utils, /resolveBoardView\(board, stored, allowBoardView, Meteor\.userId\(\)\)/);
assert.match(utils, /resolveBoardView\(board, Utils\.storedBoardView\(\{ chosenOnly: true \}\), allowBoardView, Meteor\.userId\(\)\)/);
assert.match(header, /boardViewMenuEntries\(board, Utils\.boardView\(\), allowBoardView, Meteor\.userId\(\)\)/);
});
@@ -604,3 +606,15 @@ test('every Board View entry links a guide that exists', () => {
});
console.log(`boardViewSettings: ${passed} passed`);
// A visitor who never chose a view gets the board's "Default on Public
// Board" - Swimlanes is not passed off as their choice, which made the public
// default do nothing for everybody who had not picked a view.
test('no view of one\'s own: the board\'s default; a choice of one\'s own: that choice', () => {
const board = { permission: 'public', members: [], defaultPublicBoardView: 'board-view-website' };
assert.strictEqual(bvs.resolveBoardView(board, null, () => true, null), 'board-view-website');
assert.strictEqual(bvs.resolveBoardView(board, 'board-view-lists', () => true, null), 'board-view-lists', 'a visitor\'s own choice wins');
const utils = read('client/lib/utils.js');
assert.match(utils, /resolveBoardView\(board, Utils\.storedBoardView\(\{ chosenOnly: true \}\), allowBoardView, Meteor\.userId\(\)\)/);
assert.match(utils, /return chosenOnly \? null : DEFAULT_BOARD_VIEW;/, 'negative: no choice is null, not Swimlanes');
});
+1 -1
View File
@@ -71,7 +71,7 @@ test('the view is offered below Calendar, rendered by the board, and shows label
assert.match(read('models/lib/instanceFeatures.js'), /views: \['board-view-cal', 'board-view-calendar-mode', 'board-view-multiboard-cal'\]/);
// Set and read back without an account through BOARD_VIEWS (checked above).
assert.match(read('client/lib/utils.js'), /setItem\('boardView', isKnownBoardView\(view\) \? view : DEFAULT_BOARD_VIEW\)/, 'set');
assert.match(read('client/lib/utils.js'), /return isKnownBoardView\(browserView\) \? browserView : DEFAULT_BOARD_VIEW;/, 'and read back');
assert.match(read('client/lib/utils.js'), /if \(isKnownBoardView\(browserView\)\) return browserView;/, 'and read back');
assert.match(read('client/components/boards/boardHeader.js'), /'click \.js-open-calendar-mode-view'\(\) \{\s*Utils\.setBoardView\('board-view-calendar-mode'\);/);
assert.match(read('client/components/boards/boardBody.jade'), /else if isViewCalendarMode\s*\n\s*\+calendarModeView/);
const jade = read('client/components/boards/calendarModeView.jade');
+1 -1
View File
@@ -119,7 +119,7 @@ test('the board view menu, rows, moves and fallback skip what the instance disab
test('wiring: every place that draws or picks a board view asks the instance', () => {
// ...and the viewer, deliberately: a public board's visitors get its public
// views, its members its private ones (boardViewAudience).
assert.match(read('client/lib/utils.js'), /resolveBoardView\(board, stored, allowBoardView, Meteor\.userId\(\)\)/);
assert.match(read('client/lib/utils.js'), /resolveBoardView\(board, Utils\.storedBoardView\(\{ chosenOnly: true \}\), allowBoardView, Meteor\.userId\(\)\)/);
assert.match(read('client/components/boards/boardHeader.js'),
/boardViewMenuEntries\(board, Utils\.boardView\(\), allowBoardView, Meteor\.userId\(\)\)/);
const sidebar = read('client/components/sidebar/sidebar.js');
+1 -1
View File
@@ -114,7 +114,7 @@ PER_MINICARD.forEach(([file, marker, field]) => {
// document read here, one card open re-ran every list and Blaze re-evaluated
// every minicard - 37,452 invalidations for 40 cards, 390 after.
test('Utils.storedBoardView reads only the board-view fields', () => {
const body = bodyOf(read('client/lib/utils.js'), ' storedBoardView() {');
const body = bodyOf(read('client/lib/utils.js'), ' storedBoardView({ chosenOnly = false } = {}) {');
// #4906 / #4256: the shared view and the per-board views, nothing else.
assert.ok(/currentUserWith\(\['boardViewPreference', 'boardViewPreferences', 'profile\.boardView', 'profile\.boardViews'\]\)/.test(body));
assert.ok(!WHOLE_USER.test(body), 'negative: not the whole user document');