selection cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import type { WorkspaceSelectionValue } from '../../app/WorkspaceSelectionContext';
|
||||
|
||||
type Identifier = string | number;
|
||||
|
||||
@@ -72,6 +73,7 @@ export interface UseDocumentsPanelPropsArgs {
|
||||
moveDocumentsToFolder?: (...args: unknown[]) => void;
|
||||
documentLinks?: Map<Identifier, DocumentLinkLike>;
|
||||
ensureDownloadUrl?: (documentId: Identifier, options?: { force?: boolean }) => Promise<DocumentLinkLike | null>;
|
||||
selectionValue: WorkspaceSelectionValue;
|
||||
}
|
||||
|
||||
export type DocumentsPanelProps = ReturnType<typeof useDocumentsPanelProps>;
|
||||
@@ -128,6 +130,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
||||
moveDocumentsToFolder,
|
||||
documentLinks,
|
||||
ensureDownloadUrl,
|
||||
selectionValue,
|
||||
} = props;
|
||||
|
||||
return useMemo(
|
||||
@@ -184,6 +187,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
||||
onMoveDocumentsToFolder: moveDocumentsToFolder,
|
||||
documentLinks,
|
||||
ensureDownloadUrl,
|
||||
selectionValue,
|
||||
}),
|
||||
[
|
||||
activeCorrespondentFilters,
|
||||
@@ -236,6 +240,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
||||
folderOptions,
|
||||
documentLinks,
|
||||
ensureDownloadUrl,
|
||||
selectionValue,
|
||||
],
|
||||
);
|
||||
};
|
||||
|
||||
@@ -6,7 +6,11 @@ import DesktopWorkspace from '../../desktop/DesktopWorkspace';
|
||||
import { isTagTransferEvent } from '../tagTransfer';
|
||||
import PreviewZoomOverlay from '../../detail/PreviewZoomOverlay';
|
||||
import { isPointerModifierEvent, isPrimaryPointerEvent } from '../useEntryPointer';
|
||||
import { useWorkspaceSelectionContext } from '../../app/WorkspaceSelectionContext';
|
||||
import {
|
||||
WorkspaceSelectionProvider,
|
||||
useWorkspaceSelectionContext,
|
||||
} from '../../app/WorkspaceSelectionContext';
|
||||
import type { WorkspaceSelectionValue } from '../../app/WorkspaceSelectionContext';
|
||||
import DocumentsPanelHeader, {
|
||||
DocumentsPanelHeaderConfig,
|
||||
DocumentsHeaderBreadcrumb,
|
||||
@@ -21,17 +25,21 @@ const EntryType = {
|
||||
document: 'document',
|
||||
};
|
||||
|
||||
interface DocumentsPanelProps {
|
||||
interface DocumentsPanelInnerProps {
|
||||
headerLeading?: ReactNode;
|
||||
onBreadcrumbNavigate?: (crumb: DocumentsHeaderBreadcrumb) => void;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface DocumentsPanelProps extends DocumentsPanelInnerProps {
|
||||
selectionValue: WorkspaceSelectionValue;
|
||||
}
|
||||
|
||||
const defaultGetDocumentAsset = (_doc?: unknown, _type?: string) => null;
|
||||
|
||||
export type DocumentLinkLike = { url?: string | null; contentType?: string | null };
|
||||
|
||||
const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
||||
headerLeading = null,
|
||||
onBreadcrumbNavigate,
|
||||
currentFolderName,
|
||||
@@ -825,4 +833,10 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
const DocumentsPanel: React.FC<DocumentsPanelProps> = ({ selectionValue, ...rest }) => (
|
||||
<WorkspaceSelectionProvider value={selectionValue}>
|
||||
<DocumentsPanelInner {...rest} />
|
||||
</WorkspaceSelectionProvider>
|
||||
);
|
||||
|
||||
export default DocumentsPanel;
|
||||
|
||||
Reference in New Issue
Block a user