Skip to content

Commit

Permalink
refactor: apply PR requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Apr 26, 2024
1 parent 75e0f02 commit 2ff019e
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 160 deletions.
2 changes: 0 additions & 2 deletions cypress/support/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export const mockGetAccessibleItems = (items: MockItem[]): void => {
const page = parseInt(params.get('page') ?? '1', 10);
const pageSize = parseInt(params.get('pageSize') ?? '10', 10);

// as { page: number; pageSize: number };

// warning: we don't check memberships
const root = items.filter((i) => !i.path.includes('.'));

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@graasp/query-client": "3.4.1",
"@graasp/sdk": "4.4.0",
"@graasp/translations": "1.25.3",
"@graasp/ui": "github:graasp/graasp-ui#row-menu",
"@graasp/ui": "4.16.0",
"@mui/icons-material": "5.15.14",
"@mui/lab": "5.0.0-alpha.169",
"@mui/material": "5.15.14",
Expand Down
1 change: 0 additions & 1 deletion src/components/collection/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const useCopyAction = (id?: string) => {
ids: [id],
};

// if the location to copy the item is MyItems or SharedItems root, then set the payload.to argument to be undefined
payload.to = to;

copyItems(payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Alert, Skeleton } from '@mui/material';
import { ItemType, PermissionLevel } from '@graasp/sdk';
import { RowMenuProps, RowMenus } from '@graasp/ui';

import { useLibraryTranslation } from '../../../config/i18n';
import LIBRARY from '../../../langs/constants';
import { QueryClientContext } from '../../QueryClientContext';

interface AccessibleNavigationTreeProps {
Expand All @@ -20,8 +22,8 @@ const AccessibleNavigationTree = ({
onNavigate,
selectedId,
}: AccessibleNavigationTreeProps): JSX.Element => {
const { t } = useLibraryTranslation();
const [page, setPage] = useState(1);
// todo: show only items with admin rights
const { hooks } = useContext(QueryClientContext);
const { data: accessibleItems, isLoading } = hooks.useAccessibleItems(
{
Expand Down Expand Up @@ -59,7 +61,7 @@ const AccessibleNavigationTree = ({
);
}

return <Alert severity="error">An unexpected error happened</Alert>;
return <Alert severity="error">{t(LIBRARY.UNEXPECTED_ERROR_MESSAGE)}</Alert>;
};

export default AccessibleNavigationTree;
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ const ChildrenNavigationTree = ({
const { hooks } = useContext(QueryClientContext);
const { data: children, isLoading } = hooks.useChildren(
selectedNavigationItem.id,
{ types: [ItemType.FOLDER] },
);
// TODO: use hook's filter when available
const folders = children?.filter((f) => f.type === ItemType.FOLDER);

if (children) {
return (
<RowMenus
elements={folders}
elements={children}
onNavigate={onNavigate}
selectedId={selectedId}
onClick={onClick}
Expand All @@ -57,7 +56,7 @@ const ChildrenNavigationTree = ({
</>
);
}
return <Alert severity="error">An unexpected error happened</Alert>;
return <Alert severity="error">{t(LIBRARY.UNEXPECTED_ERROR_MESSAGE)}</Alert>;
};

export default ChildrenNavigationTree;
11 changes: 4 additions & 7 deletions src/components/collection/copyModal/RootNavigationTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ const RootNavigationTree = ({
},
{ pageSize: 5 },
);
const recentFolders = recentItems?.data?.filter(
({ type }) => type === ItemType.FOLDER,
);

if (recentItems) {
if (recentItems?.data?.length) {
return (
<>
<Typography color="darkgrey" variant="subtitle2">
Expand All @@ -53,13 +50,13 @@ const RootNavigationTree = ({
onClick={onClick}
// root items cannot be disabled - but they are disabled by the button
/>
{recentFolders && (
{recentItems && (
<>
<Typography color="darkgrey" variant="subtitle2">
{t(LIBRARY.COPY_MODAL_RECENT_TITLE)}
</Typography>
<RowMenus
elements={recentFolders}
elements={recentItems.data}
onNavigate={onNavigate}
selectedId={selectedId}
onClick={onClick}
Expand All @@ -81,7 +78,7 @@ const RootNavigationTree = ({
);
}

return <Alert severity="error">An unexpected error happened</Alert>;
return <Alert severity="error">{t(LIBRARY.UNEXPECTED_ERROR_MESSAGE)}</Alert>;
};

export default RootNavigationTree;
Loading

0 comments on commit 2ff019e

Please sign in to comment.