Merge pull request #22 from utopia-os/fix-linting

fix(other): mix
This commit is contained in:
antontranelis 2024-10-31 07:57:08 +01:00 committed by GitHub
commit 55a34df9ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 28 additions and 26 deletions

4
package-lock.json generated
View File

@ -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",

View File

@ -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/",

View File

@ -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;
}

View File

@ -116,7 +116,7 @@
.staff-snake-icon {
position: relative;
top: -36px;
top: -35px;
left: 4px;
width: 24px;
}

View File

@ -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]
);

View File

@ -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" &&
<TabsView userType={userType} attestations={attestations} setUrlParams={setUrlParams} item={item} loading={loading} offers={offers} needs={needs} relations={relations} updatePermission={updatePermission} linkItem={(id) => linkItem(id, item, updateItem)} unlinkItem={(id) => unlinkItem(id, item, updateItem)}/>
<TabsView userType={userType} attestations={attestations} item={item} loading={loading} offers={offers} needs={needs} relations={relations} updatePermission={updatePermission} linkItem={(id) => linkItem(id, item, updateItem)} unlinkItem={(id) => unlinkItem(id, item, updateItem)}/>
}
</>

View File

@ -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<any>, userType: string, item: Item, offers: Array<Tag>, needs: Array<Tag>, relations: Array<Item>, updatePermission: boolean, loading: boolean, linkItem: (id: string) => Promise<void>, unlinkItem: (id: string) => Promise<void>, setUrlParams: any }) => {
export const TabsView = ({ attestations, userType, item, offers, needs, relations, updatePermission, loading, linkItem, unlinkItem }: { attestations: Array<any>, userType: string, item: Item, offers: Array<Tag>, needs: Array<Tag>, relations: Array<Item>, updatePermission: boolean, loading: boolean, linkItem: (id: string) => Promise<void>, unlinkItem: (id: string) => Promise<void> }) => {
const addFilterTag = useAddFilterTag();
const [activeTab, setActiveTab] = useState<number>();
@ -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]);

View File

@ -37,7 +37,7 @@ const addIcon = (icon: string) => {
case "puzzle":
return '<svg class="group-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#fff" width="1.6em" height="1.6em"><path d="M11.25 5.337c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.036 1.007-1.875 2.25-1.875S15 2.34 15 3.375c0 .369-.128.713-.349 1.003-.215.283-.401.604-.401.959 0 .332.278.598.61.578 1.91-.114 3.79-.342 5.632-.676a.75.75 0 0 1 .878.645 49.17 49.17 0 0 1 .376 5.452.657.657 0 0 1-.66.664c-.354 0-.675-.186-.958-.401a1.647 1.647 0 0 0-1.003-.349c-1.035 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401.31 0 .557.262.534.571a48.774 48.774 0 0 1-.595 4.845.75.75 0 0 1-.61.61c-1.82.317-3.673.533-5.555.642a.58.58 0 0 1-.611-.581c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.035-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959a.641.641 0 0 1-.658.643 49.118 49.118 0 0 1-4.708-.36.75.75 0 0 1-.645-.878c.293-1.614.504-3.257.629-4.924A.53.53 0 0 0 5.337 15c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.036 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.369 0 .713.128 1.003.349.283.215.604.401.959.401a.656.656 0 0 0 .659-.663 47.703 47.703 0 0 0-.31-4.82.75.75 0 0 1 .83-.832c1.343.155 2.703.254 4.077.294a.64.64 0 0 0 .657-.642Z" /></svg>'
case "staff-snake":
return '<svg class="staff-snake-icon" stroke="currentColor" fill="#fff" stroke-width="0" viewBox="0 0 384 512" height="1.6em" width="1.6em" xmlns="http://www.w3.org/2000/svg"><path d="M222.6 43.2l-.1 4.8H288c53 0 96 43 96 96s-43 96-96 96H248V160h40c8.8 0 16-7.2 16-16s-7.2-16-16-16H248 220l-4.5 144H256c53 0 96 43 96 96s-43 96-96 96H240V384h16c8.8 0 16-7.2 16-16s-7.2-16-16-16H213l-3.1 99.5L208.5 495l0 1c-.3 8.9-7.6 16-16.5 16s-16.2-7.1-16.5-16l0-1-1-31H136c-22.1 0-40-17.9-40-40s17.9-40 40-40h36l-1-32H152c-53 0-96-43-96-96c0-47.6 34.6-87.1 80-94.7V256c0 8.8 7.2 16 16 16h16.5L164 128H136 122.6c-9 18.9-28.3 32-50.6 32H56c-30.9 0-56-25.1-56-56S25.1 48 56 48h8 8 89.5l-.1-4.8L161 32c0-.7 0-1.3 0-1.9c.5-16.6 14.1-30 31-30s30.5 13.4 31 30c0 .6 0 1.3 0 1.9l-.4 11.2zM64 112a16 16 0 1 0 0-32 16 16 0 1 0 0 32z"></path></svg>'
return '<svg class="staff-snake-icon" stroke="currentColor" fill="#fff" stroke-width="0" viewBox="0 0 384 512" height="1.4em" width="1.4em" xmlns="http://www.w3.org/2000/svg"><path d="M222.6 43.2l-.1 4.8H288c53 0 96 43 96 96s-43 96-96 96H248V160h40c8.8 0 16-7.2 16-16s-7.2-16-16-16H248 220l-4.5 144H256c53 0 96 43 96 96s-43 96-96 96H240V384h16c8.8 0 16-7.2 16-16s-7.2-16-16-16H213l-3.1 99.5L208.5 495l0 1c-.3 8.9-7.6 16-16.5 16s-16.2-7.1-16.5-16l0-1-1-31H136c-22.1 0-40-17.9-40-40s17.9-40 40-40h36l-1-32H152c-53 0-96-43-96-96c0-47.6 34.6-87.1 80-94.7V256c0 8.8 7.2 16 16 16h16.5L164 128H136 122.6c-9 18.9-28.3 32-50.6 32H56c-30.9 0-56-25.1-56-56S25.1 48 56 48h8 8 89.5l-.1-4.8L161 32c0-.7 0-1.3 0-1.9c.5-16.6 14.1-30 31-30s30.5 13.4 31 30c0 .6 0 1.3 0 1.9l-.4 11.2zM64 112a16 16 0 1 0 0-32 16 16 0 1 0 0 32z"></path></svg>'
default:
return "";
}

View File

@ -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`