|
|
@ -40,21 +40,22 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
isNew: false, |
|
|
|
isNew: false, |
|
|
|
lastEdit: '' |
|
|
|
lastEdit: '' |
|
|
|
}, |
|
|
|
}, |
|
|
|
expandPath: [], |
|
|
|
expandPath: [name], |
|
|
|
modalOptions: { |
|
|
|
focusModal: { |
|
|
|
hide: true, |
|
|
|
hide: true, |
|
|
|
title: '', |
|
|
|
title: '', |
|
|
|
message: '', |
|
|
|
message: '', |
|
|
|
ok: { |
|
|
|
ok: { |
|
|
|
label: 'Ok', |
|
|
|
label: '', |
|
|
|
fn: null |
|
|
|
fn: () => {} |
|
|
|
}, |
|
|
|
}, |
|
|
|
cancel: { |
|
|
|
cancel: { |
|
|
|
label: 'Cancel', |
|
|
|
label: '', |
|
|
|
fn: null |
|
|
|
fn: () => {} |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleHide: null |
|
|
|
handleHide: null |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
modals: [], |
|
|
|
toasterMsg: '' |
|
|
|
toasterMsg: '' |
|
|
|
}) |
|
|
|
}) |
|
|
|
const editRef = useRef(null) |
|
|
|
const editRef = useRef(null) |
|
|
@ -196,6 +197,28 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
}, [externalUploads]) |
|
|
|
}, [externalUploads]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if (state.modals.length > 0) { |
|
|
|
|
|
|
|
setState(prevState => { |
|
|
|
|
|
|
|
const focusModal = { |
|
|
|
|
|
|
|
hide: false, |
|
|
|
|
|
|
|
title: prevState.modals[0].title, |
|
|
|
|
|
|
|
message: prevState.modals[0].message, |
|
|
|
|
|
|
|
ok: prevState.modals[0].ok, |
|
|
|
|
|
|
|
cancel: prevState.modals[0].cancel, |
|
|
|
|
|
|
|
handleHide: prevState.modals[0].handleHide |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prevState.modals.shift() |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...prevState, |
|
|
|
|
|
|
|
focusModal, |
|
|
|
|
|
|
|
modals: prevState.modals |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, [state.modals]) |
|
|
|
|
|
|
|
|
|
|
|
const resolveDirectory = async (folderPath, dir: File[], isChild = false): Promise<File[]> => { |
|
|
|
const resolveDirectory = async (folderPath, dir: File[], isChild = false): Promise<File[]> => { |
|
|
|
if (!isChild && (state.focusEdit.element === 'browser/blank') && state.focusEdit.isNew && (dir.findIndex(({ path }) => path === 'browser/blank') === -1)) { |
|
|
|
if (!isChild && (state.focusEdit.element === 'browser/blank') && state.focusEdit.isNew && (dir.findIndex(({ path }) => path === 'browser/blank') === -1)) { |
|
|
|
dir = state.focusEdit.type === 'file' ? [...dir, { |
|
|
|
dir = state.focusEdit.type === 'file' ? [...dir, { |
|
|
@ -645,7 +668,7 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
|
|
|
|
|
|
|
|
const handleHideModal = () => { |
|
|
|
const handleHideModal = () => { |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { ...prevState, modalOptions: { ...state.modalOptions, hide: true } } |
|
|
|
return { ...prevState, focusModal: { ...state.focusModal, hide: true } } |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -653,15 +676,14 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { |
|
|
|
return { |
|
|
|
...prevState, |
|
|
|
...prevState, |
|
|
|
modalOptions: { |
|
|
|
modals: [...prevState.modals, |
|
|
|
...prevState.modalOptions, |
|
|
|
{ |
|
|
|
hide: false, |
|
|
|
|
|
|
|
message, |
|
|
|
message, |
|
|
|
title, |
|
|
|
title, |
|
|
|
ok, |
|
|
|
ok, |
|
|
|
cancel, |
|
|
|
cancel, |
|
|
|
handleHide: handleHideModal |
|
|
|
handleHide: handleHideModal |
|
|
|
} |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -933,6 +955,20 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
<TreeView id='treeView'> |
|
|
|
<TreeView id='treeView'> |
|
|
|
<TreeViewItem id="treeViewItem" |
|
|
|
<TreeViewItem id="treeViewItem" |
|
|
|
label={ |
|
|
|
label={ |
|
|
|
|
|
|
|
<div onClick={(e) => { |
|
|
|
|
|
|
|
e.stopPropagation() |
|
|
|
|
|
|
|
let expandPath = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!state.expandPath.includes(props.name)) { |
|
|
|
|
|
|
|
expandPath = [props.name, ...new Set([...state.expandPath])] |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
expandPath = [...new Set(state.expandPath.filter(key => key && (typeof key === 'string') && !key.startsWith(props.name)))] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setState(prevState => { |
|
|
|
|
|
|
|
return { ...prevState, expandPath } |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
plugin.resetFocus(true) |
|
|
|
|
|
|
|
}}> |
|
|
|
<FileExplorerMenu |
|
|
|
<FileExplorerMenu |
|
|
|
title={name} |
|
|
|
title={name} |
|
|
|
menuItems={props.menuItems} |
|
|
|
menuItems={props.menuItems} |
|
|
@ -942,8 +978,9 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
uploadFile={uploadFile} |
|
|
|
uploadFile={uploadFile} |
|
|
|
fileManager={state.fileManager} |
|
|
|
fileManager={state.fileManager} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
} |
|
|
|
} |
|
|
|
expand={true}> |
|
|
|
expand={state.expandPath.includes(props.name)}> |
|
|
|
<div className='pb-2'> |
|
|
|
<div className='pb-2'> |
|
|
|
<TreeView id='treeViewMenu'> |
|
|
|
<TreeView id='treeViewMenu'> |
|
|
|
{ |
|
|
|
{ |
|
|
@ -958,11 +995,11 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
{ |
|
|
|
{ |
|
|
|
props.name && <ModalDialog |
|
|
|
props.name && <ModalDialog |
|
|
|
id={ props.name } |
|
|
|
id={ props.name } |
|
|
|
title={ state.modalOptions.title } |
|
|
|
title={ state.focusModal.title } |
|
|
|
message={ state.modalOptions.message } |
|
|
|
message={ state.focusModal.message } |
|
|
|
hide={ state.modalOptions.hide } |
|
|
|
hide={ state.focusModal.hide } |
|
|
|
ok={ state.modalOptions.ok } |
|
|
|
ok={ state.focusModal.ok } |
|
|
|
cancel={ state.modalOptions.cancel } |
|
|
|
cancel={ state.focusModal.cancel } |
|
|
|
handleHide={ handleHideModal } |
|
|
|
handleHide={ handleHideModal } |
|
|
|
/> |
|
|
|
/> |
|
|
|
} |
|
|
|
} |
|
|
|