diff --git a/commit/api/commit_project/commit_project.py b/commit/api/commit_project/commit_project.py index 66000ab..4b45ff5 100644 --- a/commit/api/commit_project/commit_project.py +++ b/commit/api/commit_project/commit_project.py @@ -11,7 +11,7 @@ def get_project_list_with_branches(): "name", 'organization_name', 'github_org', 'image', 'about', 'creation']) for organization in organizations: projects = frappe.get_all("Commit Project", filters={ - "org": organization.get("name")}, fields=["name", "display_name", "repo_name", "app_name", "image", "banner_image", "path_to_folder", 'description'], order_by="modified asc") + "org": organization.get("name")}, fields=["name", "display_name", "repo_name", "app_name", "image", "banner_image", "path_to_folder", 'description'], order_by="creation desc") # organization["projects"] = projects for project in projects: branches = frappe.get_all("Commit Project Branch", filters={"project": project.get( diff --git a/dashboard/src/components/features/meta_apps/YourApps.tsx b/dashboard/src/components/features/meta_apps/YourApps.tsx index 2a62b28..401e4e7 100644 --- a/dashboard/src/components/features/meta_apps/YourApps.tsx +++ b/dashboard/src/components/features/meta_apps/YourApps.tsx @@ -1,14 +1,14 @@ import { FullPageLoader } from "@/components/common/FullPageLoader/FullPageLoader" import { Avatar, AvatarFallback } from "@/components/ui/avatar" import { Button } from "@/components/ui/button" -import { CardDescription } from "@/components/ui/card" -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" +import { Card, CardContent, CardDescription, CardFooter, CardTitle } from "@/components/ui/card" import { AvatarImage } from "@radix-ui/react-avatar" import { useFrappeGetCall } from "frappe-react-sdk" import { useMemo } from "react" import { BsDatabase } from "react-icons/bs" import { useNavigate } from "react-router-dom" import { YourAppAPIExplorer } from "./YourAppAPIExplorer" +import { Badge } from "@/components/ui/badge" export interface AppsData { app_name: string @@ -39,9 +39,8 @@ export const YourApps = () => { if (data && data.message) { return (
-
-

-

+
+
-
-
    - {data.message.map((app: AppsData) => { - return - })} -
