Skip to content

Commit

Permalink
fix: only show admin and write accessible in move modal (#960)
Browse files Browse the repository at this point in the history
* fix: only show admin and write accessible in move modal
  • Loading branch information
pyphilia authored Jan 19, 2024
1 parent 8da10f0 commit 94063f7
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 27 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@graasp/chatbox": "3.0.1",
"@graasp/query-client": "2.2.1",
"@graasp/sdk": "3.3.0",
"@graasp/translations": "1.21.1",
"@graasp/query-client": "2.3.0",
"@graasp/sdk": "3.4.1",
"@graasp/translations": "1.22.1",
"@graasp/ui": "4.3.1",
"@mui/icons-material": "5.14.19",
"@mui/lab": "5.0.0-alpha.151",
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/PlayerViewButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const PlayerViewButton = ({ itemId }: Props): JSX.Element => {
const { t: translateBuilder } = useBuilderTranslation();

const onClick = () => {
redirect(buildGraaspPlayerView(itemId), {
redirect(window, buildGraaspPlayerView(itemId), {
name: buildPlayerTabName(itemId),
openInNewTab: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/item/publish/ItemPublishTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const ItemPublishTab = ({

const handleClick = () => {
const url = CC_LICENSE_ABOUT_URL;
redirect(url, { openInNewTab: true });
redirect(window, url, { openInNewTab: true });
};

const displayItemValidationMessage = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/Redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { HOME_PATH } from '../../config/paths';

const Redirect = (): JSX.Element => {
useEffect(() => {
redirectToSavedUrl(HOME_PATH);
redirectToSavedUrl(window, HOME_PATH);
}, []);

return <RedirectionContent link={HOME_PATH} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useState } from 'react';

import { Pagination, Stack } from '@mui/material';

import { PermissionLevel } from '@graasp/sdk';

import { hooks } from '@/config/queryClient';

import RowMenu, { RowMenuProps } from './RowMenu';
Expand All @@ -24,7 +26,10 @@ const AccessibleNavigationTree = ({
// todo: to change with real recent items (most used)
const [page, setPage] = useState(1);
// todo: show only items with admin rights
const { data: accessibleItems } = hooks.useAccessibleItems({}, { page });
const { data: accessibleItems } = hooks.useAccessibleItems(
{ permissions: [PermissionLevel.Write, PermissionLevel.Admin] },
{ page },
);

const nbPages = accessibleItems
? Math.ceil(accessibleItems.totalCount / PAGE_SIZE)
Expand Down
8 changes: 6 additions & 2 deletions src/components/main/itemSelectionModal/RootNavigationTree.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Typography } from '@mui/material';

import { DiscriminatedItem, ItemType } from '@graasp/sdk';
import { DiscriminatedItem, ItemType, PermissionLevel } from '@graasp/sdk';

import { useBuilderTranslation } from '@/config/i18n';
import { hooks } from '@/config/queryClient';
Expand Down Expand Up @@ -29,7 +29,11 @@ const RootNavigationTree = ({
const { t: translateBuilder } = useBuilderTranslation();

// todo: to change with real recent items (most used)
const { data: recentItems } = hooks.useAccessibleItems({}, { pageSize: 5 });
const { data: recentItems } = hooks.useAccessibleItems(
// you can move into an item you have at least write permission
{ permissions: [PermissionLevel.Admin, PermissionLevel.Write] },
{ pageSize: 5 },
);
const recentFolders = recentItems?.data?.filter(
({ type }) => type === ItemType.FOLDER,
);
Expand Down
36 changes: 18 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1233,12 +1233,12 @@ __metadata:
languageName: node
linkType: hard

"@graasp/query-client@npm:2.2.1":
version: 2.2.1
resolution: "@graasp/query-client@npm:2.2.1"
"@graasp/query-client@npm:2.3.0":
version: 2.3.0
resolution: "@graasp/query-client@npm:2.3.0"
dependencies:
"@graasp/sdk": "npm:3.3.0"
"@graasp/translations": "npm:1.21.1"
"@graasp/sdk": "npm:3.4.1"
"@graasp/translations": "npm:1.22.1"
axios: "npm:0.27.2"
crypto-js: "npm:4.2.0"
http-status-codes: "npm:2.3.0"
Expand All @@ -1247,7 +1247,7 @@ __metadata:
uuid: "npm:9.0.1"
peerDependencies:
react: ^17.0.0 || ^18.0.0
checksum: bad1c3a4163f38e45f0f64d8beb28eb6ca6fd4cf123d971be9421a6012d0d2860c71cc0c71b14bf7d46ea3afe73355a32823e037d0216caa8154905d0d408f8f
checksum: 7cbf30cc71c27e19b50d896899b2bed3de924c4d7b0d09346198ee07c0d640261908fdb718cce11b00888f2333b581e175ca2d31bac766163b27ef069a29abfa
languageName: node
linkType: hard

Expand Down Expand Up @@ -1276,12 +1276,12 @@ __metadata:
languageName: node
linkType: hard

"@graasp/translations@npm:1.21.1":
version: 1.21.1
resolution: "@graasp/translations@npm:1.21.1"
"@graasp/translations@npm:1.22.1":
version: 1.22.1
resolution: "@graasp/translations@npm:1.22.1"
dependencies:
i18next: "npm:23.7.7"
checksum: d95ac9cf2f2a587d6779d5b28f9c95f2f5410d3d28235b78cdf4e8ad36acd6b6ca4ac90831a6b28fecd91c6fad080f1230ab72c88295cf7742725bfa8a10c416
i18next: "npm:23.7.16"
checksum: 29043007a9926ff54236101c41ceb92eead09d8ce99edf46943790171f3275fb2cc1acd552bfa605247c42b4866bbf1f83dd889da3f571d388eca5f2dd598e17
languageName: node
linkType: hard

Expand Down Expand Up @@ -6310,9 +6310,9 @@ __metadata:
"@emotion/react": "npm:11.11.1"
"@emotion/styled": "npm:11.11.0"
"@graasp/chatbox": "npm:3.0.1"
"@graasp/query-client": "npm:2.2.1"
"@graasp/sdk": "npm:3.3.0"
"@graasp/translations": "npm:1.21.1"
"@graasp/query-client": "npm:2.3.0"
"@graasp/sdk": "npm:3.4.1"
"@graasp/translations": "npm:1.22.1"
"@graasp/ui": "npm:4.3.1"
"@mui/icons-material": "npm:5.14.19"
"@mui/lab": "npm:5.0.0-alpha.151"
Expand Down Expand Up @@ -6685,12 +6685,12 @@ __metadata:
languageName: node
linkType: hard

"i18next@npm:23.7.7":
version: 23.7.7
resolution: "i18next@npm:23.7.7"
"i18next@npm:23.7.16":
version: 23.7.16
resolution: "i18next@npm:23.7.16"
dependencies:
"@babel/runtime": "npm:^7.23.2"
checksum: c8d112f5bbe62b3402b0fc47094f85e6ae6f939ff0b3299c5f2b3d30e05125184ae3faa10abfc14e21ea7f8dc78526455c251dc7e5eb40cf1a204257f22e6071
checksum: 77e74c07a73316f6fb6678a5a3e8ce58a6e66be457dd1ccd23941e9fc57ad8e1da55193fa6328c70b86073337b776cd267f3c13c6309f548b3116f27a1e41787
languageName: node
linkType: hard

Expand Down

0 comments on commit 94063f7

Please sign in to comment.