Skip to content

Update preference management #43

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 29 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f556701
refactor: create a zone and file share path 'uber map'
allison-truhlar May 9, 2025
81971f1
fix: adds file share paths to newly created zone, not just existing ones
allison-truhlar May 9, 2025
d591c85
refactor(zone/fsp map): address konrad's suggestions
allison-truhlar May 9, 2025
abb7774
fix(createZonesAndFSPMap): don't re-push the zone back into the map
allison-truhlar May 9, 2025
fafb0a8
refactor: change how prefs are saved to backend and in state
allison-truhlar May 9, 2025
56c9698
refactor: rename types for new contents and/or clarity
allison-truhlar May 15, 2025
748e29e
refactor(pref context): change how handle zone favorite change works
allison-truhlar May 15, 2025
ca3218c
refactor: move ZoneBrowserContextProvider outside of PreferencesProvider
allison-truhlar May 15, 2025
84aed35
refactor(Zone): change to work with the zone object
allison-truhlar May 15, 2025
1b12309
refactor(makeMapKey): move to utils so it can be utilized in components
allison-truhlar May 15, 2025
c6924d1
wip: changes to make the zone preferences work for demo
allison-truhlar May 15, 2025
f1cc853
refactor(zone prefs): save state for zone keys and for actual zone fa…
allison-truhlar May 16, 2025
bb6e039
refactor: change updateFavoriteState to updatePreferenceKeyList to be…
allison-truhlar May 16, 2025
0d01e52
refactor: updates fsp pref management; adds back in all UI comps
allison-truhlar May 16, 2025
57b8060
refactor: updates folder preferences and adds back in related comps/f…
allison-truhlar May 16, 2025
318b9e7
restores filtering to zone browser
allison-truhlar May 16, 2025
cec23ae
restores filtering for favorites browser
allison-truhlar May 16, 2025
77b8685
feat: adds back in alphabetization functions for zones and fsps
allison-truhlar May 19, 2025
c636896
refactor(Pref context): change sorting to be based on the most promin…
allison-truhlar May 19, 2025
b0503f5
restores Preferences page; fixes path preference used to query backend
allison-truhlar May 19, 2025
7fe1836
chore: merge in changes from main
allison-truhlar May 19, 2025
aa126e9
chore: merge branch 'main' into update-preference-management
allison-truhlar May 19, 2025
a75679a
fix: adds Preferences page back in, removing the placeholder
allison-truhlar May 19, 2025
2810b49
Merge branch 'main' into update-preference-management
allison-truhlar May 20, 2025
6697fa1
fixed syntax error caused by old variable reference
krokicki May 20, 2025
72d69ea
fix: restore missing types and imports to FavoritesBrowser
allison-truhlar May 21, 2025
670347a
Merge branch 'main' into update-preference-management
allison-truhlar May 21, 2025
7d9510e
wip: changes info stored for zone, fsp, and folder prefs on backend
allison-truhlar May 21, 2025
824219f
refactor: final changes to preference management
allison-truhlar May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Home from '@/components/Home';
import Browse from '@/components/Browse';
import Help from '@/components/Help';
import Jobs from '@/components/Jobs';
import Preferences from '@/components/Preferences';

