This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/master by this push:
     new ee086a12a7 remove associated projects section on resource details if 
no projects (#523)
ee086a12a7 is described below

commit ee086a12a70cb998ebaa0c113d721925c69fd17f
Author: Ganning Xu <[email protected]>
AuthorDate: Wed Jun 18 07:20:18 2025 -0700

    remove associated projects section on resource details if no projects (#523)
---
 .../components/datasets/DatasetSpecificDetails.tsx | 20 +++------
 .../projects/AssociatedProejctsSection.tsx         | 40 -----------------
 .../projects/AssociatedProjectsSection.tsx         | 51 ++++++++++++++++++++++
 .../repositories/RepositorySpecificDetails.tsx     | 24 ++++------
 4 files changed, 66 insertions(+), 69 deletions(-)

diff --git 
a/modules/research-framework/portal/src/components/datasets/DatasetSpecificDetails.tsx
 
b/modules/research-framework/portal/src/components/datasets/DatasetSpecificDetails.tsx
index 8de16811a2..0ac5289253 100644
--- 
a/modules/research-framework/portal/src/components/datasets/DatasetSpecificDetails.tsx
+++ 
b/modules/research-framework/portal/src/components/datasets/DatasetSpecificDetails.tsx
@@ -1,20 +1,14 @@
-import { Box, Heading } from "@chakra-ui/react";
-import { AssociatedProjectsSection } from 
"../projects/AssociatedProejctsSection";
-import { DatasetResource } from "@/interfaces/ResourceType";
+import {AssociatedProjectsSection} from 
"../projects/AssociatedProjectsSection.tsx";
+import {DatasetResource} from "@/interfaces/ResourceType";
 
 export const DatasetSpecificDetails = ({
-  dataset,
-}: {
+                                         dataset,
+                                       }: {
   dataset: DatasetResource;
 }) => {
   return (
-    <>
-      <Box>
-        <Heading fontWeight="bold" size="2xl" mb={2}>
-          Associated Projects
-        </Heading>
-        <AssociatedProjectsSection resourceId={dataset.id} />
-      </Box>
-    </>
+      <>
+        <AssociatedProjectsSection resourceId={dataset.id}/>
+      </>
   );
 };
diff --git 
a/modules/research-framework/portal/src/components/projects/AssociatedProejctsSection.tsx
 
b/modules/research-framework/portal/src/components/projects/AssociatedProejctsSection.tsx
deleted file mode 100644
index 26ff673c9c..0000000000
--- 
a/modules/research-framework/portal/src/components/projects/AssociatedProejctsSection.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { ProjectType } from "@/interfaces/ProjectType";
-import api from "@/lib/api";
-import { CONTROLLER } from "@/lib/controller";
-import { SimpleGrid } from "@chakra-ui/react";
-import { useEffect, useState } from "react";
-import { ProjectCard } from "../home/ProjectCard";
-
-async function fetchProjects(id: string) {
-  try {
-    const resp = await api.get(`${CONTROLLER.resources}/${id}/projects`);
-    return resp.data;
-  } catch (error) {
-    console.error("Error fetching projects:", error);
-  }
-}
-
-export const AssociatedProjectsSection = ({
-  resourceId,
-}: {
-  resourceId: string;
-}) => {
-  const [projects, setProjects] = useState<ProjectType[]>([]);
-  useEffect(() => {
-    async function fetchData() {
-      const projects = await fetchProjects(resourceId);
-      setProjects(projects);
-    }
-
-    fetchData();
-  }, []);
-  return (
-    <>
-      <SimpleGrid columns={{ base: 1, md: 2 }} gap={2}>
-        {projects.map((project) => (
-          <ProjectCard key={project.id} project={project} />
-        ))}
-      </SimpleGrid>
-    </>
-  );
-};
diff --git 
a/modules/research-framework/portal/src/components/projects/AssociatedProjectsSection.tsx
 
b/modules/research-framework/portal/src/components/projects/AssociatedProjectsSection.tsx
new file mode 100644
index 0000000000..ff8606952e
--- /dev/null
+++ 
b/modules/research-framework/portal/src/components/projects/AssociatedProjectsSection.tsx
@@ -0,0 +1,51 @@
+import {ProjectType} from "@/interfaces/ProjectType";
+import api from "@/lib/api";
+import {CONTROLLER} from "@/lib/controller";
+import {Heading, Separator, SimpleGrid} from "@chakra-ui/react";
+import {useEffect, useState} from "react";
+import {ProjectCard} from "../home/ProjectCard";
+
+async function fetchProjects(id: string) {
+  try {
+    const resp = await api.get(`${CONTROLLER.resources}/${id}/projects`);
+    return resp.data;
+  } catch (error) {
+    console.error("Error fetching projects:", error);
+  }
+}
+
+export const AssociatedProjectsSection = ({
+                                            resourceId,
+                                          }: {
+  resourceId: string;
+}) => {
+  const [projects, setProjects] = useState<ProjectType[]>([]);
+  useEffect(() => {
+    async function fetchData() {
+      const projects = await fetchProjects(resourceId);
+      setProjects(projects);
+    }
+
+    fetchData();
+  }, []);
+
+  if (projects.length === 0) {
+    return null;
+  }
+
+  return (
+      <>
+        <Heading fontWeight="bold" size="2xl" mb={2}>
+          Associated Projects
+        </Heading>
+        
+        <SimpleGrid columns={{base: 1, md: 2}} gap={2}>
+          {projects.map((project) => (
+              <ProjectCard key={project.id} project={project}/>
+          ))}
+        </SimpleGrid>
+
+        <Separator my={6}/>
+      </>
+  );
+};
diff --git 
a/modules/research-framework/portal/src/components/repositories/RepositorySpecificDetails.tsx
 
b/modules/research-framework/portal/src/components/repositories/RepositorySpecificDetails.tsx
index e6597ffd03..6fd0797a42 100644
--- 
a/modules/research-framework/portal/src/components/repositories/RepositorySpecificDetails.tsx
+++ 
b/modules/research-framework/portal/src/components/repositories/RepositorySpecificDetails.tsx
@@ -1,26 +1,18 @@
-import { RepositoryResource } from "@/interfaces/ResourceType";
-import { Box, Heading, Separator } from "@chakra-ui/react";
-import { AssociatedProjectsSection } from 
"../projects/AssociatedProejctsSection";
-import { GitHubFileTree } from "./GitHubFileTree";
+import {RepositoryResource} from "@/interfaces/ResourceType";
+import {Box} from "@chakra-ui/react";
+import {AssociatedProjectsSection} from 
"../projects/AssociatedProjectsSection.tsx";
+import {GitHubFileTree} from "./GitHubFileTree";
 
 export const RepositorySpecificDetails = ({
-  repository,
-}: {
+                                            repository,
+                                          }: {
   repository: RepositoryResource;
 }) => {
   return (
-    <Box>
       <Box>
-        <Heading fontWeight="bold" size="2xl" mb={2}>
-          Associated Projects
-        </Heading>
+        <AssociatedProjectsSection resourceId={repository.id}/>
 
-        <AssociatedProjectsSection resourceId={repository.id} />
+        <GitHubFileTree repository={repository}/>
       </Box>
-
-      <Separator my={6} />
-
-      <GitHubFileTree repository={repository} />
-    </Box>
   );
 };

Reply via email to