Skip to content

Commit 91b546a

Browse files
author
Francesco Pagnamenta
committed
File manager navigation fixes
1 parent d26471b commit 91b546a

File tree

4 files changed

+56
-232
lines changed

4 files changed

+56
-232
lines changed

app/modules/filesystem/components/views/FileListView.tsx

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import {
2626
buildFileSystemSelection,
2727
buildFileSystemSelectionPath,
2828
splitFileSystemSelection,
29-
buildFileSystemNavigationPath,
3029
buildBreadcrumbNavigation,
30+
buildFileSystemNavigationPath,
3131
} from '~/modules/filesystem/helpers/filesystem-helper'
3232
import { formatDateTime } from '~/helpers/date-helper'
3333
import { FileTableSortableColumn } from '~/helpers/ui-table-helper'
@@ -62,7 +62,6 @@ import LoadingButton from '~/components/buttons/LoadingButton'
6262
import SimplePanel from '~/components/panels/SimplePanel'
6363
// views
6464
import SimpleView, { SimpleViewSize } from '~/components/views/SimpleView'
65-
import { showInputValidation } from '~/components/forms/validations/ValidationForm'
6665

6766
const copyToClipboard = (file: File, fileSystem: FileSystem) => {
6867
const path = `${fileSystem.path}/${file.name}`
@@ -74,9 +73,16 @@ interface FileItemProps {
7473
currentPath: string
7574
fileSystem: FileSystem
7675
system: System
76+
accountName: string
7777
}
7878

79-
const FileItem: React.FC<FileItemProps> = ({ file, currentPath, fileSystem, system }) => {
79+
const FileItem: React.FC<FileItemProps> = ({
80+
file,
81+
currentPath,
82+
fileSystem,
83+
system,
84+
accountName,
85+
}) => {
8086
const [changeOwnershipDialogOpen, setChangeOwnershipDialogOpen] = useState(false)
8187
const [changePermissionDialogDialogOpen, setChangePermissionDialogDialogOpen] = useState(false)
8288
const [checksumDialogOpen, setChecksumDialogOpen] = useState(false)
@@ -303,9 +309,16 @@ interface DirectoryItemProps {
303309
currentPath: string
304310
fileSystem: FileSystem
305311
system: System
312+
accountName: string
306313
}
307314

308-
const DirectoryItem: React.FC<DirectoryItemProps> = ({ file, currentPath, fileSystem, system }) => {
315+
const DirectoryItem: React.FC<DirectoryItemProps> = ({
316+
file,
317+
currentPath,
318+
fileSystem,
319+
system,
320+
accountName,
321+
}) => {
309322
const [changeOwnershipDialogOpen, setChangeOwnershipDialogOpen] = useState(false)
310323
const [changePermissionDialogDialogOpen, setChangePermissionDialogDialogOpen] = useState(false)
311324
const [copyDialogOpen, setCopyDialogOpen] = useState(false)
@@ -316,7 +329,7 @@ const DirectoryItem: React.FC<DirectoryItemProps> = ({ file, currentPath, fileSy
316329
const [removeDialogOpen, setRemoveDialogOpen] = useState(false)
317330
const { name } = file
318331

319-
const navigationPath = buildFileSystemNavigationPath(system.name, currentPath, name)
332+
const navigationPath = buildFileSystemNavigationPath(system.name, currentPath, accountName, name)
320333
return (
321334
<tr className='even:bg-blue-50'>
322335
<td className='px-4 py-3 font-medium'>
@@ -493,14 +506,21 @@ interface BreadcrumbNavigationProps {
493506
currentPath: string
494507
system: System
495508
fileSystem: FileSystem
509+
accountName: string
496510
}
497511

498512
const BreadcrumbNavigation: React.FC<BreadcrumbNavigationProps> = ({
499513
currentPath,
500514
system,
501515
fileSystem,
516+
accountName,
502517
}) => {
503-
const navigationData = buildBreadcrumbNavigation(currentPath, fileSystem.path, system.name)
518+
const navigationData = buildBreadcrumbNavigation(
519+
currentPath,
520+
fileSystem.path,
521+
system.name,
522+
accountName,
523+
)
504524
return (
505525
<>
506526
<nav className='flex rounded-md p-2 mb-4 border border-gray-200' aria-label='Breadcrumb'>
@@ -540,6 +560,7 @@ interface FileSystemSelectionData {
540560
system: System
541561
systems: System[]
542562
username: string
563+
accountName: string
543564
}
544565

545566
const FileSystemSelection: React.FC<FileSystemSelectionData> = ({
@@ -548,11 +569,12 @@ const FileSystemSelection: React.FC<FileSystemSelectionData> = ({
548569
system,
549570
systems,
550571
username,
572+
accountName,
551573
}) => {
552574
const onChangeHandler = (event: any) => {
553575
const selectedValue = event.target.value
554576
const { systemName, fileSystemPath } = splitFileSystemSelection(selectedValue)
555-
const newNavigationPath = buildFileSystemNavigationPath(systemName, fileSystemPath)
577+
const newNavigationPath = buildFileSystemNavigationPath(systemName, fileSystemPath, accountName)
556578
window.location.href = newNavigationPath
557579
}
558580

@@ -618,13 +640,15 @@ interface FileListTableProps {
618640
currentPath: string
619641
fileSystem: FileSystem
620642
system: System
643+
accountName: string
621644
}
622645

623646
const FileListTable: React.FC<FileListTableProps> = ({
624647
files,
625648
currentPath,
626649
fileSystem,
627650
system,
651+
accountName,
628652
}) => {
629653
const [sortableColumns, setSortableColumns] = useState<FileTableSortableColumn[]>([])
630654
const [fileSystemList, setFileSystemList] = useState<any[]>([])
@@ -655,6 +679,7 @@ const FileListTable: React.FC<FileListTableProps> = ({
655679
currentPath={currentPath}
656680
fileSystem={fileSystem}
657681
system={system}
682+
accountName={accountName}
658683
/>
659684
) : (
660685
<FileItem
@@ -663,6 +688,7 @@ const FileListTable: React.FC<FileListTableProps> = ({
663688
currentPath={currentPath}
664689
fileSystem={fileSystem}
665690
system={system}
691+
accountName={accountName}
666692
/>
667693
),
668694
)}
@@ -895,6 +921,8 @@ const FileListView: React.FC<FileListViewProps> = ({
895921
</div>
896922
)
897923

924+
console.log('Account Name:', accountName)
925+
898926
return (
899927
<SimpleView title='File Manager' size={SimpleViewSize.FULL}>
900928
<SimplePanel title={'Filesystem'} className='mb-[330px]' actionsButtons={actionsButtons}>
@@ -912,12 +940,14 @@ const FileListView: React.FC<FileListViewProps> = ({
912940
system={system}
913941
systems={systems}
914942
username={username}
943+
accountName={accountName}
915944
/>
916945
</div>
917946
<BreadcrumbNavigation
918947
currentPath={currentPath}
919948
system={system}
920949
fileSystem={fileSystem}
950+
accountName={accountName}
921951
/>
922952
{remoteFsError == null && (
923953
<FileUpload
@@ -937,6 +967,7 @@ const FileListView: React.FC<FileListViewProps> = ({
937967
currentPath={currentPath}
938968
fileSystem={fileSystem}
939969
system={system}
970+
accountName={accountName}
940971
/>
941972
)}
942973
{!fileList ||

app/modules/filesystem/helpers/filesystem-helper.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,20 @@ export const buildFileSystemSelectionPath = (fileSystem: FileSystem, username: s
3939
export const buildFileSystemNavigationPath = (
4040
systemName: string,
4141
currentPath: string,
42+
accountName: string,
4243
additionalPath: string | null = null,
4344
) => {
4445
if (additionalPath === null || _.isEmpty(additionalPath)) {
45-
return `/filesystems/${systemName}/?targetPath=${currentPath}`
46+
return `/filesystems/systems/${systemName}/accounts/${accountName}/?targetPath=${currentPath}`
4647
}
47-
return `/filesystems/${systemName}/?targetPath=${currentPath}/${additionalPath}`
48+
return `/filesystems/systems/${systemName}/accounts/${accountName}/?targetPath=${currentPath}/${additionalPath}`
4849
}
4950

5051
export const buildBreadcrumbNavigation = (
5152
currentPath: string,
5253
fileSystemPath: string,
5354
systemName: string,
55+
accountName: string,
5456
) => {
5557
if (!currentPath || currentPath.trim() === '') {
5658
return []
@@ -64,7 +66,7 @@ export const buildBreadcrumbNavigation = (
6466
dirName: pathSegment,
6567
path: path,
6668
isBasePath: path === fileSystemPath,
67-
navUrl: buildFileSystemNavigationPath(systemName, path),
69+
navUrl: buildFileSystemNavigationPath(systemName, path, accountName),
6870
})
6971
})
7072
return navigationStructure

app/routes/_app.filesystems.$system.tsx

Lines changed: 0 additions & 143 deletions
This file was deleted.

0 commit comments

Comments
 (0)