From 7a6e6c8becab31410d0a36bcc22e13d5359a6cdf Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 14 Mar 2022 06:26:12 +0500 Subject: [PATCH] feat(web): added delete option in Drive --- web/src/containers/Drive/main.tsx | 28 +++++++++++++++++++++++++++- web/src/containers/Drive/sideBar.tsx | 18 ++++++++++-------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/web/src/containers/Drive/main.tsx b/web/src/containers/Drive/main.tsx index 7fbf730..fa083a4 100644 --- a/web/src/containers/Drive/main.tsx +++ b/web/src/containers/Drive/main.tsx @@ -23,7 +23,7 @@ const Main = (props: any) => { if (props.selectedFilePath) { setIsLoading(true) axios - .get(`/SASjsApi/drive/file?filePath=${props.selectedFilePath}`) + .get(`/SASjsApi/drive/file?_filePath=${props.selectedFilePath}`) .then((res: any) => { setFileContent(res.data) }) @@ -36,6 +36,25 @@ const Main = (props: any) => { } }, [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 = () => { if (!editMode) { setFileContentBeforeEdit(fileContent) @@ -112,6 +131,13 @@ const Main = (props: any) => { direction="row" sx={{ justifyContent: 'center', marginTop: '20px' }} > +