Copilot commented on code in PR #527: URL: https://github.com/apache/airavata/pull/527#discussion_r2158143307
########## modules/research-framework/research-service/src/main/java/org/apache/airavata/research/service/model/repo/ResourceLikeRepository.java: ########## @@ -0,0 +1,43 @@ +/** +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.apache.airavata.research.service.model.repo; + +import java.util.List; +import org.apache.airavata.research.service.enums.StateEnum; +import org.apache.airavata.research.service.model.entity.Resource; +import org.apache.airavata.research.service.model.entity.ResourceLike; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ResourceLikeRepository extends JpaRepository<ResourceLike, String> { + + boolean existsByResourceAndOwnerId(Resource resource, String ownerId); + + List<ResourceLike> findByResource(Resource resource); + + List<ResourceLike> findByResourceAndOwnerId(Resource resource, String ownerId); + + List<ResourceLike> findByOwnerId(String ownerId); + + List<ResourceLike> findByOwnerIdAndResourceState(String loggedInUser, StateEnum stateEnum); Review Comment: Spring Data JPA won’t find `resourceState` on `ResourceLike`. If you intend to filter by the nested `Resource.state`, rename to `findByOwnerIdAndResource_State` or add a dedicated field. ```suggestion List<ResourceLike> findByOwnerIdAndResource_State(String loggedInUser, StateEnum stateEnum); ``` ########## modules/research-framework/portal/src/components/resources/ResourceOptions.tsx: ########## @@ -0,0 +1,69 @@ +import {Resource} from "@/interfaces/ResourceType.ts"; +import {Button, ButtonProps, Menu, VStack} from "@chakra-ui/react"; +import {BsThreeDots} from "react-icons/bs"; +import {DeleteResourceButton} from "@/components/resources/DeleteResourceButton.tsx"; +import {LikeResourceButton} from "@/components/resources/LikeResourceButton.tsx"; +import {useAuth} from "react-oidc-context"; + +export const ResourceOptions = ({resource, deleteable = true, onDeleteSuccess, onUnlikeSuccess}: + { + resource: Resource, + deleteable: boolean, + onDeleteSuccess: () => void, + onUnlikeSuccess: (resourceId: string) => void + }) => { + + const auth = useAuth(); + if (!auth.isAuthenticated) { + return null; + } + + return ( + <> + <Menu.Root> + <Menu.Trigger _hover={{ + cursor: 'pointer', + }}> + <BsThreeDots/> + </Menu.Trigger> + <Menu.Positioner> + <Menu.Content> + <VStack gap={2} alignItems={'start'}> + <LikeResourceButton resource={resource} onSuccess={onUnlikeSuccess}/> + {deleteable && <DeleteResourceButton resource={resource} onSuccess={onDeleteSuccess}/>} + </VStack> + </Menu.Content> + </Menu.Positioner> + </Menu.Root> Review Comment: Chakra UI’s `Menu` API doesn't expose `Root`, `Trigger`, or `Positioner`. You may need to import a Radix menu or switch to Chakra’s `<Menu>`, `<MenuButton>`, `<MenuList>`, `<MenuItem>` components. ```suggestion <Menu> <MenuButton _hover={{ cursor: 'pointer', }} > <BsThreeDots/> </MenuButton> <MenuList> <MenuItem> <LikeResourceButton resource={resource} onSuccess={onUnlikeSuccess}/> </MenuItem> {deleteable && ( <MenuItem> <DeleteResourceButton resource={resource} onSuccess={onDeleteSuccess}/> </MenuItem> )} </MenuList> </Menu> ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