+
+ {data.message.map((app: AppsData) => { + return + })}
) @@ -66,45 +63,27 @@ export const YourApps = () => { } -export const ProjectCard = ({ app }: { app: AppsData }) => { +const AppsCard = ({ app }: { app: AppsData }) => { const appNameInitials = useMemo(() => { return app.app_name.split('_').map((word) => word[0]).join('').toUpperCase() }, [app]) return ( -
  • -
    -
    -
    - - - {appNameInitials} - -
    -
    -

    {app.app_name}

    - - by - -

    {app.app_publisher}

    -
    - {app.app_description} -
    -
    - -
    -
    -
  • + + + + + {appNameInitials} + + {app.app_name} + + {app.app_description} + + + + {app.app_publisher} + + ) } \ No newline at end of file diff --git a/dashboard/src/components/features/projects/Org/OrgList.tsx b/dashboard/src/components/features/projects/Org/OrgComponent.tsx similarity index 70% rename from dashboard/src/components/features/projects/Org/OrgList.tsx rename to dashboard/src/components/features/projects/Org/OrgComponent.tsx index 23fe5d4..212959d 100644 --- a/dashboard/src/components/features/projects/Org/OrgList.tsx +++ b/dashboard/src/components/features/projects/Org/OrgComponent.tsx @@ -5,7 +5,8 @@ import { KeyedMutator } from "swr"; import { ProjectData } from "../Projects"; import DeleteOrgModal from "./DeleteOrgModal"; import { AlertDialog, AlertDialogTrigger } from "@/components/ui/alert-dialog"; -import { ProjectCard } from "../Projects/ProjectsList"; +import { ProjectCard } from "../Projects/ProjectCard"; + interface OrgComponentProps { org: ProjectData, mutate: KeyedMutator<{ message: ProjectData[]; }> @@ -20,21 +21,21 @@ export const OrgComponent = ({ org, mutate }: OrgComponentProps) => { {org.organization_name} {isCreateAccess && - - - - + + + + }
    - {org.projects.map((project => { + {org.projects.map((project) => { return ( ) } - ))} + )}
    ) diff --git a/dashboard/src/components/features/projects/Projects.tsx b/dashboard/src/components/features/projects/Projects.tsx index 98c98c0..46746d7 100644 --- a/dashboard/src/components/features/projects/Projects.tsx +++ b/dashboard/src/components/features/projects/Projects.tsx @@ -1,42 +1,49 @@ -import { FullPageLoader } from "@/components/common/FullPageLoader/FullPageLoader" -import { Button } from "@/components/ui/button" -import { Dialog, DialogTrigger } from "@/components/ui/dialog" -import { CommitProject } from "@/types/commit/CommitProject" -import { useFrappeGetCall } from "frappe-react-sdk" -import { BsDatabase } from "react-icons/bs" -import { ViewERDDialogContent } from "./ViewERDAppDialog" -import { isSystemManager } from "@/utils/roles" -import { CommitProjectBranch } from "@/types/commit/CommitProjectBranch" -import { OrgComponent } from "./Org/OrgList" -import { DropdownMenuDemo } from "./AddMenuButton" -import { APIExplorer } from "./APIExplorer" +import { FullPageLoader } from "@/components/common/FullPageLoader/FullPageLoader"; +import { Button } from "@/components/ui/button"; +import { Dialog, DialogTrigger } from "@/components/ui/dialog"; +import { CommitProject } from "@/types/commit/CommitProject"; +import { useFrappeGetCall } from "frappe-react-sdk"; +import { BsDatabase } from "react-icons/bs"; +import { ViewERDDialogContent } from "./ViewERDAppDialog"; +import { isSystemManager } from "@/utils/roles"; +import { CommitProjectBranch } from "@/types/commit/CommitProjectBranch"; +import { DropdownMenuDemo } from "./AddMenuButton"; +import { APIExplorer } from "./APIExplorer"; +import ProjectCard from "./Projects/ProjectCard"; + export interface ProjectWithBranch extends CommitProject { - branches: CommitProjectBranch[] + branches: CommitProjectBranch[]; } export interface ProjectData extends CommitProjectBranch { - projects: ProjectWithBranch[] - organization_name: string - image: string - name: string - about: string + projects: ProjectWithBranch[]; + organization_name: string; + image: string; + name: string; + about: string; } export const Projects = () => { + const isCreateAccess = isSystemManager(); - const isCreateAccess = isSystemManager() - - const { data, error, isLoading, mutate } = useFrappeGetCall<{ message: ProjectData[] }>('commit.api.commit_project.commit_project.get_project_list_with_branches', {}, 'get_project_list_with_branches', { - keepPreviousData: true, - revalidateOnFocus: true, - revalidateIfStale: false, - }) + const { data, error, isLoading, mutate } = useFrappeGetCall<{ + message: ProjectData[]; + }>( + "commit.api.commit_project.commit_project.get_project_list_with_branches", + {}, + "get_project_list_with_branches", + { + keepPreviousData: true, + revalidateOnFocus: true, + revalidateIfStale: false, + } + ); if (error) { - return
    Error
    + return
    Error
    ; } if (isLoading) { - return + return ; } if (data && data.message) { @@ -48,20 +55,29 @@ export const Projects = () => { - -
      +
      {data.message.map((org: ProjectData) => { - return + const orgName = org.organization_name; + return org.projects.map((project) => ( + + )); })} -
    + + - ) + ); } -} \ No newline at end of file +}; diff --git a/dashboard/src/components/features/projects/Projects/ProjectCard.tsx b/dashboard/src/components/features/projects/Projects/ProjectCard.tsx new file mode 100644 index 0000000..44aba9e --- /dev/null +++ b/dashboard/src/components/features/projects/Projects/ProjectCard.tsx @@ -0,0 +1,104 @@ +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardTitle, +} from "@/components/ui/card"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { AiOutlineDelete } from "react-icons/ai"; +import { AlertDialog } from "@/components/ui/alert-dialog"; +import { KeyedMutator } from "swr"; +import { useMemo, useState } from "react"; +import { isSystemManager } from "@/utils/roles"; +import { RxDragHandleDots1 } from "react-icons/rx"; +import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; +import { BsThreeDotsVertical } from "react-icons/bs"; +import { Dialog } from "@radix-ui/react-dialog"; +import ManageBranchModal from "../Branch/ManageBranchModal"; +import { ProjectWithBranch, ProjectData } from "../Projects"; +import DeleteProjectModal from "./DeleteProjectModal"; +import { Badge } from "@/components/ui/badge"; + +export interface ProjectCardProps { + project: ProjectWithBranch + mutate: KeyedMutator<{ + message: ProjectData[]; + }> + orgName: string +} + +const ProjectCard = ({ project, mutate, orgName }: ProjectCardProps) => { + + const appNameInitials = useMemo(() => { + return project.display_name[0].toUpperCase() + }, [project]) + + const isCreateAccess = isSystemManager() + + const [openManageModal, setOpenManageModal] = useState(false) + + const [openDeleteDialogModal, setOpenDeleteDialogModal] = useState(false) + + return ( + + +
    + + + + {appNameInitials} + + + +
    +
    + {project.display_name} + {isCreateAccess && + + + + + {project.branches.length > 0 && + { setOpenManageModal(true) }}> + <> + + Manage Branches + + + } + setOpenDeleteDialogModal(true)}> + + Delete Project + + + + } +
    + + + {project.description} + +
    + + +
    +
    + + + + + + + + + + + {orgName} + +
    + ); +} + +export default ProjectCard; diff --git a/dashboard/src/components/features/projects/Projects/ProjectsList.tsx b/dashboard/src/components/features/projects/Projects/ProjectsList.tsx deleted file mode 100644 index 98094d7..0000000 --- a/dashboard/src/components/features/projects/Projects/ProjectsList.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import { Button } from "@/components/ui/button"; -import { CardDescription } from "@/components/ui/card"; -import { isSystemManager } from "@/utils/roles"; -import { useState, useMemo } from "react"; -import { AiOutlineDelete } from "react-icons/ai"; -import { RxDragHandleDots1 } from "react-icons/rx"; -import { KeyedMutator } from "swr"; -import ManageBranchModal from "../Branch/ManageBranchModal"; -import { ProjectWithBranch, ProjectData } from "../Projects"; -import DeleteProjectModal from "./DeleteProjectModal"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; -import { Dialog } from "@/components/ui/dialog"; -import { AlertDialog, AlertDialogTrigger } from "@/components/ui/alert-dialog"; -import { CommitProjectBranch } from "@/types/commit/CommitProjectBranch" - -export interface ProjectCardProps { - project: ProjectWithBranch - mutate: KeyedMutator<{ - message: ProjectData[]; - }> - -} - -export const ProjectCard = ({ project, mutate }: ProjectCardProps) => { - - const [branch, setBranch] = useState(project.branches[0]?.name) - - const appNameInitials = useMemo(() => { - return project.display_name.split('_').map((word) => word[0]).join('').toUpperCase() - }, [project]) - - const isCreateAccess = isSystemManager() - - const [openManageModal, setOpenManageModal] = useState(false) - - const [selectOpen, setSelectOpen] = useState(false) - - return ( -
  • -
    -
    -
    - -
    - - - {appNameInitials} - -
    -
    -

    {project.display_name}

    -
    - {project.description} -
    -
    -
    - -
    - - - - - - - {isCreateAccess && - - } - - -
    -
    -
    -
  • - ) -}