selection cleanup
This commit is contained in:
@@ -6,7 +6,6 @@ import UploadQueueOverlay from './UploadQueueOverlay';
|
|||||||
import useDocumentsWorkspace from '../hooks/documents/useDocumentsWorkspace';
|
import useDocumentsWorkspace from '../hooks/documents/useDocumentsWorkspace';
|
||||||
import { useDocumentsPreferences } from './useDocumentsPreferences';
|
import { useDocumentsPreferences } from './useDocumentsPreferences';
|
||||||
import SettingsRoute from './SettingsRoute';
|
import SettingsRoute from './SettingsRoute';
|
||||||
import { WorkspaceSelectionProvider } from './WorkspaceSelectionContext';
|
|
||||||
|
|
||||||
const AppLayout: React.FC = () => {
|
const AppLayout: React.FC = () => {
|
||||||
const documentsPreferences = useDocumentsPreferences();
|
const documentsPreferences = useDocumentsPreferences();
|
||||||
@@ -17,7 +16,6 @@ const AppLayout: React.FC = () => {
|
|||||||
dropOverlayState,
|
dropOverlayState,
|
||||||
managementModals,
|
managementModals,
|
||||||
contextValue,
|
contextValue,
|
||||||
workspaceSelection,
|
|
||||||
settingsOpen,
|
settingsOpen,
|
||||||
closeSettings,
|
closeSettings,
|
||||||
} = useDocumentsWorkspace({
|
} = useDocumentsWorkspace({
|
||||||
@@ -47,7 +45,6 @@ const AppLayout: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WorkspaceSelectionProvider value={workspaceSelection}>
|
|
||||||
<AppShellContext.Provider value={contextValue}>
|
<AppShellContext.Provider value={contextValue}>
|
||||||
<div className="app-shell" ref={shellRef}>
|
<div className="app-shell" ref={shellRef}>
|
||||||
<DropOverlay
|
<DropOverlay
|
||||||
@@ -65,7 +62,6 @@ const AppLayout: React.FC = () => {
|
|||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</AppShellContext.Provider>
|
</AppShellContext.Provider>
|
||||||
</WorkspaceSelectionProvider>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext } from 'react';
|
||||||
import type useWorkspaceSelection from './useWorkspaceSelection';
|
import type useWorkspaceSelection from './useWorkspaceSelection';
|
||||||
|
|
||||||
type WorkspaceSelectionValue = ReturnType<typeof useWorkspaceSelection> | null;
|
export type WorkspaceSelectionValue = ReturnType<typeof useWorkspaceSelection>;
|
||||||
|
|
||||||
const WorkspaceSelectionContext = createContext<WorkspaceSelectionValue>(null);
|
const WorkspaceSelectionContext = createContext<WorkspaceSelectionValue | null>(null);
|
||||||
|
|
||||||
export const WorkspaceSelectionProvider: React.FC<{ value: NonNullable<WorkspaceSelectionValue>; children: React.ReactNode }>
|
interface WorkspaceSelectionProviderProps {
|
||||||
= ({ value, children }) => (
|
value: WorkspaceSelectionValue;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const WorkspaceSelectionProvider: React.FC<WorkspaceSelectionProviderProps> = ({ value, children }) => (
|
||||||
<WorkspaceSelectionContext.Provider value={value}>
|
<WorkspaceSelectionContext.Provider value={value}>
|
||||||
{children}
|
{children}
|
||||||
</WorkspaceSelectionContext.Provider>
|
</WorkspaceSelectionContext.Provider>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
import type { WorkspaceSelectionValue } from '../../app/WorkspaceSelectionContext';
|
||||||
|
|
||||||
type Identifier = string | number;
|
type Identifier = string | number;
|
||||||
|
|
||||||
@@ -72,6 +73,7 @@ export interface UseDocumentsPanelPropsArgs {
|
|||||||
moveDocumentsToFolder?: (...args: unknown[]) => void;
|
moveDocumentsToFolder?: (...args: unknown[]) => void;
|
||||||
documentLinks?: Map<Identifier, DocumentLinkLike>;
|
documentLinks?: Map<Identifier, DocumentLinkLike>;
|
||||||
ensureDownloadUrl?: (documentId: Identifier, options?: { force?: boolean }) => Promise<DocumentLinkLike | null>;
|
ensureDownloadUrl?: (documentId: Identifier, options?: { force?: boolean }) => Promise<DocumentLinkLike | null>;
|
||||||
|
selectionValue: WorkspaceSelectionValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DocumentsPanelProps = ReturnType<typeof useDocumentsPanelProps>;
|
export type DocumentsPanelProps = ReturnType<typeof useDocumentsPanelProps>;
|
||||||
@@ -128,6 +130,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
moveDocumentsToFolder,
|
moveDocumentsToFolder,
|
||||||
documentLinks,
|
documentLinks,
|
||||||
ensureDownloadUrl,
|
ensureDownloadUrl,
|
||||||
|
selectionValue,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
@@ -184,6 +187,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
onMoveDocumentsToFolder: moveDocumentsToFolder,
|
onMoveDocumentsToFolder: moveDocumentsToFolder,
|
||||||
documentLinks,
|
documentLinks,
|
||||||
ensureDownloadUrl,
|
ensureDownloadUrl,
|
||||||
|
selectionValue,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
activeCorrespondentFilters,
|
activeCorrespondentFilters,
|
||||||
@@ -236,6 +240,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
folderOptions,
|
folderOptions,
|
||||||
documentLinks,
|
documentLinks,
|
||||||
ensureDownloadUrl,
|
ensureDownloadUrl,
|
||||||
|
selectionValue,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import DesktopWorkspace from '../../desktop/DesktopWorkspace';
|
|||||||
import { isTagTransferEvent } from '../tagTransfer';
|
import { isTagTransferEvent } from '../tagTransfer';
|
||||||
import PreviewZoomOverlay from '../../detail/PreviewZoomOverlay';
|
import PreviewZoomOverlay from '../../detail/PreviewZoomOverlay';
|
||||||
import { isPointerModifierEvent, isPrimaryPointerEvent } from '../useEntryPointer';
|
import { isPointerModifierEvent, isPrimaryPointerEvent } from '../useEntryPointer';
|
||||||
import { useWorkspaceSelectionContext } from '../../app/WorkspaceSelectionContext';
|
import {
|
||||||
|
WorkspaceSelectionProvider,
|
||||||
|
useWorkspaceSelectionContext,
|
||||||
|
} from '../../app/WorkspaceSelectionContext';
|
||||||
|
import type { WorkspaceSelectionValue } from '../../app/WorkspaceSelectionContext';
|
||||||
import DocumentsPanelHeader, {
|
import DocumentsPanelHeader, {
|
||||||
DocumentsPanelHeaderConfig,
|
DocumentsPanelHeaderConfig,
|
||||||
DocumentsHeaderBreadcrumb,
|
DocumentsHeaderBreadcrumb,
|
||||||
@@ -21,17 +25,21 @@ const EntryType = {
|
|||||||
document: 'document',
|
document: 'document',
|
||||||
};
|
};
|
||||||
|
|
||||||
interface DocumentsPanelProps {
|
interface DocumentsPanelInnerProps {
|
||||||
headerLeading?: ReactNode;
|
headerLeading?: ReactNode;
|
||||||
onBreadcrumbNavigate?: (crumb: DocumentsHeaderBreadcrumb) => void;
|
onBreadcrumbNavigate?: (crumb: DocumentsHeaderBreadcrumb) => void;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface DocumentsPanelProps extends DocumentsPanelInnerProps {
|
||||||
|
selectionValue: WorkspaceSelectionValue;
|
||||||
|
}
|
||||||
|
|
||||||
const defaultGetDocumentAsset = (_doc?: unknown, _type?: string) => null;
|
const defaultGetDocumentAsset = (_doc?: unknown, _type?: string) => null;
|
||||||
|
|
||||||
export type DocumentLinkLike = { url?: string | null; contentType?: string | null };
|
export type DocumentLinkLike = { url?: string | null; contentType?: string | null };
|
||||||
|
|
||||||
const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
||||||
headerLeading = null,
|
headerLeading = null,
|
||||||
onBreadcrumbNavigate,
|
onBreadcrumbNavigate,
|
||||||
currentFolderName,
|
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;
|
export default DocumentsPanel;
|
||||||
|
|||||||
@@ -1539,6 +1539,7 @@ const useDocumentsWorkspace = ({
|
|||||||
selectFolder,
|
selectFolder,
|
||||||
documentLinks,
|
documentLinks,
|
||||||
ensureDownloadUrl,
|
ensureDownloadUrl,
|
||||||
|
selectionValue: selection,
|
||||||
});
|
});
|
||||||
|
|
||||||
const documentsTableProps = useMemo(
|
const documentsTableProps = useMemo(
|
||||||
@@ -1700,7 +1701,6 @@ const useDocumentsWorkspace = ({
|
|||||||
dropOverlayState,
|
dropOverlayState,
|
||||||
managementModals,
|
managementModals,
|
||||||
contextValue,
|
contextValue,
|
||||||
workspaceSelection: selection,
|
|
||||||
settingsOpen,
|
settingsOpen,
|
||||||
closeSettings,
|
closeSettings,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user