OLD | NEW |
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 /** | 233 /** |
234 * @param {?string} selectedFolder | 234 * @param {?string} selectedFolder |
235 * @param {Action} action | 235 * @param {Action} action |
236 * @param {NodeList} nodes | 236 * @param {NodeList} nodes |
237 * @return {?string} | 237 * @return {?string} |
238 */ | 238 */ |
239 SelectedFolderState.updateSelectedFolder = function( | 239 SelectedFolderState.updateSelectedFolder = function( |
240 selectedFolder, action, nodes) { | 240 selectedFolder, action, nodes) { |
241 // TODO(tsergeant): It should not be possible to select a non-folder. | 241 // TODO(tsergeant): It should not be possible to select a non-folder. |
| 242 // TODO(tsergeant): Select parent folder when selected folder is deleted. |
242 switch (action.name) { | 243 switch (action.name) { |
243 case 'select-folder': | 244 case 'select-folder': |
244 return action.id; | 245 return action.id; |
245 case 'change-folder-open': | 246 case 'change-folder-open': |
246 // When hiding the selected folder by closing its ancestor, select | 247 // When hiding the selected folder by closing its ancestor, select |
247 // that ancestor instead. | 248 // that ancestor instead. |
248 if (!action.open && selectedFolder && | 249 if (!action.open && selectedFolder && |
249 SelectedFolderState.isAncestorOf( | 250 SelectedFolderState.isAncestorOf( |
250 nodes, action.id, selectedFolder)) { | 251 nodes, action.id, selectedFolder)) { |
251 return action.id; | 252 return action.id; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 344 |
344 return { | 345 return { |
345 reduceAction: reduceAction, | 346 reduceAction: reduceAction, |
346 ClosedFolderState: ClosedFolderState, | 347 ClosedFolderState: ClosedFolderState, |
347 NodeState: NodeState, | 348 NodeState: NodeState, |
348 SearchState: SearchState, | 349 SearchState: SearchState, |
349 SelectedFolderState: SelectedFolderState, | 350 SelectedFolderState: SelectedFolderState, |
350 SelectionState: SelectionState, | 351 SelectionState: SelectionState, |
351 }; | 352 }; |
352 }); | 353 }); |
OLD | NEW |