diff --git a/components/AccessBox.tsx b/components/AccessBox.tsx index 036eebc2..42b12d31 100644 --- a/components/AccessBox.tsx +++ b/components/AccessBox.tsx @@ -8,7 +8,6 @@ import { useMutation, useQuery, useQueryClient } from "react-query"; import BaseAPIServices from "../services/BaseAPIServices"; import { accessRoles } from "@/types/AccessRoles"; -import { getOwner } from "utils/getOwner"; import { notifyOthers } from "@/services/notifyOthers"; import style from "./AccessBox.module.scss"; import { unknownErrorToString } from "utils/isError"; @@ -42,7 +41,6 @@ export function AccessBox(props: {
void }) { } function MiddleSection(props: { - owner: string; users: userAccess[]; vsmId: number; loading: boolean; diff --git a/components/RoleSelect.tsx b/components/RoleSelect.tsx index cb826cc7..804703de 100644 --- a/components/RoleSelect.tsx +++ b/components/RoleSelect.tsx @@ -14,7 +14,6 @@ export const RoleSelect = (props: { onChange={(event) => props.onChange(event.target.value)} disabled={props.disabled} > - diff --git a/components/UserItem.tsx b/components/UserItem.tsx index 97521ed2..87f36513 100644 --- a/components/UserItem.tsx +++ b/components/UserItem.tsx @@ -45,8 +45,6 @@ export const UserItem = ({ ); - } else if (role === "Owner") { - return "Owner"; } else { return ( (
- You need to be owner or admin to manage sharing + You need to be {accessRoles.Contributor} to manage sharing
); - const UserItems = () => - users?.map((user) => ( - onRoleChange(user, role)} - onRemove={() => onRemove(user)} - disabled={!isAdmin} - /> - )); + const UserItems = () => { + const isSingleUser = users && users.length === 1; + return ( + users && + users.map((user) => ( + onRoleChange(user, role)} + onRemove={() => onRemove(user)} + disabled={isSingleUser} + /> + )) + ); + }; const SearchedUserItems = () => usersSearched diff --git a/components/canvas/hooks/useAccess.tsx b/components/canvas/hooks/useAccess.tsx index a916fc34..59bafdd7 100644 --- a/components/canvas/hooks/useAccess.tsx +++ b/components/canvas/hooks/useAccess.tsx @@ -2,14 +2,15 @@ import { Project } from "@/types/Project"; import { getMyAccess } from "@/utils/getMyAccess"; import router from "next/router"; import { useUserAccount } from "./useUserAccount"; +import { accessRoles } from "@/types/AccessRoles"; export const useAccess = (project: Project) => { const { version } = router.query; + const { Contributor, Reader } = accessRoles; const account = useUserAccount(); const myAccess = getMyAccess(project, account); - const userCanEdit = !version && myAccess !== "Reader"; - const isAdmin = myAccess === "Admin" || myAccess === "Owner"; - + const userCanEdit = !version && myAccess !== Reader; + const isAdmin = myAccess === Contributor; return { myAccess, userCanEdit, diff --git a/layouts/canvas.tsx b/layouts/canvas.tsx index c5dd7feb..3fbd8a09 100644 --- a/layouts/canvas.tsx +++ b/layouts/canvas.tsx @@ -39,7 +39,6 @@ import { UserMenu } from "@/components/AppHeader/UserMenu"; import { disableKeyboardZoomShortcuts } from "@/utils/disableKeyboardZoomShortcuts"; import { disableMouseWheelZoom } from "@/utils/disableMouseWheelZoom"; import { getMyAccess } from "@/utils/getMyAccess"; -import { getOwner } from "utils/getOwner"; import { notifyOthers } from "@/services/notifyOthers"; import packageJson from "../package.json"; import styles from "./default.layout.module.scss"; @@ -48,6 +47,7 @@ import { useRouter } from "next/router"; import { useProjectId } from "@/hooks/useProjectId"; import { EditableTitle } from "components/EditableTitle"; import { getProjectName } from "@/utils/getProjectName"; +import { accessRoles } from "@/types/AccessRoles"; export const CanvasLayout = ({ children }: { children: ReactNode }) => { const isAuthenticated = useIsAuthenticated(); @@ -107,9 +107,10 @@ export const CanvasLayout = ({ children }: { children: ReactNode }) => { const { accounts } = useMsal(); const account = useAccount(accounts[0] || {}); const myAccess = getMyAccess(project ?? null, account); - const userCanEdit = myAccess !== "Reader"; + const { Contributor, Reader } = accessRoles; + const userCanEdit = myAccess !== Reader; const userCannotEdit = !userCanEdit; - const isAdmin = myAccess === "Admin" || myAccess === "Owner"; + const isAdmin = myAccess === Contributor; const projectName = getProjectName(project); const [visibleShareScrim, setVisibleShareScrim] = useState(false); @@ -274,7 +275,7 @@ export const CanvasLayout = ({ children }: { children: ReactNode }) => { { title={`${ isAdmin ? "Delete the current process" - : "Only the creator can delete this process" + : "Only the Contributor can delete this process" }`} disabled={!isAdmin} onKeyDown={(e) => { @@ -308,13 +309,6 @@ export const CanvasLayout = ({ children }: { children: ReactNode }) => { Delete process - {project && ( - - - Owner: {getOwner(project)} - - - )}
@@ -379,7 +373,6 @@ export const CanvasLayout = ({ children }: { children: ReactNode }) => { - setVisibleDeleteScrim(false)} @@ -388,7 +381,7 @@ export const CanvasLayout = ({ children }: { children: ReactNode }) => { >
{isDeleting ? ( - Deleting... + Deleting... ) : ( <>
@@ -402,17 +395,12 @@ export const CanvasLayout = ({ children }: { children: ReactNode }) => { )}

Are you sure you want to delete this process? By doing so you - will delete all versions of Current and To-be processes, - neither of which will be recoverable. + will delete + ALL VERSIONS as they + will not be recoverable.

-
+