mirror of
https://github.com/sasjs/server.git
synced 2026-01-18 19:30:06 +00:00
feat(web): added delete option in Drive
This commit is contained in:
@@ -23,7 +23,7 @@ const Main = (props: any) => {
|
|||||||
if (props.selectedFilePath) {
|
if (props.selectedFilePath) {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
axios
|
axios
|
||||||
.get(`/SASjsApi/drive/file?filePath=${props.selectedFilePath}`)
|
.get(`/SASjsApi/drive/file?_filePath=${props.selectedFilePath}`)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
setFileContent(res.data)
|
setFileContent(res.data)
|
||||||
})
|
})
|
||||||
@@ -36,6 +36,25 @@ const Main = (props: any) => {
|
|||||||
}
|
}
|
||||||
}, [props.selectedFilePath])
|
}, [props.selectedFilePath])
|
||||||
|
|
||||||
|
const handleDeleteBtnClick = () => {
|
||||||
|
setIsLoading(true)
|
||||||
|
|
||||||
|
const filePath = props.selectedFilePath
|
||||||
|
|
||||||
|
axios
|
||||||
|
.delete(`/SASjsApi/drive/file?_filePath=${filePath}`)
|
||||||
|
.then((res) => {
|
||||||
|
setFileContent('')
|
||||||
|
window.history.pushState('', '', `${baseUrl}/#/SASjsDrive`)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setIsLoading(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const handleEditSaveBtnClick = () => {
|
const handleEditSaveBtnClick = () => {
|
||||||
if (!editMode) {
|
if (!editMode) {
|
||||||
setFileContentBeforeEdit(fileContent)
|
setFileContentBeforeEdit(fileContent)
|
||||||
@@ -112,6 +131,13 @@ const Main = (props: any) => {
|
|||||||
direction="row"
|
direction="row"
|
||||||
sx={{ justifyContent: 'center', marginTop: '20px' }}
|
sx={{ justifyContent: 'center', marginTop: '20px' }}
|
||||||
>
|
>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleDeleteBtnClick}
|
||||||
|
disabled={isLoading || !props?.selectedFilePath}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={handleEditSaveBtnClick}
|
onClick={handleEditSaveBtnClick}
|
||||||
|
|||||||
@@ -64,14 +64,16 @@ const SideBar = (props: any) => {
|
|||||||
}, [setFilePathOnMount])
|
}, [setFilePathOnMount])
|
||||||
|
|
||||||
const handleSelect = (node: TreeNode) => {
|
const handleSelect = (node: TreeNode) => {
|
||||||
if (!node.children.length) {
|
if (node.children.length) return
|
||||||
window.history.pushState(
|
|
||||||
'',
|
if (!node.name.includes('.')) return
|
||||||
'',
|
|
||||||
`${baseUrl}/#/SASjsDrive?filePath=${node.relativePath}`
|
window.history.pushState(
|
||||||
)
|
'',
|
||||||
setSelectedFilePath(node.relativePath)
|
'',
|
||||||
}
|
`${baseUrl}/#/SASjsDrive?filePath=${node.relativePath}`
|
||||||
|
)
|
||||||
|
setSelectedFilePath(node.relativePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderTree = (nodes: TreeNode) => (
|
const renderTree = (nodes: TreeNode) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user