diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e34383a..1b272288 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [10.x.x] - 2024-xx-xx +### 🎨 Enhancements + +- [#878](https://github.com/estruyf/vscode-front-matter/issues/878): Allow the `select all` button to work on other pages when there is a selection present + ### 🐞 Fixes - [#876](https://github.com/estruyf/vscode-front-matter/issues/876): Fix snippet type on the snippet card diff --git a/src/dashboardWebView/components/Common/ItemSelection.tsx b/src/dashboardWebView/components/Common/ItemSelection.tsx index eeda2de4..13f9a99d 100644 --- a/src/dashboardWebView/components/Common/ItemSelection.tsx +++ b/src/dashboardWebView/components/Common/ItemSelection.tsx @@ -25,6 +25,9 @@ export const ItemSelection: React.FunctionComponent = ({
{ + e.stopPropagation(); + }} onChange={() => { onMultiSelect(filePath); }} diff --git a/src/dashboardWebView/components/Header/ActionsBar.tsx b/src/dashboardWebView/components/Header/ActionsBar.tsx index 612a7f17..8035a773 100644 --- a/src/dashboardWebView/components/Header/ActionsBar.tsx +++ b/src/dashboardWebView/components/Header/ActionsBar.tsx @@ -4,8 +4,7 @@ import { CommandLineIcon, PencilIcon, TrashIcon, ChevronDownIcon, XMarkIcon, Eye import { useRecoilState, useRecoilValue } from 'recoil'; import { MultiSelectedItemsAtom, PagedItems, SelectedItemActionAtom, SelectedMediaFolderSelector, SettingsSelector } from '../../state'; import { ActionsBarItem } from './ActionsBarItem'; -import * as l10n from '@vscode/l10n'; -import { LocalizationKey } from '../../../localization'; +import { LocalizationKey, localize } from '../../../localization'; import { Alert } from '../Modals/Alert'; import { messageHandler } from '@estruyf/vscode/dist/client'; import { DashboardMessage } from '../../DashboardMessage'; @@ -68,8 +67,14 @@ export const ActionsBar: React.FunctionComponent = ({ }, [selectedFiles]); const selectAllItems = React.useCallback(() => { - setSelectedFiles([...pagedItems]); - }, [pagedItems]); + const allSelected = [...selectedFiles, ...pagedItems]; + setSelectedFiles(Array.from(new Set(allSelected))); + }, [selectedFiles, pagedItems]); + + const hasAllItemsSelectedOnPage = React.useMemo(() => { + const selectedItemsOnPage = selectedFiles.filter((file) => pagedItems.includes(file)); + return selectedItemsOnPage.length >= pagedItems.length; + }, [selectedFiles, pagedItems]); const languageActions = React.useMemo(() => { const actions: React.ReactNode[] = []; @@ -92,7 +97,7 @@ export const ActionsBar: React.FunctionComponent = ({ }) }}> - {l10n.t(LocalizationKey.commonTranslate)} + {localize(LocalizationKey.commonTranslate)} ) @@ -107,7 +112,7 @@ export const ActionsBar: React.FunctionComponent = ({ className='flex items-center text-[var(--vscode-tab-inactiveForeground)] hover:text-[var(--vscode-tab-activeForeground)]' > - {l10n.t(LocalizationKey.commonLanguages)} + {localize(LocalizationKey.commonLanguages)} @@ -163,7 +168,7 @@ export const ActionsBar: React.FunctionComponent = ({ disabled={selectedFiles.length === 0} > - {l10n.t(LocalizationKey.commonScripts)} + {localize(LocalizationKey.commonScripts)} @@ -197,10 +202,10 @@ export const ActionsBar: React.FunctionComponent = ({ 1} onClick={viewFile} - title={l10n.t(LocalizationKey.commonView)} + title={localize(LocalizationKey.commonView)} > { @@ -211,10 +216,10 @@ export const ActionsBar: React.FunctionComponent = ({ messageHandler.send(DashboardMessage.rename, selectedFiles[0]); setSelectedFiles([]); }} - title={l10n.t(LocalizationKey.commonRename)} + title={localize(LocalizationKey.commonRename)} >
@@ -258,33 +263,33 @@ export const ActionsBar: React.FunctionComponent = ({ setSelectedFiles([])} - title={l10n.t(LocalizationKey.dashboardHeaderActionsBarItemsSelected, selectedFiles.length)} + title={localize(LocalizationKey.dashboardHeaderActionsBarItemsSelected, selectedFiles.length)} > ) }
- {l10n.t(LocalizationKey.dashboardHeaderActionsBarSelectAll)} + {localize(LocalizationKey.dashboardHeaderActionsBarSelectAll)}
{showAlert && ( setShowAlert(false)} trigger={onDeleteConfirm} />