Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: chrome/browser/resources/md_bookmarks/reducers.js

Issue 2813503002: MD Bookmarks: Prevent navigating to invalid folders (Closed)
Patch Set: handleAction -> dispatch Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Module of functions which produce a new page state in response 6 * @fileoverview Module of functions which produce a new page state in response
7 * to an action. Reducers (in the same sense as Array.prototype.reduce) must be 7 * to an action. Reducers (in the same sense as Array.prototype.reduce) must be
8 * pure functions: they must not modify existing state objects, or make any API 8 * pure functions: they must not modify existing state objects, or make any API
9 * calls. 9 * calls.
10 */ 10 */
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 /** 306 /**
307 * @param {string} selectedFolder 307 * @param {string} selectedFolder
308 * @param {Action} action 308 * @param {Action} action
309 * @param {NodeMap} nodes 309 * @param {NodeMap} nodes
310 * @return {string} 310 * @return {string}
311 */ 311 */
312 SelectedFolderState.updateSelectedFolder = function( 312 SelectedFolderState.updateSelectedFolder = function(
313 selectedFolder, action, nodes) { 313 selectedFolder, action, nodes) {
314 switch (action.name) { 314 switch (action.name) {
315 case 'select-folder': 315 case 'select-folder':
316 // TODO(tsergeant): It should not be possible to select a non-folder.
317 return action.id; 316 return action.id;
318 case 'change-folder-open': 317 case 'change-folder-open':
319 // When hiding the selected folder by closing its ancestor, select 318 // When hiding the selected folder by closing its ancestor, select
320 // that ancestor instead. 319 // that ancestor instead.
321 if (!action.open && selectedFolder && 320 if (!action.open && selectedFolder &&
322 SelectedFolderState.isAncestorOf( 321 SelectedFolderState.isAncestorOf(
323 nodes, action.id, selectedFolder)) { 322 nodes, action.id, selectedFolder)) {
324 return action.id; 323 return action.id;
325 } 324 }
326 return selectedFolder; 325 return selectedFolder;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 422
424 return { 423 return {
425 reduceAction: reduceAction, 424 reduceAction: reduceAction,
426 ClosedFolderState: ClosedFolderState, 425 ClosedFolderState: ClosedFolderState,
427 NodeState: NodeState, 426 NodeState: NodeState,
428 SearchState: SearchState, 427 SearchState: SearchState,
429 SelectedFolderState: SelectedFolderState, 428 SelectedFolderState: SelectedFolderState,
430 SelectionState: SelectionState, 429 SelectionState: SelectionState,
431 }; 430 };
432 }); 431 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/item.js ('k') | chrome/browser/resources/md_bookmarks/router.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698