From 80cf23cea5312c31627c3173e6566d012ddbcefd Mon Sep 17 00:00:00 2001 From: Julian Waller Date: Fri, 24 Jan 2025 22:30:53 +0000 Subject: [PATCH] fix: show page name of single page during import #3227 --- webui/src/ImportExport/Import/Page.tsx | 38 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/webui/src/ImportExport/Import/Page.tsx b/webui/src/ImportExport/Import/Page.tsx index 79a8abbb3..5f038d35c 100644 --- a/webui/src/ImportExport/Import/Page.tsx +++ b/webui/src/ImportExport/Import/Page.tsx @@ -38,20 +38,30 @@ export const ImportPageWizard = observer(function ImportPageWizard({ const isSinglePage = snapshot.type === 'page' const [snapshotPageOptions, pageCount] = useMemo(() => { - const snapshotPageOptions: PageNumberOption[] = [] - let pageCount = 0 - for (const [pageNumber, pageInfo] of Object.entries(snapshot.pages ?? {})) { - const pageNumberInt = parseInt(pageNumber) - pageCount = Math.max(pageCount, pageNumberInt) - - snapshotPageOptions.push({ - value: pageNumberInt, - label: pageInfo.name ? `${pageNumberInt} (${pageInfo.name})` : `${pageNumberInt}`, - }) + if (isSinglePage) { + const snapshotPageOptions: PageNumberOption[] = [ + { + value: 1, + label: snapshot.page?.name ? `1 (${snapshot.page.name})` : '1', + }, + ] + return [snapshotPageOptions, 1] + } else { + const snapshotPageOptions: PageNumberOption[] = [] + let pageCount = 0 + for (const [pageNumber, pageInfo] of Object.entries(snapshot.pages ?? {})) { + const pageNumberInt = parseInt(pageNumber) + pageCount = Math.max(pageCount, pageNumberInt) + + snapshotPageOptions.push({ + value: pageNumberInt, + label: pageInfo.name ? `${pageNumberInt} (${pageInfo.name})` : `${pageNumberInt}`, + }) + } + + return [snapshotPageOptions, pageCount] } - - return [snapshotPageOptions, pageCount] - }, [snapshot.pages]) + }, [snapshot.pages, snapshot.page, isSinglePage]) const { pageNumber, setPageNumber, changePage } = usePagePicker(pages.data.length, 1) const { @@ -95,6 +105,8 @@ export const ImportPageWizard = observer(function ImportPageWizard({ const [gridZoomController, gridZoomValue] = useGridZoom('import') + console.log('sn', snapshotPageOptions, snapshot) + return (