({ totalFolders, totalFiles, itemsPerPage, targetPage })
| 1987 | } |
| 1988 | |
| 1989 | function getCombinedPageLayout({ totalFolders, totalFiles, itemsPerPage, targetPage }) { |
| 1990 | const folderCount = Number.isFinite(Number(totalFolders)) ? Math.max(0, Number(totalFolders)) : 0; |
| 1991 | const fileCount = Number.isFinite(Number(totalFiles)) ? Math.max(0, Number(totalFiles)) : 0; |
| 1992 | const itemsRaw = Number(itemsPerPage); |
| 1993 | const pageSize = Number.isFinite(itemsRaw) && itemsRaw > 0 ? Math.max(1, Math.floor(itemsRaw)) : 50; |
| 1994 | const totalRows = folderCount + fileCount; |
| 1995 | const totalPages = Math.max(1, Math.ceil(totalRows / pageSize) || 1); |
| 1996 | const targetRaw = Number(targetPage); |
| 1997 | const page = Number.isFinite(targetRaw) |
| 1998 | ? Math.max(1, Math.min(totalPages, Math.floor(targetRaw))) |
| 1999 | : 1; |
| 2000 | const startRow = (page - 1) * pageSize; |
| 2001 | const endRow = Math.min(totalRows, startRow + pageSize); |
| 2002 | |
| 2003 | const folderStart = Math.min(folderCount, startRow); |
| 2004 | const folderEnd = Math.min(folderCount, endRow); |
| 2005 | const folderCountOnPage = Math.max(0, folderEnd - folderStart); |
| 2006 | |
| 2007 | const fileStart = Math.max(0, startRow - folderCount); |
| 2008 | const fileEnd = Math.max(0, endRow - folderCount); |
| 2009 | const fileCountOnPage = Math.max(0, fileEnd - fileStart); |
| 2010 | |
| 2011 | return { |
| 2012 | page, |
| 2013 | totalPages, |
| 2014 | pageSize, |
| 2015 | totalRows, |
| 2016 | folderStart, |
| 2017 | folderCount: folderCountOnPage, |
| 2018 | fileStart, |
| 2019 | fileCount: fileCountOnPage |
| 2020 | }; |
| 2021 | } |
| 2022 | |
| 2023 | function resolveServerPagingCursorForLoad({ pane, folder, sourceId, requestedCursor }) { |
| 2024 | if (requestedCursor != null) { |
no outgoing calls
no test coverage detected