diff --git a/commit/api/commit_project/commit_project.py b/commit/api/commit_project/commit_project.py index 4b45ff5..95f568b 100644 --- a/commit/api/commit_project/commit_project.py +++ b/commit/api/commit_project/commit_project.py @@ -15,7 +15,7 @@ def get_project_list_with_branches(): # organization["projects"] = projects for project in projects: branches = frappe.get_all("Commit Project Branch", filters={"project": project.get( - "name")}, fields=["branch_name", "last_fetched", "modules", "whitelisted_apis", "name"]) + "name")}, fields=["branch_name", "last_fetched", "modules", "whitelisted_apis", "name", "frequency"]) project["branches"] = branches organization["projects"] = projects diff --git a/commit/commit/doctype/commit_project_branch/commit_project_branch.json b/commit/commit/doctype/commit_project_branch/commit_project_branch.json index 9bc479a..60b0c50 100644 --- a/commit/commit/doctype/commit_project_branch/commit_project_branch.json +++ b/commit/commit/doctype/commit_project_branch/commit_project_branch.json @@ -20,6 +20,7 @@ "commit_hash", "app_name", "last_fetched", + "frequency", "modules_and_doctypes_tab", "modules", "module_doctypes_map", @@ -103,6 +104,11 @@ "label": "Doctype - Module Map" }, { + "fieldname": "frequency", + "fieldtype": "Select", + "label": "Frequency", + "options": "\nDaily\nWeekly\nMonthly" + }, "fieldname": "documentation", "fieldtype": "JSON", "label": "Documentation" @@ -110,7 +116,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-06-26 09:34:15.314418", + "modified": "2024-06-26 15:17:43.807200", "modified_by": "Administrator", "module": "commit", "name": "Commit Project Branch", diff --git a/dashboard/src/components/features/projects/AddMenuButton.tsx b/dashboard/src/components/features/projects/AddMenuButton.tsx index 43bcda3..9dbd797 100644 --- a/dashboard/src/components/features/projects/AddMenuButton.tsx +++ b/dashboard/src/components/features/projects/AddMenuButton.tsx @@ -16,7 +16,7 @@ import { ProjectData } from "./Projects" import CreateProjectModal from "./Projects/CreateProjectModal" import CreateBranchModal from "./Branch/CreateBranchModal" -export const DropdownMenuDemo = ({ mutate }: { +export const AddMenuButton = ({ mutate }: { mutate: KeyedMutator<{ message: ProjectData[]; }> diff --git a/dashboard/src/components/features/projects/Branch/ManageBranchItem.tsx b/dashboard/src/components/features/projects/Branch/ManageBranchItem.tsx index 2046581..3fa105c 100644 --- a/dashboard/src/components/features/projects/Branch/ManageBranchItem.tsx +++ b/dashboard/src/components/features/projects/Branch/ManageBranchItem.tsx @@ -2,11 +2,16 @@ import { Button } from '@/components/ui/button' import { toast } from '@/components/ui/use-toast' import { convertFrappeTimestampToTimeAgo } from '@/components/utils/dateconversion' import { CommitProjectBranch } from '@/types/commit/CommitProjectBranch' -import { useFrappeDeleteDoc, useFrappePostCall } from 'frappe-react-sdk' +import { useFrappeDeleteDoc, useFrappePostCall, useFrappeUpdateDoc } from 'frappe-react-sdk' import { AiOutlineDelete } from 'react-icons/ai' import { IoMdSync } from 'react-icons/io' import { ProjectData } from '../Projects' import { KeyedMutator } from 'swr' +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Controller, FormProvider, useForm } from 'react-hook-form' +import { Label } from '@/components/ui/label' +import { useState } from 'react' const ManageBranchItem = ({ branch, mutate }: { branch: CommitProjectBranch, mutate: KeyedMutator<{ message: ProjectData[]; }> }) => { @@ -39,11 +44,40 @@ const ManageBranchItem = ({ branch, mutate }: { branch: CommitProjectBranch, mut })) } + const methods = useForm({ + defaultValues: { + frequency : branch.frequency + } + }) + + const { control, reset: formReset } = methods + + const { updateDoc } = useFrappeUpdateDoc() + + const onSubmit = (data: CommitProjectBranch) => { + updateDoc("Commit Project Branch", branch.name, data) + .then(() => { + mutate() + formReset({ frequency: data.frequency }) + }).then(() => { + toast({ + description: `Branch ${branch.branch_name} will be updated ${data.frequency}`, + duration: 2000 + }) + setOpen(false) + } + ) + + } + + + const [open, setOpen] = useState(false); + return (
  • {branch.branch_name} -
    +
    Last synced {convertFrappeTimestampToTimeAgo(branch.last_fetched)}
    @@ -58,6 +92,47 @@ const ManageBranchItem = ({ branch, mutate }: { branch: CommitProjectBranch, mut Fetch latest code + + + + + + +
    +
    + + ( + + )} + /> +
    +
    + +
    +
    +
    +
    +