( state: RightSidebarLayoutState, tab: TabType )
| 230 | } |
| 231 | |
| 232 | export function removeTabEverywhere( |
| 233 | state: RightSidebarLayoutState, |
| 234 | tab: TabType |
| 235 | ): RightSidebarLayoutState { |
| 236 | const nextRoot = removeTabFromNode(state.root, tab); |
| 237 | if (!nextRoot) { |
| 238 | return getDefaultRightSidebarLayoutState("costs"); |
| 239 | } |
| 240 | |
| 241 | const focusedExists = findTabset(nextRoot, state.focusedTabsetId) !== null; |
| 242 | const focusedTabsetId = focusedExists |
| 243 | ? state.focusedTabsetId |
| 244 | : (findFirstTabsetId(nextRoot) ?? "tabset-1"); |
| 245 | |
| 246 | return { |
| 247 | ...state, |
| 248 | root: nextRoot, |
| 249 | focusedTabsetId, |
| 250 | }; |
| 251 | } |
| 252 | function updateNode( |
| 253 | node: RightSidebarLayoutNode, |
| 254 | tabsetId: string, |
no test coverage detected