@@ -7,6 +7,8 @@ import TrashIcon from 'react-icons/lib/md/delete';
77import { Mutation } from 'react-apollo' ;
88import { DropTarget , DragSource } from 'react-dnd' ;
99import track from '@codesandbox/common/lib/utils/analytics' ;
10+ import { withRouter } from 'react-router-dom' ;
11+ import { History } from 'history' ;
1012import { client } from 'app/graphql/client' ;
1113
1214import { Animate as ReactShow } from 'react-show' ;
@@ -60,6 +62,8 @@ type Props = {
6062 isDragging ?: boolean ;
6163 connectDropTarget ?: any ;
6264 connectDragSource ?: any ;
65+
66+ history ?: History ;
6367} ;
6468
6569type State = {
@@ -138,6 +142,7 @@ class FolderEntry extends React.Component<Props, State> {
138142 onSelect,
139143 currentPath,
140144 currentTeamId,
145+ history,
141146 } = this . props ;
142147
143148 const children = getDirectChildren ( path , folders ) ;
@@ -283,6 +288,14 @@ class FolderEntry extends React.Component<Props, State> {
283288 } ,
284289 variables,
285290 } ) ;
291+ const modifiedPath = path
292+ . split ( '/' )
293+ . slice ( 0 , - 1 )
294+ . join ( '/' ) ;
295+
296+ history . replace (
297+ `${ basePath } ${ modifiedPath } /${ input . value } `
298+ ) ;
286299 } ,
287300 } ) ;
288301
@@ -392,8 +405,11 @@ const collectSource = (connect, monitor) => ({
392405 isDragging : monitor . isDragging ( ) ,
393406} ) ;
394407
395- DropFolderEntry = DropTarget ( [ 'SANDBOX' , 'FOLDER' ] , entryTarget , collectTarget ) (
396- DragSource ( 'FOLDER' , entrySource , collectSource ) ( FolderEntry )
397- ) as any ;
408+ DropFolderEntry = ( withRouter (
409+ // @ts -ignore Don't know how to mix dnd and react-router with right typings
410+ DropTarget ( [ 'SANDBOX' , 'FOLDER' ] , entryTarget , collectTarget ) (
411+ DragSource ( 'FOLDER' , entrySource , collectSource ) ( FolderEntry )
412+ )
413+ ) as unknown ) as React . ComponentClass < Props , State > ;
398414
399415export { DropFolderEntry } ;
0 commit comments