Skip to content

Commit

Permalink
TASK: Move DndProvider into new DndContextProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebobo committed Feb 12, 2024
1 parent 8fa60a2 commit b08ae00
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { useCallback, useState, createContext, useContext } from 'react';
import { DndProvider } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';

import { useIntl, useNotify } from '@media-ui/core';

Expand Down Expand Up @@ -103,16 +105,18 @@ export function AssetCollectionTreeDndProvider({ children }: AssetCollectionTree
);

return (
<AssetCollectionDndContext.Provider
value={{
currentlyDraggedNodes,
handleDrag,
handeEndDrag,
handleDrop,
acceptsDraggedNode,
}}
>
{children}
</AssetCollectionDndContext.Provider>
<DndProvider backend={HTML5Backend}>
<AssetCollectionDndContext.Provider
value={{
currentlyDraggedNodes,
handleDrag,
handeEndDrag,
handleDrop,
acceptsDraggedNode,
}}
>
{children}
</AssetCollectionDndContext.Provider>
</DndProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { neos } from '@neos-project/neos-ui-decorators';
import { actions } from '@neos-project/neos-ui-redux-store';

// Media UI dependencies
// GraphQL type definitions
import { MediaUiProvider, typeDefs as TYPE_DEFS_CORE } from '@media-ui/core';
import MediaApplicationWrapper from '@media-ui/core/src/components/MediaApplicationWrapper';
import { AssetCollectionTreeDndProvider } from '@media-ui/feature-asset-collections/src/provider/AssetCollectionTreeDndProvider';
import { MediaUiProvider, typeDefs as TYPE_DEFS_CORE } from '@media-ui/core';
import { CacheFactory, createErrorHandler } from '@media-ui/media-module/src/core';
import { Details } from './components';
import { typeDefs as TYPE_DEFS_ASSET_USAGE } from '@media-ui/feature-asset-usage';

// GraphQL local resolvers
// Package local dependencies
import { Details } from './components';
import { MediaDetailsScreenApprovalAttainmentStrategyFactory } from './strategy';

import classes from './MediaDetailsScreen.module.css';
Expand Down Expand Up @@ -147,7 +147,9 @@ export class MediaDetailsScreen extends React.PureComponent<MediaDetailsScreenPr
containerRef={containerRef}
approvalAttainmentStrategyFactory={MediaDetailsScreenApprovalAttainmentStrategyFactory}
>
<Details buildLinkToMediaUi={buildLinkToMediaUi} />
<AssetCollectionTreeDndProvider>
<Details buildLinkToMediaUi={buildLinkToMediaUi} />
</AssetCollectionTreeDndProvider>
</MediaUiProvider>
</MediaApplicationWrapper>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import cx from 'classnames';
import { InteractionDialogRenderer, useMediaUi } from '@media-ui/core';
import { useAssetQuery } from '@media-ui/core/src/hooks';
import { AssetUsagesModal, assetUsageDetailsModalState } from '@media-ui/feature-asset-usage';
import { ClipboardWatcher } from '@media-ui/feature-clipboard';
import { ConcurrentChangeMonitor } from '@media-ui/feature-concurrent-editing';
import { SimilarAssetsModal, similarAssetsModalState } from '@media-ui/feature-similar-assets';
import { uploadDialogState } from '@media-ui/feature-asset-upload/src/state';
import { UploadDialog } from '@media-ui/feature-asset-upload/src/components';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IconButton } from '@neos-project/react-ui-components';

import { useIntl } from '@media-ui/core';
import { clipboardItemState } from '@media-ui/feature-clipboard';
import DownloadAssetButton from 'Resources/Private/JavaScript/media-module/src/components/Actions/DownloadAssetButton';
import DownloadAssetButton from '@media-ui/media-module/src/components/Actions/DownloadAssetButton';

interface PreviewActionsProps {
asset: Asset;
Expand Down
12 changes: 4 additions & 8 deletions Resources/Private/JavaScript/media-module/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import React, { createRef } from 'react';
import { render } from 'react-dom';
import Modal from 'react-modal';
import { DndProvider } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';
import { ApolloClient, ApolloLink } from '@apollo/client';
import { createUploadLink } from 'apollo-upload-client';

// GraphQL type definitions
import { MediaUiProvider, typeDefs as TYPE_DEFS_CORE } from '@media-ui/core';
import MediaApplicationWrapper from '@media-ui/core/src/components/MediaApplicationWrapper';
import { typeDefs as TYPE_DEFS_ASSET_USAGE } from '@media-ui/feature-asset-usage';
import { AssetCollectionTreeDndProvider } from '@media-ui/feature-asset-collections/src/provider/AssetCollectionTreeDndProvider';

// Internal dependencies
import { CacheFactory, createErrorHandler } from './core';
import App from './components/App';
import ErrorBoundary from './components/ErrorBoundary';
import loadIconLibrary from './lib/FontAwesome';
import { AssetCollectionTreeDndProvider } from '@media-ui/feature-asset-collections/src/provider/AssetCollectionTreeDndProvider';

loadIconLibrary();

Expand Down Expand Up @@ -73,11 +71,9 @@ window.onload = async (): Promise<void> => {
>
<ErrorBoundary>
<MediaUiProvider dummyImage={dummyImage} containerRef={containerRef}>
<DndProvider backend={HTML5Backend}>
<AssetCollectionTreeDndProvider>
<App />
</AssetCollectionTreeDndProvider>
</DndProvider>
<AssetCollectionTreeDndProvider>
<App />
</AssetCollectionTreeDndProvider>
</MediaUiProvider>
</ErrorBoundary>
</MediaApplicationWrapper>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import MediaApplicationWrapper from '@media-ui/core/src/components/MediaApplicat
import { CacheFactory, createErrorHandler } from '@media-ui/media-module/src/core';
import App from '@media-ui/media-module/src/components/App';
import { typeDefs as TYPE_DEFS_ASSET_USAGE } from '@media-ui/feature-asset-usage';
import { AssetCollectionTreeDndProvider } from '@media-ui/feature-asset-collections/src/provider/AssetCollectionTreeDndProvider';

import classes from './MediaSelectionScreen.module.css';

Expand Down Expand Up @@ -161,7 +162,9 @@ class MediaSelectionScreen extends React.PureComponent<MediaSelectionScreenProps
isInNodeCreationDialog={isInNodeCreationDialog}
containerRef={containerRef}
>
<App />
<AssetCollectionTreeDndProvider>
<App />
</AssetCollectionTreeDndProvider>
</MediaUiProvider>
</MediaApplicationWrapper>
</div>
Expand Down

0 comments on commit b08ae00

Please sign in to comment.