expand folder path from event fired

pull/1575/head
ioedeveloper 3 years ago
parent 6ddd5f5b2f
commit dc1f9d0698
  1. 3
      libs/remix-ui/workspace/src/lib/actions/events.ts
  2. 4
      libs/remix-ui/workspace/src/lib/actions/payload.ts
  3. 6
      libs/remix-ui/workspace/src/lib/reducers/workspace.ts

@ -139,7 +139,8 @@ const folderAdded = async (folderPath: string) => {
})
promise.then((files) => {
dispatch(folderAddedSuccess(path, files))
folderPath = folderPath.replace(/^\/+/, '')
dispatch(folderAddedSuccess(path, folderPath, files))
}).catch((error) => {
console.error(error)
})

@ -62,10 +62,10 @@ export const fileAddedSuccess = (filePath: string) => {
}
}
export const folderAddedSuccess = (folderPath: string, fileTree) => {
export const folderAddedSuccess = (path: string, folderPath: string, fileTree) => {
return {
type: 'FOLDER_ADDED_SUCCESS',
payload: { path: folderPath, fileTree }
payload: { path, folderPath, fileTree }
}
}

@ -286,19 +286,19 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
}
case 'FOLDER_ADDED_SUCCESS': {
const payload = action.payload as { path: string, fileTree }
const payload = action.payload as { path: string, folderPath: string, fileTree }
return {
...state,
browser: {
...state.browser,
files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files,
expandPath: state.mode === 'browser' ? [...new Set([...state.browser.expandPath, payload.path])] : state.browser.expandPath
expandPath: state.mode === 'browser' ? [...new Set([...state.browser.expandPath, payload.folderPath])] : state.browser.expandPath
},
localhost: {
...state.localhost,
files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files,
expandPath: state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload.path])] : state.localhost.expandPath
expandPath: state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload.folderPath])] : state.localhost.expandPath
}
}
}

Loading…
Cancel
Save