function Profile() {
return (
Expand All @@ -23,14 +24,6 @@ function Login() {
);
}

function Preferences() {
return (
<div className="p-4">
<h2 className="text-foreground text-lg">Preferences Page</h2>
</div>
);
}

function getBasename() {
const { pathname } = window.location;
// Try to match /user/:username/lab
Expand Down
43 changes: 11 additions & 32 deletions src/components/ui/FileBrowser/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import ReactDOM from 'react-dom';
import { Typography } from '@material-tailwind/react';

import type { File } from '@/shared.types';
import type { FileOrFolder } from '@/shared.types';
import { useZoneBrowserContext } from '@/contexts/ZoneBrowserContext';
import { usePreferencesContext } from '@/contexts/PreferencesContext';

type ContextMenuProps = {
x: number;
y: number;
menuRef: React.RefObject<HTMLDivElement | null>;
selectedFiles: File[];
selectedFiles: FileOrFolder[];
setShowPropertiesDrawer: React.Dispatch<React.SetStateAction<boolean>>;
setShowContextMenu: React.Dispatch<React.SetStateAction<boolean>>;
setShowRenameDialog: React.Dispatch<React.SetStateAction<boolean>>;
Expand All @@ -29,7 +29,7 @@
setShowDeleteDialog,
setShowPermissionsDialog
}: ContextMenuProps): React.ReactNode {
const { currentNavigationZone, currentFileSharePath } =

Check warning on line 32 in src/components/ui/FileBrowser/ContextMenu.tsx

View workflow job for this annotation

GitHub Actions / build

'currentNavigationZone' is assigned a value but never used
useZoneBrowserContext();
const { handleFavoriteChange } = usePreferencesContext();
return ReactDOM.createPortal(
Expand All @@ -52,44 +52,25 @@
>
View file properties
</Typography>

{/* Set/unset folders as favorites */}
{(selectedFiles.length === 1 && selectedFiles[0].is_dir) ||
(selectedFiles.length > 1 &&
selectedFiles.some(file => file.is_dir)) ? (
{selectedFiles.length === 1 && selectedFiles[0].is_dir ? (
<Typography
className="text-sm p-1 cursor-pointer text-secondary-light hover:bg-secondary-light/30 transition-colors whitespace-nowrap"
onClick={() => {
if (currentNavigationZone && currentFileSharePath) {
if (selectedFiles.length === 1) {
handleFavoriteChange(
{
fileSharePath: currentFileSharePath,
name: selectedFiles[0].name,
path: selectedFiles[0].path
},
'directory'
);
} else if (selectedFiles.length > 1) {
console.log('selected files:', selectedFiles);
const directoriesToAdd = selectedFiles
.filter(file => file.is_dir)
.map(file => ({
navigationZone: currentNavigationZone,
fileSharePath: currentFileSharePath,
name: file.name,
path: file.path
}));
handleFavoriteChange(directoriesToAdd, 'directory');
setShowContextMenu(false);
}
if (currentFileSharePath) {
handleFavoriteChange(
{
folderPath: selectedFiles[0].path,
fsp: currentFileSharePath
},
'folder'
);
}
}}
>
Set/unset as favorite
</Typography>
) : null}

{/* Rename file or folder */}
{selectedFiles.length === 1 ? (
<Typography
Expand All @@ -102,7 +83,6 @@
Rename
</Typography>
) : null}

{/* Change permissions on file(s) */}
{selectedFiles.length === 1 && !selectedFiles[0].is_dir ? (
<Typography
Expand All @@ -115,7 +95,6 @@
Change permissions
</Typography>
) : null}

{/* Delete file(s) or folder(s) */}
<Typography
className="text-sm p-1 cursor-pointer text-secondary-light hover:bg-secondary-light/30 transition-colors whitespace-nowrap"
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/FileBrowser/Dialogs/ChangePermissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
Typography
} from '@material-tailwind/react';
import { XMarkIcon } from '@heroicons/react/24/outline';

import usePermissionsDialog from '@/hooks/usePermissionsDialog';
import type { File } from '@/shared.types';
import type { FileOrFolder } from '@/shared.types';

type ChangePermissionsProps = {
targetItem: File | null;
targetItem: FileOrFolder | null;
showPermissionsDialog: boolean;
setShowPermissionsDialog: React.Dispatch<React.SetStateAction<boolean>>;
};
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/FileBrowser/Dialogs/Delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {
Typography
} from '@material-tailwind/react';
import { XMarkIcon } from '@heroicons/react/24/outline';

import useDeleteDialog from '@/hooks/useDeleteDialog';
import type { File } from '@/shared.types';
import type { FileOrFolder } from '@/shared.types';
import { useZoneBrowserContext } from '@/contexts/ZoneBrowserContext';

type DeleteDialogProps = {
targetItem: File;
targetItem: FileOrFolder;
showDeleteDialog: boolean;
setShowDeleteDialog: React.Dispatch<React.SetStateAction<boolean>>;
};
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/FileBrowser/Dialogs/RenameDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
Typography
} from '@material-tailwind/react';
import { XMarkIcon } from '@heroicons/react/24/outline';
import type { File } from '@/shared.types';

import type { FileOrFolder } from '@/shared.types';
import useRenameDialog from '@/hooks/useRenameDialog';

type ItemNamingDialogProps = {
propertiesTarget: File | null;
propertiesTarget: FileOrFolder | null;
showRenameDialog: boolean;
setShowRenameDialog: React.Dispatch<React.SetStateAction<boolean>>;
};
Expand Down
26 changes: 17 additions & 9 deletions src/components/ui/FileBrowser/FileList.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
import * as React from 'react';
import { Typography } from '@material-tailwind/react';

import type { File } from '@/shared.types';

Check warning on line 4 in src/components/ui/FileBrowser/FileList.tsx

View workflow job for this annotation

GitHub Actions / build

'zarr' is defined but never used
import * as zarr from 'zarrita';

Check warning on line 5 in src/components/ui/FileBrowser/FileList.tsx

View workflow job for this annotation

GitHub Actions / build

'omezarr' is defined but never used
import * as omezarr from 'ome-zarr.js';

import type { FileOrFolder } from '@/shared.types';
import FileListCrumbs from './Crumbs';
import FileRow from './FileRow';
import { useZoneBrowserContext } from '@/contexts/ZoneBrowserContext';
import { useFileBrowserContext } from '@/contexts/FileBrowserContext';
import { getOmeZarrMetadata } from '@/omezarr-helper';

type FileListProps = {
files: File[];
selectedFiles: File[];
setSelectedFiles: React.Dispatch<React.SetStateAction<File[]>>;
files: FileOrFolder[];
selectedFiles: FileOrFolder[];
setSelectedFiles: React.Dispatch<React.SetStateAction<FileOrFolder[]>>;
showPropertiesDrawer: boolean;
setPropertiesTarget: React.Dispatch<React.SetStateAction<File | null>>;
setPropertiesTarget: React.Dispatch<
React.SetStateAction<FileOrFolder | null>
>;
hideDotFiles: boolean;
handleRightClick: (
e: React.MouseEvent<HTMLDivElement>,
file: File,
selectedFiles: File[],
setSelectedFiles: React.Dispatch<React.SetStateAction<File[]>>,
setPropertiesTarget: React.Dispatch<React.SetStateAction<File | null>>
file: FileOrFolder,
selectedFiles: FileOrFolder[],
setSelectedFiles: React.Dispatch<React.SetStateAction<FileOrFolder[]>>,
setPropertiesTarget: React.Dispatch<
React.SetStateAction<FileOrFolder | null>
>
) => void;
};

Expand Down Expand Up @@ -70,7 +78,7 @@
}
};

checkZattrsForMultiscales();

Check warning on line 81 in src/components/ui/FileBrowser/FileList.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook React.useEffect has missing dependencies: 'currentFileSharePath', 'files', and 'getFileFetchPath'. Either include them or remove the dependency array
}, [currentNavigationPath]);

