Chromium Code Reviews| 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 for functions which produce action objects. These are | 6 * @fileoverview Module for functions which produce action objects. These are |
| 7 * listed in one place to document available actions and their parameters. | 7 * listed in one place to document available actions and their parameters. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('bookmarks.actions', function() { | 10 cr.define('bookmarks.actions', function() { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 */ | 90 */ |
| 91 function refreshNodes(nodeMap) { | 91 function refreshNodes(nodeMap) { |
| 92 return { | 92 return { |
| 93 name: 'refresh-nodes', | 93 name: 'refresh-nodes', |
| 94 nodes: nodeMap, | 94 nodes: nodeMap, |
| 95 }; | 95 }; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @param {string} id | 99 * @param {string} id |
| 100 * @param {NodeList} nodes Current node state. Can be ommitted in tests. | |
|
calamity
2017/04/11 04:13:37
Doesn't omitting this always result in a no-op? Wh
tsergeant
2017/05/02 03:20:24
If nodes is falsey, the check for validity will be
| |
| 100 * @return {!Action} | 101 * @return {!Action} |
| 101 */ | 102 */ |
| 102 function selectFolder(id) { | 103 function selectFolder(id, nodes) { |
| 103 assert(id != '0', 'Cannot select root folder'); | 104 if (nodes && (id == ROOT_NODE_ID || !nodes[id] || nodes[id].url)) { |
| 105 return { | |
| 106 name: 'no-op', | |
| 107 }; | |
|
calamity
2017/04/11 04:13:37
Make no-op a private action and early return in re
tsergeant
2017/05/02 03:20:24
I've replace 'no-op' with returning null, which do
| |
| 108 } | |
| 104 return { | 109 return { |
| 105 name: 'select-folder', | 110 name: 'select-folder', |
| 106 id: id, | 111 id: id, |
| 107 }; | 112 }; |
| 108 } | 113 } |
| 109 | 114 |
| 110 /** | 115 /** |
| 111 * @param {string} id | 116 * @param {string} id |
| 112 * @param {boolean} open | 117 * @param {boolean} open |
| 113 * @return {!Action} | 118 * @return {!Action} |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 moveBookmark: moveBookmark, | 211 moveBookmark: moveBookmark, |
| 207 refreshNodes: refreshNodes, | 212 refreshNodes: refreshNodes, |
| 208 removeBookmark: removeBookmark, | 213 removeBookmark: removeBookmark, |
| 209 reorderChildren: reorderChildren, | 214 reorderChildren: reorderChildren, |
| 210 selectFolder: selectFolder, | 215 selectFolder: selectFolder, |
| 211 selectItem: selectItem, | 216 selectItem: selectItem, |
| 212 setSearchResults: setSearchResults, | 217 setSearchResults: setSearchResults, |
| 213 setSearchTerm: setSearchTerm, | 218 setSearchTerm: setSearchTerm, |
| 214 }; | 219 }; |
| 215 }); | 220 }); |
| OLD | NEW |