-
Notifications
You must be signed in to change notification settings - Fork 0
Implemented Persistent Filesystem solution #206
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
3e5b946
improved by putting api calls in services and use hooks to fetch the …
stijnpotters1 73ad5e1
Remove unnecessary comments in navigation-store and project-landing f…
stijnpotters1 ca7bb61
Implement filesystem browser and project management features
stijnpotters1 4271b77
Refactor project management to use recent projects and improve filesy…
stijnpotters1 d0b234d
Add project cloning functionality and enhance project management UI
stijnpotters1 e36e9bb
Add ProjectCloneDTO for handling project cloning data
stijnpotters1 a20063d
Refactor project modals to use DirectoryPicker for folder selection
stijnpotters1 dca5d86
Add project removal functionality to recent projects list
stijnpotters1 57ed3a4
Enhance project fetching and configuration loading in services
stijnpotters1 144ecf1
Refactor FileTreeServiceTest to improve readability and add new test …
stijnpotters1 6f9f0bc
Add ToastContainer to AppLayout and update error handling in project …
stijnpotters1 e50a34f
feat: made it filesystem cloud and local proof
stijnpotters1 afb686c
fix: introduced JGIT and solved sonar hotspot
stijnpotters1 ebe5bfe
feat: improved code and tests
stijnpotters1 3a43435
chore: applied spotless
stijnpotters1 9c59d52
fix: improved failing FileTreeService test
stijnpotters1 bc35a38
fix: solved sonar security issues and added tests to cover new implem…
stijnpotters1 cf86905
fix: improved failing tests
stijnpotters1 28dc258
fix: improved failing test because of IOException
stijnpotters1 7998518
fix: solved stubbing issues in projectservicetest
stijnpotters1 7b11eaf
fix: solved stubbing issues in FileTreeServiceTest
stijnpotters1 0cdfbb4
fix: solved sonar hotspots
stijnpotters1 5579a12
fix: improved code according to feedback
stijnpotters1 37a5b4c
fix: improved code according to feedback
stijnpotters1 2e6b099
fix: made spring profile default cloud so its compatible for kubernet…
stijnpotters1 2c76a7a
Update src/main/java/org/frankframework/flow/filesystem/FileSystemSto…
stijnpotters1 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
158 changes: 158 additions & 0 deletions
158
src/main/frontend/app/components/directory-picker/directory-picker.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| import { useCallback, useEffect, useState } from 'react' | ||
| import FolderIcon from '/icons/solar/Folder.svg?react' | ||
| import { filesystemService } from '~/services/filesystem-service' | ||
| import type { FilesystemEntry } from '~/types/filesystem.types' | ||
| import { ApiError } from '~/utils/api' | ||
|
|
||
| interface DirectoryPickerProperties { | ||
| isOpen: boolean | ||
| onSelect: (absolutePath: string) => void | ||
| onCancel: () => void | ||
| rootLabel?: string | ||
| } | ||
|
|
||
| export default function DirectoryPicker({ | ||
| isOpen, | ||
| onSelect, | ||
| onCancel, | ||
| rootLabel = 'Computer', | ||
| }: Readonly<DirectoryPickerProperties>) { | ||
| const [currentPath, setCurrentPath] = useState('') | ||
| const [entries, setEntries] = useState<FilesystemEntry[]>([]) | ||
| const [selectedEntry, setSelectedEntry] = useState<string | null>(null) | ||
| const [loading, setLoading] = useState(false) | ||
| const [error, setError] = useState<string | null>(null) | ||
|
|
||
| const loadEntries = useCallback(async (path: string) => { | ||
| setLoading(true) | ||
| setError(null) | ||
| setSelectedEntry(null) | ||
| try { | ||
| const result = await filesystemService.browse(path) | ||
| setEntries(result) | ||
| setCurrentPath(path) | ||
| } catch (error_) { | ||
| const status = error_ instanceof ApiError ? error_.status : 0 | ||
| if (status === 403) { | ||
| setError('Access denied') | ||
| } else { | ||
| setError(error_ instanceof Error ? error_.message : 'Failed to load directories') | ||
| } | ||
| } finally { | ||
| setLoading(false) | ||
| } | ||
| }, []) | ||
|
|
||
| useEffect(() => { | ||
| if (isOpen) { | ||
| setSelectedEntry(null) | ||
| loadEntries('') | ||
| } | ||
| }, [isOpen, loadEntries]) | ||
|
|
||
| if (!isOpen) return null | ||
|
|
||
| const isRoot = !currentPath | ||
| const canGoUp = !isRoot | ||
|
|
||
| const handleNavigateUp = () => { | ||
| if (/^[a-zA-Z]:[/\\]?$/.test(currentPath) || currentPath === '/') { | ||
| loadEntries('') | ||
| return | ||
| } | ||
| const parentPath = currentPath.replace(/[\\/][^\\/]*$/, '') | ||
| if (!parentPath || parentPath === currentPath) { | ||
| loadEntries('') | ||
| } else if (/^[a-zA-Z]:$/.test(parentPath)) { | ||
| loadEntries(`${parentPath}\\`) | ||
| } else { | ||
| loadEntries(parentPath) | ||
| } | ||
| } | ||
|
|
||
| const handleClick = (entry: FilesystemEntry) => { | ||
| setSelectedEntry(entry.path) | ||
| } | ||
|
|
||
| const handleDoubleClick = (entry: FilesystemEntry) => { | ||
| loadEntries(entry.path) | ||
| } | ||
|
|
||
| const activePath = selectedEntry ?? currentPath | ||
|
|
||
| return ( | ||
| <div className="bg-background/50 absolute inset-0 z-[60] flex items-center justify-center"> | ||
| <div className="bg-background border-border flex h-[450px] w-[500px] flex-col rounded-lg border shadow-lg"> | ||
| <div className="border-border flex items-center justify-between border-b px-4 py-3"> | ||
| <h3 className="text-sm font-semibold">Select Directory</h3> | ||
| <button | ||
| onClick={onCancel} | ||
| className="text-foreground-muted hover:text-foreground cursor-pointer text-lg leading-none" | ||
| > | ||
| × | ||
| </button> | ||
| </div> | ||
|
|
||
| <div className="border-border flex items-center gap-2 border-b px-4 py-2"> | ||
| <button | ||
| onClick={handleNavigateUp} | ||
| disabled={!canGoUp} | ||
| className="bg-backdrop border-border cursor-pointer rounded border px-2 py-0.5 text-xs disabled:opacity-30" | ||
| > | ||
| .. | ||
| </button> | ||
| <span className="text-foreground-muted truncate text-xs">{currentPath || rootLabel}</span> | ||
| </div> | ||
|
|
||
| <div className="flex-1 overflow-y-auto p-2"> | ||
| {loading && <p className="text-foreground-muted p-4 text-center text-xs">Loading...</p>} | ||
| {error && <p className="p-4 text-center text-xs text-red-500">{error}</p>} | ||
| {!loading && !error && entries.length === 0 && ( | ||
| <p className="text-foreground-muted p-4 text-center text-xs italic">No subdirectories</p> | ||
| )} | ||
| {!loading && | ||
| !error && | ||
| entries.map((entry) => ( | ||
| <button | ||
| key={entry.path} | ||
| onClick={() => handleClick(entry)} | ||
| onDoubleClick={() => handleDoubleClick(entry)} | ||
| className={`flex w-full cursor-pointer items-center gap-2 rounded px-3 py-1.5 text-left text-sm ${ | ||
| selectedEntry === entry.path ? 'bg-backdrop font-medium' : 'hover:bg-backdrop/50' | ||
| }`} | ||
| > | ||
| <span className="relative text-xs"> | ||
| <FolderIcon className="fill-foreground w-4 flex-shrink-0" /> | ||
| {entry.projectRoot && ( | ||
| <span className="absolute bottom-0.5 h-1.5 w-1.5 rounded-full bg-black" style={{ left: '65%' }} /> | ||
| )} | ||
| </span> | ||
| <span className="truncate">{entry.name}</span> | ||
| </button> | ||
| ))} | ||
| </div> | ||
|
|
||
| <div className="border-border flex items-center justify-between border-t px-4 py-3"> | ||
| <span className="text-foreground-muted max-w-[280px] truncate text-xs"> | ||
| {activePath || 'Select a directory'} | ||
| </span> | ||
| <div className="flex gap-2"> | ||
| <button | ||
| onClick={onCancel} | ||
| className="border-border hover:bg-backdrop cursor-pointer rounded border px-3 py-1 text-sm" | ||
| > | ||
| Cancel | ||
| </button> | ||
| <button | ||
| onClick={() => onSelect(activePath)} | ||
| disabled={!activePath} | ||
| className="bg-backdrop hover:bg-background border-border cursor-pointer rounded border px-3 py-1 text-sm disabled:cursor-not-allowed disabled:opacity-50" | ||
| > | ||
| Select | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { useAsync } from './use-async' | ||
| import { fetchProjects } from '~/services/project-service' | ||
| import type { Project } from '~/routes/projectlanding/project-landing' | ||
| import type { RecentProject } from '~/types/project.types' | ||
| import { fetchRecentProjects } from '~/services/recent-project-service' | ||
|
|
||
| export function useProjects() { | ||
| return useAsync<Project[]>((signal) => fetchProjects(signal)) | ||
| export function useRecentProjects() { | ||
| return useAsync<RecentProject[]>((signal) => fetchRecentProjects(signal)) | ||
| } |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.