You are viewing a plain text version of this content. The canonical link for it is here.
Posted to custos@airavata.apache.org by "ganning127 (via GitHub)" <gi...@apache.org> on 2025/06/20 06:21:03 UTC
[PR] Support liking resources [airavata]
ganning127 opened a new pull request, #527:
URL: https://github.com/apache/airavata/pull/527
Added:
- ability to like all resources
- page to view liked resources
https://github.com/user-attachments/assets/d97edb68-e8e8-4429-98ba-8c53e0341d43
--
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: custos-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "ganning127 (via GitHub)" <gi...@apache.org>.
ganning127 commented on PR #527:
URL: https://github.com/apache/airavata/pull/527#issuecomment-2993326400
Thanks for the feedback, @lahirujayathilake! I've pushed my fixes
--
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: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "ganning127 (via GitHub)" <gi...@apache.org>.
ganning127 commented on code in PR #527:
URL: https://github.com/apache/airavata/pull/527#discussion_r2158149388
##########
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:
This suggestion by Copilot is wrong
--
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: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "lahirujayathilake (via GitHub)" <gi...@apache.org>.
lahirujayathilake commented on code in PR #527:
URL: https://github.com/apache/airavata/pull/527#discussion_r2159498929
##########
modules/research-framework/research-service/src/main/java/org/apache/airavata/research/service/controller/LikesController.java:
##########
@@ -0,0 +1,66 @@
+/**
Review Comment:
I believe it is better to move all the endpoints to the existing resource controller instead of creating a separate controller class
##########
modules/research-framework/portal/src/components/resources/LikeResourceButton.tsx:
##########
Review Comment:
I prefer to change the wording to 'Star' instead of 'Like'. WDYT @yasithdev?
##########
modules/research-framework/research-service/src/main/java/org/apache/airavata/research/service/controller/ResourceController.java:
##########
@@ -57,7 +57,7 @@ public class ResourceController {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceController.class);
- @org.springframework.beans.factory.annotation.Autowired
+ @Autowired
Review Comment:
better to use constructor-based dependency injection as a practice
##########
modules/research-framework/portal/src/components/resources/LikeResourceButton.tsx:
##########
@@ -0,0 +1,84 @@
+import {Resource} from "@/interfaces/ResourceType.ts";
Review Comment:
include the license header
##########
modules/research-framework/research-service/src/main/java/org/apache/airavata/research/service/model/entity/ResourceLike.java:
##########
@@ -0,0 +1,70 @@
+/**
+*
+* 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.entity;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
+import org.hibernate.annotations.UuidGenerator;
+
+@Entity(name = "RESOURCE_LIKE")
+public class ResourceLike {
+
+ @Id
+ @GeneratedValue
+ @UuidGenerator
+ @Column(nullable = false, updatable = false, length = 48)
+ private String id;
+
+ @Column(name = "owner_id", nullable = false)
+ private String ownerId;
Review Comment:
@ganning127, this is to hold the id of the user who liked the resource right? Better to change the variable name
--
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: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "yasithdev (via GitHub)" <gi...@apache.org>.
yasithdev commented on code in PR #527:
URL: https://github.com/apache/airavata/pull/527#discussion_r2159514533
##########
modules/research-framework/portal/src/components/resources/LikeResourceButton.tsx:
##########
Review Comment:
Yes, agreed @lahirujayathilake!
--
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: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "lahirujayathilake (via GitHub)" <gi...@apache.org>.
lahirujayathilake commented on code in PR #527:
URL: https://github.com/apache/airavata/pull/527#discussion_r2159491672
##########
modules/research-framework/portal/src/App.tsx:
##########
@@ -1,30 +1,28 @@
-import { useColorMode } from "./components/ui/color-mode";
-import { Route, Routes, useLocation, useNavigate } from "react-router";
+import {useColorMode} from "./components/ui/color-mode";
+import {Route, Routes, useLocation, useNavigate} from "react-router";
import Home from "./components/home";
-import { Models } from "./components/models";
-import { Datasets } from "./components/datasets";
+import {Models} from "./components/models";
+import {Datasets} from "./components/datasets";
import ResourceDetails from "./components/resources/ResourceDetails";
import Notebooks from "./components/notebooks";
import Repositories from "./components/repositories";
-import { Login } from "./components/auth/UserLoginPage";
+import {Login} from "./components/auth/UserLoginPage";
import ProtectedComponent from "./components/auth/ProtectedComponent";
-import { AuthProvider, AuthProviderProps } from "react-oidc-context";
-import { useEffect, useState } from "react";
+import {AuthProvider, AuthProviderProps} from "react-oidc-context";
+import {useEffect, useState} from "react";
import NavBarFooterLayout from "./layouts/NavBarFooterLayout";
-import { CybershuttleLanding } from "./components/home/CybershuttleLanding";
-import {
- APP_REDIRECT_URI,
- CLIENT_ID,
- OPENID_CONFIG_URL,
-} from "./lib/constants";
-import { WebStorageStateStore } from "oidc-client-ts";
-import { Resources } from "./components/resources";
-import { UserSet } from "./components/auth/UserSet";
-import { Toaster } from "./components/ui/toaster";
-import { Events } from "./components/events";
-import { AddRepoMaster } from "./components/add/AddRepoMaster";
-import { Add } from "./components/add";
-import { AddProjectMaster } from "./components/add/AddProjectMaster";
+import {CybershuttleLanding} from "./components/home/CybershuttleLanding";
Review Comment:
better to revert these formattings
##########
modules/research-framework/portal/src/App.tsx:
##########
@@ -1,30 +1,28 @@
-import { useColorMode } from "./components/ui/color-mode";
-import { Route, Routes, useLocation, useNavigate } from "react-router";
+import {useColorMode} from "./components/ui/color-mode";
+import {Route, Routes, useLocation, useNavigate} from "react-router";
import Home from "./components/home";
-import { Models } from "./components/models";
-import { Datasets } from "./components/datasets";
+import {Models} from "./components/models";
+import {Datasets} from "./components/datasets";
import ResourceDetails from "./components/resources/ResourceDetails";
import Notebooks from "./components/notebooks";
import Repositories from "./components/repositories";
-import { Login } from "./components/auth/UserLoginPage";
+import {Login} from "./components/auth/UserLoginPage";
import ProtectedComponent from "./components/auth/ProtectedComponent";
-import { AuthProvider, AuthProviderProps } from "react-oidc-context";
-import { useEffect, useState } from "react";
+import {AuthProvider, AuthProviderProps} from "react-oidc-context";
+import {useEffect, useState} from "react";
import NavBarFooterLayout from "./layouts/NavBarFooterLayout";
-import { CybershuttleLanding } from "./components/home/CybershuttleLanding";
-import {
- APP_REDIRECT_URI,
- CLIENT_ID,
- OPENID_CONFIG_URL,
-} from "./lib/constants";
-import { WebStorageStateStore } from "oidc-client-ts";
-import { Resources } from "./components/resources";
-import { UserSet } from "./components/auth/UserSet";
-import { Toaster } from "./components/ui/toaster";
-import { Events } from "./components/events";
-import { AddRepoMaster } from "./components/add/AddRepoMaster";
-import { Add } from "./components/add";
-import { AddProjectMaster } from "./components/add/AddProjectMaster";
+import {CybershuttleLanding} from "./components/home/CybershuttleLanding";
Review Comment:
better to revert these formattings
--
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: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "yasithdev (via GitHub)" <gi...@apache.org>.
yasithdev commented on code in PR #527:
URL: https://github.com/apache/airavata/pull/527#discussion_r2159514533
##########
modules/research-framework/portal/src/components/resources/LikeResourceButton.tsx:
##########
Review Comment:
Yes, agreed!
--
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: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "ganning127 (via GitHub)" <gi...@apache.org>.
ganning127 commented on code in PR #527:
URL: https://github.com/apache/airavata/pull/527#discussion_r2158149759
##########
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:
Copilot is wrong here
--
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: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support liking resources [airavata]
Posted by "yasithdev (via GitHub)" <gi...@apache.org>.
yasithdev merged PR #527:
URL: https://github.com/apache/airavata/pull/527
--
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: custos-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org