diff --git a/frontend/src/app/DocumentsRoute.tsx b/frontend/src/app/DocumentsRoute.tsx index 1c68262..35bc944 100644 --- a/frontend/src/app/DocumentsRoute.tsx +++ b/frontend/src/app/DocumentsRoute.tsx @@ -190,16 +190,7 @@ const DocumentsRouteContent: React.FC = () => { actions={header.actions} /> - {(header.selectionLabel || header.floatingActions) ? ( -
-
- {header.selectionLabel ? ( - {header.selectionLabel} - ) : null} - {header.floatingActions || null} -
-
- ) : null} + {(header.floatingActions)} ) : null}
{surface.content}
diff --git a/frontend/src/desktop/createDesktopSurface.tsx b/frontend/src/desktop/createDesktopSurface.tsx index 204a6d4..3a6fd02 100644 --- a/frontend/src/desktop/createDesktopSurface.tsx +++ b/frontend/src/desktop/createDesktopSurface.tsx @@ -1,30 +1,9 @@ import React, { ReactNode } from 'react'; -import SelectionFloatingActions from '../documents/SelectionFloatingActions'; +import { SelectionFloatingPanel } from '../documents/SelectionFloatingActions'; import { createDocumentsTableHeaderActions } from '../documents/DocumentsPanel'; import createWorkspaceSurfaceConfig from '../documents/workspaceHeader'; import DocumentViewerPanel from '../preview/DocumentViewerPanel'; import DesktopWorkspace from './DesktopWorkspace'; -import { useWorkspaceSelectionContext } from '../app/WorkspaceSelectionContext'; - -type SelectionFloatingActionsBaseProps = Omit, 'selectionCount' | 'selectedDocumentIds' | 'selectedFolderIds'>; - -const SelectionFloatingActionsWithSelection: React.FC = (props) => { - const { selectedDocumentIds, selectedFolderIds } = useWorkspaceSelectionContext(); - const documentIds = Array.isArray(selectedDocumentIds) ? selectedDocumentIds : []; - const folderIds = Array.isArray(selectedFolderIds) ? selectedFolderIds : []; - const selectionCount = documentIds.length + folderIds.length; - if (selectionCount === 0) { - return null; - } - return ( - - ); -}; type WorkspaceProps = Record; @@ -58,7 +37,6 @@ const createDesktopSurface = ({ viewMode, onViewModeChange, onDeleteSelection, - onClearSelection, tags, correspondents, documentLookup, @@ -88,7 +66,7 @@ const createDesktopSurface = ({ }); const floatingActions = ( - diff --git a/frontend/src/documents/SelectionFloatingActions.tsx b/frontend/src/documents/SelectionFloatingActions.tsx index a1866b5..04f5f59 100644 --- a/frontend/src/documents/SelectionFloatingActions.tsx +++ b/frontend/src/documents/SelectionFloatingActions.tsx @@ -11,6 +11,7 @@ import { import SelectionAssignmentMenu, { SelectionAssignmentMenuItem } from './SelectionAssignmentMenu'; import SelectionSummary from './SelectionSummary'; import { api, useAppState } from '../app/appState'; +import { useWorkspaceSelectionContext } from '../app/WorkspaceSelectionContext'; const ROOT_FOLDER_LABEL = 'Documents'; @@ -64,7 +65,7 @@ interface BulkCorrespondentRemoveArgs { documentIds: DocumentId[]; } -interface SelectionFloatingActionsProps { +export interface SelectionFloatingActionsProps { selectionCount?: number; selectedDocumentIds?: SelectedIdList; selectedFolderIds?: SelectedIdList; @@ -616,4 +617,31 @@ const SelectionFloatingActions: React.FC = ({ ); }; +export type SelectionFloatingPanelProps = Omit; + +export const SelectionFloatingPanel: React.FC = ({ onClearSelection, ...rest }) => { + const { selectedDocumentIds, selectedFolderIds, clearSelection } = useWorkspaceSelectionContext(); + const documentIds = Array.isArray(selectedDocumentIds) ? selectedDocumentIds : []; + const folderIds = Array.isArray(selectedFolderIds) ? selectedFolderIds : []; + const selectionCount = documentIds.length + folderIds.length; + if (selectionCount === 0) { + return null; + } + const handleClear = onClearSelection || clearSelection; + return ( +
+
+ +
+
+ ); +}; + + export default SelectionFloatingActions; diff --git a/frontend/src/documents/panel/createDocumentsSurface.tsx b/frontend/src/documents/panel/createDocumentsSurface.tsx index 171c831..d1ab460 100644 --- a/frontend/src/documents/panel/createDocumentsSurface.tsx +++ b/frontend/src/documents/panel/createDocumentsSurface.tsx @@ -1,30 +1,9 @@ import React, { ReactNode } from 'react'; import DocumentViewerPanel from '../../preview/DocumentViewerPanel'; -import SelectionFloatingActions from '../SelectionFloatingActions'; import createWorkspaceSurfaceConfig from '../workspaceHeader'; import DocumentsPanel from './DocumentsPanel'; +import { SelectionFloatingPanel } from '../SelectionFloatingActions'; import { createDocumentsTableHeaderActions } from './DocumentsToolbar'; -import { useWorkspaceSelectionContext } from '../../app/WorkspaceSelectionContext'; - -type SelectionFloatingActionsBaseProps = Omit, 'selectionCount' | 'selectedDocumentIds' | 'selectedFolderIds'>; - -const SelectionFloatingActionsWithSelection: React.FC = (props) => { - const { selectedDocumentIds, selectedFolderIds } = useWorkspaceSelectionContext(); - const documentIds = Array.isArray(selectedDocumentIds) ? selectedDocumentIds : []; - const folderIds = Array.isArray(selectedFolderIds) ? selectedFolderIds : []; - const selectionCount = documentIds.length + folderIds.length; - if (selectionCount === 0) { - return null; - } - return ( - - ); -}; interface CreateDocumentsSurfaceArgs { tableProps: Record; @@ -52,7 +31,6 @@ const createDocumentsSurface = ({ onSortFieldChange, onSortDirectionToggle, onDeleteSelection, - onClearSelection, tags, correspondents, documentLookup, @@ -88,7 +66,7 @@ const createDocumentsSurface = ({ }); const floatingActions = ( -