Expand externally loaded files

pull/5370/head
ioedeveloper 4 years ago
parent c67c7f77a5
commit a00e0f2332
  1. 8
      libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
  2. 7
      libs/remix-ui/file-explorer/src/lib/reducers/fileSystem.ts

@ -132,6 +132,14 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}, [fileSystem.notification.message])
useEffect(() => {
if (fileSystem.files.expandPath.length > 0) {
setState(prevState => {
return { ...prevState, expandPath: [...new Set([...prevState.expandPath, ...fileSystem.files.expandPath])] }
})
}
}, [fileSystem.files.expandPath])
useEffect(() => {
if (state.focusEdit.element) {
setTimeout(() => {

@ -8,6 +8,7 @@ interface Action {
export const fileSystemInitialState = {
files: {
files: [],
expandPath: [],
workspaceName: null,
blankPath: null,
isRequesting: false,
@ -175,6 +176,7 @@ export const fileSystemReducer = (state = fileSystemInitialState, action: Action
files: {
...state.files,
files: fileAdded(state.files.workspaceName, action.payload.path, state.files.files, action.payload.files),
expandPath: [...new Set([...state.files.expandPath, action.payload.path])],
isRequesting: false,
isSuccessful: true,
error: null
@ -187,6 +189,7 @@ export const fileSystemReducer = (state = fileSystemInitialState, action: Action
files: {
...state.files,
files: folderAdded(state.files.workspaceName, action.payload.path, state.files.files, action.payload.files),
expandPath: [...new Set([...state.files.expandPath, action.payload.path])],
isRequesting: false,
isSuccessful: true,
error: null
@ -271,12 +274,12 @@ const removePath = (root, path: string, pathName, files) => {
}, [])
const prevFiles = _.get(files, _path)
prevFiles.child[pathName] && delete prevFiles.child[pathName]
prevFiles && prevFiles.child && prevFiles.child[pathName] && delete prevFiles.child[pathName]
files = _.set(files, _path, {
isDirectory: true,
path,
name: extractNameFromKey(path),
child: prevFiles.child
child: prevFiles ? prevFiles.child : {}
})
return files

Loading…
Cancel
Save