return (
Expand Down
25 changes: 15 additions & 10 deletions src/components/ui/FileBrowser/FileRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@ import {
FolderIcon
} from '@heroicons/react/24/outline';

import type { File } from '@/shared.types';
import type { FileOrFolder } from '@/shared.types';
import { useFileBrowserContext } from '@/contexts/FileBrowserContext';
import { useZoneBrowserContext } from '@/contexts/ZoneBrowserContext';
import useHandleLeftClick from '@/hooks/useHandleLeftClick';
import { formatDate, formatFileSize } from '@/utils';


type FileRowProps = {
file: File;
file: FileOrFolder;
index: number;
selectedFiles: File[];
setSelectedFiles: React.Dispatch<React.SetStateAction<File[]>>;
displayFiles: File[];
selectedFiles: FileOrFolder[];
setSelectedFiles: React.Dispatch<React.SetStateAction<FileOrFolder[]>>;
displayFiles: FileOrFolder[];
showPropertiesDrawer: boolean;
setPropertiesTarget: React.Dispatch<React.SetStateAction<File | null>>;
setPropertiesTarget: React.Dispatch<
React.SetStateAction<FileOrFolder | null>
>;
handleRightClick: (
e: React.MouseEvent<HTMLDivElement>,
file: File,
selectedFiles: File[],
setSelectedFiles: React.Dispatch<React.SetStateAction<File[]>>,
setPropertiesTarget: React.Dispatch<React.SetStateAction<File | null>>
file: FileOrFolder,
selectedFiles: FileOrFolder[],
setSelectedFiles: React.Dispatch<React.SetStateAction<FileOrFolder[]>>,
setPropertiesTarget: React.Dispatch<
React.SetStateAction<FileOrFolder | null>
>
) => void;
};

Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/PropertiesDrawer/OverviewTable.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { File } from '@/shared.types';

import { FileOrFolder } from '@/shared.types';
import { formatDate, formatFileSize } from '@/utils';

export default function OverviewTable({ file }: { file: File | null }) {
export default function OverviewTable({ file }: { file: FileOrFolder | null }) {
return (
<div className="w-full overflow-hidden rounded-lg border border-surface mt-4">
<table className="w-full">
Expand Down
10 changes: 8 additions & 2 deletions src/components/ui/PropertiesDrawer/PermissionsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from 'react';
import { CheckIcon, MinusIcon } from '@heroicons/react/24/outline';
import { File } from '@/shared.types';

import { FileOrFolder } from '@/shared.types';
import { parsePermissions } from '@/utils';

export default function PermissionsTable({ file }: { file: File | null }) {

export default function PermissionsTable({
file
}: {
file: FileOrFolder | null;
}) {
const permissions = file ? parsePermissions(file.permissions) : null;

const PermissionIcon = ({ hasPermission }: { hasPermission: boolean }) =>
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/PropertiesDrawer/PropertiesDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import {
XMarkIcon
} from '@heroicons/react/24/outline';

import type { File } from '@/shared.types';
import type { FileOrFolder } from '@/shared.types';

import PermissionsTable from './PermissionsTable';
import OverviewTable from './OverviewTable';
import useCopyPath from '@/hooks/useCopyPath';
import { useZoneBrowserContext } from '@/contexts/ZoneBrowserContext';

type PropertiesDrawerProps = {
propertiesTarget: File | null;
propertiesTarget: FileOrFolder | null;
open: boolean;
setShowPropertiesDrawer: React.Dispatch<React.SetStateAction<boolean>>;
setShowPermissionsDialog: React.Dispatch<React.SetStateAction<boolean>>;
Expand Down
Loading
Loading