This commit is contained in:
2025-11-13 14:07:31 +01:00
parent 18558ab087
commit 62e44b5375
10 changed files with 152 additions and 132 deletions
+8 -4
View File
@@ -6,6 +6,7 @@ import UploadQueueOverlay from './UploadQueueOverlay';
import useDocumentsWorkspace from '../hooks/documents/useDocumentsWorkspace';
import { useDocumentsPreferences } from './useDocumentsPreferences';
import SettingsRoute from './SettingsRoute';
import { WorkspaceSelectionProvider } from './WorkspaceSelectionContext';
const AppLayout: React.FC = () => {
const documentsPreferences = useDocumentsPreferences();
@@ -16,6 +17,7 @@ const AppLayout: React.FC = () => {
dropOverlayState,
managementModals,
contextValue,
workspaceSelection,
settingsOpen,
closeSettings,
} = useDocumentsWorkspace({
@@ -50,8 +52,9 @@ const AppLayout: React.FC = () => {
}
return (
<AppShellContext.Provider value={contextValue}>
<div className="app-shell" ref={shellRef}>
<WorkspaceSelectionProvider value={workspaceSelection}>
<AppShellContext.Provider value={contextValue}>
<div className="app-shell" ref={shellRef}>
<DropOverlay
active={dropOverlayState.active}
folderName={dropOverlayState.folderName}
@@ -65,8 +68,9 @@ const AppLayout: React.FC = () => {
{settingsOpen ? (
<SettingsRoute open onClose={closeSettings} />
) : null}
</div>
</AppShellContext.Provider>
</div>
</AppShellContext.Provider>
</WorkspaceSelectionProvider>
);
};
@@ -0,0 +1,23 @@
import React, { createContext, useContext } from 'react';
import type useWorkspaceSelection from './useWorkspaceSelection';
type WorkspaceSelectionValue = ReturnType<typeof useWorkspaceSelection> | null;
const WorkspaceSelectionContext = createContext<WorkspaceSelectionValue>(null);
export const WorkspaceSelectionProvider: React.FC<{ value: NonNullable<WorkspaceSelectionValue>; children: React.ReactNode }>
= ({ value, children }) => (
<WorkspaceSelectionContext.Provider value={value}>
{children}
</WorkspaceSelectionContext.Provider>
);
export const useWorkspaceSelectionContext = () => {
const context = useContext(WorkspaceSelectionContext);
if (!context) {
throw new Error('useWorkspaceSelectionContext must be used within a WorkspaceSelectionProvider');
}
return context;
};
export default WorkspaceSelectionContext;