From 8817b42dd13bd4ce3d31ce6416e2dde7550a3218 Mon Sep 17 00:00:00 2001 From: van-go <35277477+van-go@users.noreply.github.com> Date: Mon, 18 Dec 2023 11:03:41 -0600 Subject: [PATCH 1/7] WP-47: if user is Guest, disable rename & trash --- .../DataFilesToolbar/DataFilesToolbar.jsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/client/src/components/DataFiles/DataFilesToolbar/DataFilesToolbar.jsx b/client/src/components/DataFiles/DataFilesToolbar/DataFilesToolbar.jsx index 63b22155a..152bb35e1 100644 --- a/client/src/components/DataFiles/DataFilesToolbar/DataFilesToolbar.jsx +++ b/client/src/components/DataFiles/DataFilesToolbar/DataFilesToolbar.jsx @@ -5,6 +5,7 @@ import PropTypes from 'prop-types'; import { Button } from '_common'; import getFilePermissions from 'utils/filePermissions'; import { useModal, useSelectedFiles, useFileListing } from 'hooks/datafiles'; +import { useSystemRole } from '../DataFilesProjectMembers/_cells/SystemRoleSelector'; import './DataFilesToolbar.scss'; export const ToolbarButton = ({ text, iconName, onClick, disabled }) => { @@ -45,7 +46,6 @@ const DataFilesToolbar = ({ scheme, api }) => { const reloadPage = () => { history.push(location.pathname); }; - const systemList = useSelector( (state) => state.systems.storage.configuration.filter((s) => !s.hidden), shallowEqual @@ -55,6 +55,21 @@ const DataFilesToolbar = ({ scheme, api }) => { (sys) => sys.system === params.system && sys.scheme === params.scheme ); + const { projectId } = useSelector( + (state) => state.projects.metadata + ); + + const authenticatedUser = useSelector( + (state) => state.authenticatedUser.user.username + ); + + const { query: authenticatedUserQuery } = useSystemRole( + projectId, + authenticatedUser + ); + + const isGuest = authenticatedUserQuery?.data?.role === 'GUEST' + const inTrash = useSelector((state) => { // remove leading slash from homeDir value const homeDir = selectedSystem?.homeDir?.slice(1); @@ -177,10 +192,10 @@ const DataFilesToolbar = ({ scheme, api }) => { 'areMultipleFilesOrFolderSelected', permissionParams ); - const canRename = getFilePermissions('rename', permissionParams); + const canRename = getFilePermissions('rename', permissionParams) && !isGuest; const canMove = getFilePermissions('move', permissionParams); const canCopy = getFilePermissions('copy', permissionParams); - const canTrash = getFilePermissions('trash', permissionParams); + const canTrash = getFilePermissions('trash', permissionParams) && !isGuest; const canCompress = getFilePermissions('compress', permissionParams); const canExtract = getFilePermissions('extract', permissionParams); const canMakePublic = From 0bc4814260334e26a4ae56ac5cccce1cec8a1991 Mon Sep 17 00:00:00 2001 From: van-go <35277477+van-go@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:24:06 -0600 Subject: [PATCH 2/7] css to Update button --- .../DataFilesProjectMembers.module.scss | 4 ++++ .../DataFilesProjectMembers/_cells/SystemRoleSelector.jsx | 5 +++-- .../DataFiles/DataFilesToolbar/DataFilesToolbar.jsx | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client/src/components/DataFiles/DataFilesProjectMembers/DataFilesProjectMembers.module.scss b/client/src/components/DataFiles/DataFilesProjectMembers/DataFilesProjectMembers.module.scss index e1fe53229..69f6d645e 100644 --- a/client/src/components/DataFiles/DataFilesProjectMembers/DataFilesProjectMembers.module.scss +++ b/client/src/components/DataFiles/DataFilesProjectMembers/DataFilesProjectMembers.module.scss @@ -69,6 +69,10 @@ composes: c-button--secondary from '../../../styles/components/c-button.css'; } +.ownership-button { + margin-left: 5px; +} + div > .project-role-selector { height: auto; /* overwrite .form-control height to accommodate dropdown selector next to small button in this instance */ } diff --git a/client/src/components/DataFiles/DataFilesProjectMembers/_cells/SystemRoleSelector.jsx b/client/src/components/DataFiles/DataFilesProjectMembers/_cells/SystemRoleSelector.jsx index 3ac8dd12b..f623c6b85 100644 --- a/client/src/components/DataFiles/DataFilesProjectMembers/_cells/SystemRoleSelector.jsx +++ b/client/src/components/DataFiles/DataFilesProjectMembers/_cells/SystemRoleSelector.jsx @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux'; import Cookies from 'js-cookie'; import fetch from 'cross-fetch'; import DropdownSelector from '_common/DropdownSelector'; -import { Button } from 'reactstrap'; +import { Button } from '_common'; import styles from '../DataFilesProjectMembers.module.scss'; import LoadingSpinner from '_common/LoadingSpinner'; @@ -109,7 +109,8 @@ const SystemRoleSelector = ({ projectId, username }) => { {data.role !== selectedRole && !isFetching && (