From 35855096a8abd6e5d5d9267b7377021f473009c9 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 28 Sep 2021 03:24:06 +0100 Subject: [PATCH] expand folder path from event fired --- libs/remix-ui/workspace/src/lib/actions/events.ts | 3 ++- libs/remix-ui/workspace/src/lib/actions/payload.ts | 4 ++-- libs/remix-ui/workspace/src/lib/reducers/workspace.ts | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts index 30a9208a14..8e021def35 100644 --- a/libs/remix-ui/workspace/src/lib/actions/events.ts +++ b/libs/remix-ui/workspace/src/lib/actions/events.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) }) diff --git a/libs/remix-ui/workspace/src/lib/actions/payload.ts b/libs/remix-ui/workspace/src/lib/actions/payload.ts index 75a55c962c..5f7a708c29 100644 --- a/libs/remix-ui/workspace/src/lib/actions/payload.ts +++ b/libs/remix-ui/workspace/src/lib/actions/payload.ts @@ -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 } } } diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index 4aac385368..47c7543354 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -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 } } }