Skip to content
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

Bug/wp 47 fix shared workspace manage team modal #922

Merged
merged 10 commits into from
Dec 22, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -109,7 +109,8 @@ const SystemRoleSelector = ({ projectId, username }) => {
</DropdownSelector>
{data.role !== selectedRole && !isFetching && (
<Button
style={{ marginLeft: '5px' }}
type="secondary"
size="small"
className={styles['ownership-button']}
onClick={() => setSystemRole(selectedRole)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -55,6 +56,19 @@ 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);
Expand Down Expand Up @@ -177,10 +191,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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ describe('DataFilesToolbar', () => {
},
listing: { selected: { FilesListing: [] } },
systems: systemsFixture,
projects: { metadata: [] },
authenticatedUser: { user: { username: 'testuser' } },
}),
createMemoryHistory()
);
Expand Down Expand Up @@ -82,6 +84,8 @@ describe('DataFilesToolbar', () => {
},
listing: { selected: { FilesListing: [] } },
systems: systemsFixture,
projects: { metadata: [] },
authenticatedUser: { user: { username: 'testuser' } },
}),
createMemoryHistory()
);
Expand Down Expand Up @@ -114,6 +118,8 @@ describe('DataFilesToolbar', () => {
},
listing: { selected: { FilesListing: [] } },
systems: systemsFixture,
projects: { metadata: [] },
authenticatedUser: { user: { username: 'testuser' } },
}),
createMemoryHistory()
);
Expand Down Expand Up @@ -146,6 +152,8 @@ describe('DataFilesToolbar', () => {
},
listing: { selected: { FilesListing: [] } },
systems: systemsFixture,
projects: { metadata: [] },
authenticatedUser: { user: { username: 'testuser' } },
}),
createMemoryHistory()
);
Expand Down Expand Up @@ -187,6 +195,8 @@ describe('DataFilesToolbar', () => {
operationStatus: { trash: false },
},
systems: systemsFixture,
projects: { metadata: [] },
authenticatedUser: { user: { username: 'testuser' } },
}),
createMemoryHistory()
);
Expand Down Expand Up @@ -218,6 +228,8 @@ describe('DataFilesToolbar', () => {
},
//listing: { } },
systems: systemsFixture,
projects: { metadata: [] },
authenticatedUser: { user: { username: 'testuser' } },
}),
createMemoryHistory()
);
Expand Down