-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: delete Org, Project and Manage Branches #39
Merged
sumitjain236
merged 13 commits into
The-Commit-Company:org-project-branch-creation
from
Pardeshi-Aditya:org-project-branch-creation
May 31, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cc6a916
fix: only display projects which have branches
Pardeshi-Aditya 5ed7fb6
feat: add manage branch modal
Pardeshi-Aditya 8096432
fix: update boot
Pardeshi-Aditya 45a2e46
fix: fetch repo api
Pardeshi-Aditya e606a1e
fix: undo delete
Pardeshi-Aditya 5ff0ea7
feat: handle exception while adding non existing branch
Pardeshi-Aditya 648c8ba
feat : sync or delete branch
Pardeshi-Aditya 3874882
feat: manage branch modal
Pardeshi-Aditya ae7175d
refactor : add interface
Pardeshi-Aditya 5fb6e18
fix : handle exception for adding non existing branch
Pardeshi-Aditya 290e185
feat : add delete project modal
Pardeshi-Aditya 46c2af6
feat : add description while adding project
Pardeshi-Aditya c921472
fix : refactor and add project delete button
Pardeshi-Aditya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,17 @@ | |
<meta name="msapplication-TileColor" content="#da532c"> | ||
<meta name="theme-color" content="#ffffff"> | ||
<title>Commit - Developer tooling for the Frappeverse</title> | ||
<script type="module" crossorigin src="/assets/commit/dashboard/assets/index-2eacee2d.js"></script> | ||
<link rel="stylesheet" href="/assets/commit/dashboard/assets/index-31456e03.css"> | ||
<script type="module" crossorigin src="/assets/commit/dashboard/assets/index-63f9cb36.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this file not required |
||
<link rel="stylesheet" href="/assets/commit/dashboard/assets/index-4a5a43c3.css"> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script>window.csrf_token = '{{ frappe.session.csrf_token }}';</script> | ||
<script> | ||
if (!window.frappe) window.frappe = {}; | ||
frappe.boot = JSON.parse({{ boot }}); | ||
</script> | ||
|
||
</body> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
dashboard/src/components/features/projects/Branch/ManageBranchItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
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 { AiOutlineDelete } from 'react-icons/ai' | ||
import { IoMdSync } from 'react-icons/io' | ||
import { ProjectData } from '../Projects' | ||
import { KeyedMutator } from 'swr' | ||
|
||
|
||
const ManageBranchItem = ({ branch, mutate }: { branch: CommitProjectBranch, mutate: KeyedMutator<{ message: ProjectData[]; }> }) => { | ||
const { call, loading, reset: callReset } = useFrappePostCall<{ message: any }>('commit.commit.doctype.commit_project_branch.commit_project_branch.fetch_repo') | ||
|
||
|
||
const { deleteDoc, reset, loading: deleteLoading } = useFrappeDeleteDoc() | ||
|
||
const handleDelete = () => { | ||
deleteDoc("Commit Project Branch", branch.name) | ||
.then(() => { | ||
mutate() | ||
reset() | ||
}).then(() => toast({ | ||
description: "Branch Deleted Successfully", | ||
})) | ||
} | ||
|
||
const handleSync = () => { | ||
call({ | ||
doc: {}, | ||
name: branch.name, | ||
}).then(() => { | ||
mutate() | ||
callReset() | ||
}).then(() => toast({ | ||
description: "Branch Synced!", | ||
})) | ||
} | ||
|
||
return ( | ||
<li className="pl-0 pt-2 hover:shadow-sm flex justify-between"> | ||
<div className="flex flex-col items-start text-lg tracking-normal"> | ||
{branch.branch_name} | ||
<div className='text-xs text-gray-500 pl-0'> | ||
Last synced {convertFrappeTimestampToTimeAgo(branch.last_fetched)} | ||
</div> | ||
</div> | ||
<div className="flex gap-2"> | ||
<Button | ||
className="flex gap-2 text-sm" | ||
variant="secondary" | ||
onClick={() => handleSync()} | ||
disabled={deleteLoading || loading} | ||
> | ||
<IoMdSync className={loading ? 'animate-spin' : ''} /> | ||
Sync | ||
</Button> | ||
<Button className="text-lg p-2" variant="destructive" | ||
onClick={() => handleDelete()} | ||
disabled={deleteLoading || loading} | ||
> | ||
<AiOutlineDelete /> | ||
</Button> | ||
</div> | ||
</li > | ||
) | ||
} | ||
|
||
export default ManageBranchItem |
43 changes: 43 additions & 0 deletions
43
dashboard/src/components/features/projects/Branch/ManageBranchModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog" | ||
import { ProjectData } from "../Projects" | ||
import { Button } from "@/components/ui/button" | ||
import { KeyedMutator } from "swr" | ||
import { CommitProjectBranch } from "@/types/commit/CommitProjectBranch" | ||
import ManageBranchItem from "./ManageBranchItem" | ||
|
||
export interface ManageBranchModalProps { | ||
branches: CommitProjectBranch[] | ||
mutate: KeyedMutator<{ message: ProjectData[]; }> | ||
setOpenManageModal: React.Dispatch<React.SetStateAction<boolean>> | ||
} | ||
|
||
|
||
const ManageBranchModal = ({ branches, mutate, setOpenManageModal }: ManageBranchModalProps) => { | ||
|
||
return ( | ||
<DialogContent className="sm:max-w-[600px] sm:max-h-[800px] overflow-y-scroll"> | ||
<DialogHeader> | ||
<DialogTitle>Manage Branches</DialogTitle> | ||
<DialogDescription> | ||
Update or Delete Branches | ||
</DialogDescription> | ||
</DialogHeader> | ||
<ul role="list" className="divide-y divide-gray-200"> | ||
{branches?.map((branch: CommitProjectBranch) => { | ||
return ( | ||
<ManageBranchItem key={branch.name} branch={branch} mutate={mutate} /> | ||
) | ||
} | ||
)} | ||
</ul> | ||
<DialogFooter> | ||
<Button variant="outline" onClick={() => setOpenManageModal(false)}> | ||
Close | ||
</Button> | ||
</DialogFooter> | ||
</DialogContent> | ||
) | ||
} | ||
|
||
|
||
export default ManageBranchModal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this import