-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JTE/PKFE-46 #58
Merged
Merged
JTE/PKFE-46 #58
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
46ed81c
Added file export functionality
justinnas 7c8efac
Small fixes
justinnas 94260ba
More small fixes
justinnas 3c097e7
Fixed issues
justinnas 9e0e201
Minor fix
justinnas e2e9c48
Merge pull request #59 from Strexas/main
mantvydasdeltuva 845047d
MDE/PKFE-46 implemented socket emit in [FE]
mantvydasdeltuva 3abbb2c
MDE/PKFE-46 implemented event handler for export feedback
mantvydasdeltuva d52efa6
MDE/PKFE-46 fixed pylint errors and minor structure changes
mantvydasdeltuva 126481d
Added file names to success and fail messages
justinnas fcb4e2a
Added filename in frontend export error
justinnas 7f112e8
Switched from fileName to filePath variable
justinnas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ export const FileTreeItemContextMenu: React.FC<FileTreeItemContextMenuProps> = ( | |
); | ||
} else { | ||
menuItems.push( | ||
<MenuItem key='export' onClick={() => handleActionContextMenu('export')} disabled> | ||
<MenuItem key='export' onClick={() => handleActionContextMenu('export')}> | ||
Export... | ||
</MenuItem>, | ||
<Divider key='divider-export' /> | ||
|
@@ -112,8 +112,7 @@ export const FileTreeItemContextMenu: React.FC<FileTreeItemContextMenuProps> = ( | |
setFileImportDialogOpen(true); | ||
break; | ||
case 'export': | ||
// TODO: Implement file export | ||
console.log('export'); | ||
handleExport(); | ||
break; | ||
case 'rename': | ||
setRenameDialogOpen(true); | ||
|
@@ -158,6 +157,30 @@ export const FileTreeItemContextMenu: React.FC<FileTreeItemContextMenuProps> = ( | |
filesHistoryStateUpdate(undefined, { id: item.id, label: item.label, type: item.fileType || FileTypes.FILE }); | ||
}; | ||
|
||
const handleExport = async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use hook There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea |
||
try { | ||
const response = await axios.get(`${Endpoints.WORKSPACE_EXPORT}/${item.id}`, { | ||
responseType: 'blob', | ||
}); | ||
const url = window.URL.createObjectURL(new Blob([response.data])); | ||
|
||
const fileName = item.id.match(/[^/\\]+$/)?.[0] || item.id; // Extracts only the file name, otherwise uses the full path | ||
|
||
const link = Object.assign(document.createElement('a'), { | ||
href: url, | ||
download: fileName, | ||
}); | ||
|
||
link.click(); | ||
window.URL.revokeObjectURL(url); | ||
|
||
// TODO: Implement socket console event for successful file export | ||
console.log('Exported:', fileName); | ||
} catch (error) { | ||
console.error('Error exporting file:', error); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Menu | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edit everywhere where logger and console feedback:
accessing -> exporting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch