diff --git a/package-lock.json b/package-lock.json index acdd2041..411019d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "utopia-ui", - "version": "3.0.1", + "version": "3.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "utopia-ui", - "version": "3.0.1", + "version": "3.0.5", "license": "MIT", "dependencies": { "@heroicons/react": "^2.0.17", diff --git a/package.json b/package.json index 1b42f527..42112809 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "utopia-ui", - "version": "3.0.1", + "version": "3.0.5", "description": "Reuseable React Components to build mapping apps for real life communities and networks", "repository": "https://github.com/utopia-os/utopia-ui", "homepage:": "https://utopia-os.org/", diff --git a/src/Components/Map/Subcomponents/AddButton.tsx b/src/Components/Map/Subcomponents/AddButton.tsx index f5d6c7ff..84073aa6 100644 --- a/src/Components/Map/Subcomponents/AddButton.tsx +++ b/src/Components/Map/Subcomponents/AddButton.tsx @@ -8,11 +8,11 @@ export default function AddButton({ triggerAction }: { triggerAction: React.Disp const layers = useLayers(); const hasUserPermission = useHasUserPermission(); - const canAddItems = () => { + const canAddItems = () => { let canAdd = false; layers.map(layer => { if (layer.api?.createItem && hasUserPermission(layer.api.collectionName!, "create", undefined, layer) && layer.listed) canAdd = true; - }) + }) return canAdd; } diff --git a/src/Components/Map/UtopiaMap.css b/src/Components/Map/UtopiaMap.css index 70812368..389e3469 100644 --- a/src/Components/Map/UtopiaMap.css +++ b/src/Components/Map/UtopiaMap.css @@ -116,7 +116,7 @@ .staff-snake-icon { position: relative; - top: -36px; + top: -35px; left: 4px; width: 24px; } diff --git a/src/Components/Map/hooks/usePermissions.tsx b/src/Components/Map/hooks/usePermissions.tsx index cb11a81f..b9d02afc 100644 --- a/src/Components/Map/hooks/usePermissions.tsx +++ b/src/Components/Map/hooks/usePermissions.tsx @@ -96,30 +96,35 @@ function usePermissionsManager(initialPermissions: Permission[]): { ); }; - if (permissions.length === 0) return true; - else if (user && user.role === adminRole) return true; + // Bedingung für leere Berechtigungen nur, wenn NICHT item und create + if (permissions.length === 0 && !(collectionName === "item" && action === "create")) return true; + else if (user && user.role.id === adminRole) return true; else { return permissions.some(p => p.action === action && p.collection === collectionName && ( - (p.role === user?.role && + // Neue Bedingung für "item" und "create" + (collectionName === "item" && action === "create" && layer?.public_edit_items === true) || ( - !item || evaluatePermissions(p.permissions) - )) || - (p.role == null && - ( - (layer?.public_edit_items || item?.layer?.public_edit_items) && - (!item || evaluatePermissions(p.permissions)) - )) + (p.policy.name === user?.role.name && + ( + !item || evaluatePermissions(p.permissions) + )) || + (p.policy == null && + ( + (layer?.public_edit_items || item?.layer?.public_edit_items) && + (!item || evaluatePermissions(p.permissions)) + )) + ) ) ); } }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [permissions, user] + [permissions, user, adminRole] ); + diff --git a/src/Components/Profile/ProfileView.tsx b/src/Components/Profile/ProfileView.tsx index 8ce0efba..d7b7e4e7 100644 --- a/src/Components/Profile/ProfileView.tsx +++ b/src/Components/Profile/ProfileView.tsx @@ -140,8 +140,6 @@ export function ProfileView({ userType, attestationApi }: { userType: string , a setTemplate(item?.layer?.itemType.template || userType); }, [userType, item]) - const [/* urlParams, */ setUrlParams] = useState(new URLSearchParams(location.search)); - return ( <> @@ -161,7 +159,7 @@ export function ProfileView({ userType, attestationApi }: { userType: string , a } {template == "tabs" && - linkItem(id, item, updateItem)} unlinkItem={(id) => unlinkItem(id, item, updateItem)}/> + linkItem(id, item, updateItem)} unlinkItem={(id) => unlinkItem(id, item, updateItem)}/> } diff --git a/src/Components/Profile/Templates/TabsView.tsx b/src/Components/Profile/Templates/TabsView.tsx index 00ef9532..d8deb7b0 100644 --- a/src/Components/Profile/Templates/TabsView.tsx +++ b/src/Components/Profile/Templates/TabsView.tsx @@ -11,7 +11,7 @@ import { useAssetApi } from '../../AppShell/hooks/useAssets' import { timeAgo } from '../../../Utils/TimeAgo' // eslint-disable-next-line no-unused-vars -export const TabsView = ({ attestations, userType, item, offers, needs, relations, updatePermission, loading, linkItem, unlinkItem, setUrlParams }: { attestations: Array, userType: string, item: Item, offers: Array, needs: Array, relations: Array, updatePermission: boolean, loading: boolean, linkItem: (id: string) => Promise, unlinkItem: (id: string) => Promise, setUrlParams: any }) => { +export const TabsView = ({ attestations, userType, item, offers, needs, relations, updatePermission, loading, linkItem, unlinkItem }: { attestations: Array, userType: string, item: Item, offers: Array, needs: Array, relations: Array, updatePermission: boolean, loading: boolean, linkItem: (id: string) => Promise, unlinkItem: (id: string) => Promise }) => { const addFilterTag = useAddFilterTag(); const [activeTab, setActiveTab] = useState(); @@ -42,7 +42,6 @@ export const TabsView = ({ attestations, userType, item, offers, needs, relation params.set("tab", `${id}`); const newUrl = location.pathname + "?" + params.toString(); window.history.pushState({}, '', newUrl); - setUrlParams(params); // eslint-disable-next-line react-hooks/exhaustive-deps }, [location.pathname]); diff --git a/src/Utils/MarkerIconFactory.ts b/src/Utils/MarkerIconFactory.ts index 5882785f..0a3b705a 100644 --- a/src/Utils/MarkerIconFactory.ts +++ b/src/Utils/MarkerIconFactory.ts @@ -37,7 +37,7 @@ const addIcon = (icon: string) => { case "puzzle": return '' case "staff-snake": - return '' + return '' default: return ""; } diff --git a/src/types.ts b/src/types.ts index 5e80b58f..7ec77af2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -130,7 +130,7 @@ export interface UserApi { export type UserItem = { id?: string; - role?: string; + role?: any; email?: string; password?: string; profile?: Profile; @@ -158,7 +158,7 @@ export type PermissionCondition = { export type Permission = { id?: string; - role: string; + policy: any; collection: string; action: PermissionAction; permissions?: { // Optional, für spezifische Bedingungen wie `user_created`