diff --git a/.env.example b/.env.example index af26745..5cb68f6 100644 --- a/.env.example +++ b/.env.example @@ -8,7 +8,7 @@ AUTH_SECRET= RESEND_API_KEY= # client url -NEXT_PUBLIC_VERCEL_URL=http://localhost:3000 +NEXT_PUBLIC_APP_URL=http://localhost:3000 # your google gemini api key (optional). GENERATIVE_API_KEY= diff --git a/.eslintrc.json b/.eslintrc.json index 0e81f9b..bffb357 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,3 @@ { "extends": "next/core-web-vitals" -} \ No newline at end of file +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d698d8d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + diff --git a/.github/workflows/Production_chacks.yml b/.github/workflows/Production_chacks.yml index a3040e3..580e940 100644 --- a/.github/workflows/Production_chacks.yml +++ b/.github/workflows/Production_chacks.yml @@ -4,6 +4,8 @@ on: push: branches: - "*" + pull_request: + branches: ["*"] jobs: build: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cf4383a..fcd141d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,11 +13,11 @@ name: "CodeQL" on: push: - branches: [ "*" ] + branches: ["*"] pull_request: - branches: [ "*" ] + branches: ["*"] schedule: - - cron: '38 17 * * 2' + - cron: "38 17 * * 2" jobs: analyze: @@ -41,8 +41,8 @@ jobs: fail-fast: false matrix: include: - - language: javascript-typescript - build-mode: none + - language: javascript-typescript + build-mode: none # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' # Use `c-cpp` to analyze code written in C, C++ or both # Use 'java-kotlin' to analyze code written in Java, Kotlin or both @@ -52,38 +52,38 @@ jobs: # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality - # If the analyze step fails for one of the languages you are analyzing with - # "We were unable to automatically build your code", modify the matrix above - # to set the build mode to "manual" for that language. Then modify this step - # to build your code. - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - if: matrix.build-mode == 'manual' - run: | - echo 'If you are using a "manual" build mode for one or more of the' \ - 'languages you are analyzing, replace this with the commands to build' \ - 'your code, for example:' - echo ' make bootstrap' - echo ' make release' - exit 1 + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - if: matrix.build-mode == 'manual' + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index f202aab..43431ff 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -7,10 +7,10 @@ # # Source repository: https://github.com/actions/dependency-review-action # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement -name: 'Dependency review' +name: "Dependency review" on: pull_request: - branches: [ "*" ] + branches: ["*"] # If using a dependency submission action in this workflow this permission will need to be set to: # @@ -27,9 +27,9 @@ jobs: dependency-review: runs-on: ubuntu-latest steps: - - name: 'Checkout repository' + - name: "Checkout repository" uses: actions/checkout@v4 - - name: 'Dependency Review' + - name: "Dependency Review" uses: actions/dependency-review-action@v4 # Commonly enabled options, see https://github.com/actions/dependency-review-action#configuration-options for all available options. with: diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index ec6f87f..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "workbench.colorTheme": "Tokyo Night", - "workbench.startupEditor": "none", - // "files.autoSave": "onWindowChange", - "files.autoSave": "off", - "glassit.alpha": 245, - "glassit.force_sway": true, - "workbench.iconTheme": "material-icon-theme", - "[typescriptreact]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[javascriptreact]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "hediet.vscode-drawio.resizeImages": null, - "[html]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[javascript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - // "tabnine.experimentalAutoImports": true, - "[jsonc]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "javascript.updateImportsOnFileMove.enabled": "always", - "typescript.updateImportsOnFileMove.enabled": "always", - "[less]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[css]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "glassit.step": 500, - // "bitoAI.codeCompletion.enableCommentToCode": true, - // "bitoAI.codeCompletion.enableAutoCompletion": true, - "cmake.options.statusBarVisibility": "hidden", - "editor.cursorBlinking": "smooth" -} \ No newline at end of file diff --git a/actions/repo/commments/fetchComments.ts b/actions/repo/commments/fetchComments.ts new file mode 100644 index 0000000..e113755 --- /dev/null +++ b/actions/repo/commments/fetchComments.ts @@ -0,0 +1,34 @@ +"use server"; + +import { db } from "@/lib/db"; +import { Comment } from "@prisma/client"; + +type FetchCommentsResult = { + success: boolean; + message?: string; + data?: Comment[]; +}; + +export const fetchComments = async ({ + repositoryPath, + issuePullRequestDiscussionId, +}: { + repositoryPath: string | null; + issuePullRequestDiscussionId: string | undefined; +}): Promise => { + if (!repositoryPath || !issuePullRequestDiscussionId) { + return { + success: false, + message: "repositoryPath and issuePullRequestDiscussionId is req!", + }; + } + + const data = await db.comment.findMany({ + where: { + repositoryPath: repositoryPath, + issuePullRequestDiscussionId: issuePullRequestDiscussionId, + }, + }); + + return { success: true, data: data }; +}; diff --git a/actions/repo/issue/createComment.ts b/actions/repo/issue/createComment.ts new file mode 100644 index 0000000..4c21c01 --- /dev/null +++ b/actions/repo/issue/createComment.ts @@ -0,0 +1,69 @@ +"use server"; + +import { db } from "@/lib/db"; +import { Comment } from "@prisma/client"; + +export const createComment = async ({ + repositoryPath, + body, + user, + IssuePullRequestId, +}: { + repositoryPath: string | null; + body: string | null; + user: string | undefined; + IssuePullRequestId: string | undefined; +}) => { + if (!repositoryPath || !user || !IssuePullRequestId) { + return { data: null, success: false }; + } + + if (!body) { + return { data: null, success: false, Message: "Body is required" }; + } + + // find last comment number + + const latestComment = await db.comment.findFirst({ + where: { + repositoryPath: repositoryPath, + }, + orderBy: { + number: "desc", + }, + }); + + // ! DEBUG: [X] console.log("latestComment", latestComment); + + // crete new comment with body author number issuePullRequestDiscussionId + + const nextIssueNumber: number = latestComment ? latestComment.number + 1 : 1; + + // ! DEBUG: [X] console.log("nextIssueNumber", nextIssueNumber) + + const comment: Comment = await db.comment.create({ + data: { + body: body, + author: user, + repositoryPath: repositoryPath, + number: nextIssueNumber, + issuePullRequestDiscussionId: IssuePullRequestId, + }, + }); + + // find issuePullRed and update commentscount to + 1 + + await db.issuePullRequest.update({ + where: { + id: IssuePullRequestId, + repositoryPath: repositoryPath, + }, + data: { + commentscount: { + increment: 1, + }, + }, + }); + + return { data: comment, success: true }; +}; diff --git a/actions/repo/createIssue.ts b/actions/repo/issue/createIssue.ts similarity index 100% rename from actions/repo/createIssue.ts rename to actions/repo/issue/createIssue.ts diff --git a/actions/repo/fetchIssues.ts b/actions/repo/issue/fetchIssues.ts similarity index 100% rename from actions/repo/fetchIssues.ts rename to actions/repo/issue/fetchIssues.ts diff --git a/actions/repo/getIssueByNumber.ts b/actions/repo/issue/getIssueByNumber.ts similarity index 100% rename from actions/repo/getIssueByNumber.ts rename to actions/repo/issue/getIssueByNumber.ts diff --git a/actions/repo/rendomRepo.ts b/actions/repo/rendomRepo.ts index 22bbf4b..1201a8b 100644 --- a/actions/repo/rendomRepo.ts +++ b/actions/repo/rendomRepo.ts @@ -2,9 +2,7 @@ import { db } from "@/lib/db"; -export const ReandomRepos = async ( - limit: number, -) => { +export const ReandomRepos = async (limit: number) => { const ReandomRepo = await db.repository.findMany({ take: limit, where: { diff --git a/app/[username]/[repository]/components/Code.tsx b/app/[username]/[repository]/components/Code.tsx index f778698..4302d12 100644 --- a/app/[username]/[repository]/components/Code.tsx +++ b/app/[username]/[repository]/components/Code.tsx @@ -91,6 +91,7 @@ import { findBlobByName } from "@/hooks/Find-README-file"; import { FetchBlob } from "@/actions/repo/fetchBlob"; import { debounce } from "lodash"; import MarkdownReader from "@/components/mdx-components"; +import ContentLoader from "@/components/ContentLoader"; export type FileItem = { id: string; @@ -121,7 +122,7 @@ export function Code({ repodata }: { repodata: Repository }) { const [md, setMd] = React.useState(""); const [mdload, setMdload] = React.useState(false); const [fetchingdataloadfortree, setFetchingdataloadfortree] = - React.useState(false); + React.useState(true); // ! hooks const user = useCurrentUser(); @@ -149,10 +150,12 @@ export function Code({ repodata }: { repodata: Repository }) { console.log(READMEdata); setMd(READMEdata.data); } + setFetchingdataloadfortree(false); }) .finally(() => { setFetchingdataloadfortree(false); }); + setFetchingdataloadfortree(false); }, 100); React.useEffect(() => { @@ -630,9 +633,9 @@ export function Code({ repodata }: { repodata: Repository }) { - + )} diff --git a/app/[username]/[repository]/issues/[issueNum]/page.tsx b/app/[username]/[repository]/issues/[issueNum]/page.tsx index 230bd13..ab68aa0 100644 --- a/app/[username]/[repository]/issues/[issueNum]/page.tsx +++ b/app/[username]/[repository]/issues/[issueNum]/page.tsx @@ -1,13 +1,21 @@ /* eslint-disable react-hooks/exhaustive-deps */ "use client"; -import { getIssueByNumber } from "@/actions/repo/getIssueByNumber"; +import { getIssueByNumber } from "@/actions/repo/issue/getIssueByNumber"; import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import { Separator } from "@/components/ui/separator"; import { useCurrentUser } from "@/hooks/use-current-user"; -import { IssuePullRequest } from "@prisma/client"; -import { CircleDot, Loader2, Smile } from "lucide-react"; +import { Comment, IssuePullRequest } from "@prisma/client"; +import { + Check, + CircleDot, + GitCommitHorizontal, + Loader2, + Smile, + Tag, + X, +} from "lucide-react"; import Link from "next/link"; import React from "react"; import { Card } from "@/components/ui/card"; @@ -18,6 +26,7 @@ import * as timeago from "timeago.js"; import { ArrowRightIcon, ChatBubbleIcon, + DotsHorizontalIcon, DrawingPinIcon, GearIcon, InfoCircledIcon, @@ -26,6 +35,11 @@ import { } from "@radix-ui/react-icons"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Write } from "@/components/ui/fancy-area/write"; +import ContentLoader from "@/components/ContentLoader"; +import { createComment } from "@/actions/repo/issue/createComment"; +import { fetchComments } from "@/actions/repo/commments/fetchComments"; +import CommentBox from "@/components/Comment"; +import { Badge } from "@/components/ui/badge"; const Page = ({ params, @@ -34,16 +48,18 @@ const Page = ({ }) => { // * hooks const user = useCurrentUser(); + const repositoryPath = `${params.username}/${params.repository}`; // * states const [issue, setIssue] = React.useState(null); const [isLoadin, setIsLoadin] = React.useState(true); const [textValue, setTextValue] = React.useState(""); + const [commentList, setCommentList] = React.useState([]); + const [isPandingComment, setIsPandingComment] = React.useState(false); // * 📐 functions const FetchIssue = async () => { setIsLoadin(true); - const repositoryPath = `${params.username}/${params.repository}`; await getIssueByNumber(params?.issueNum, repositoryPath) .then((res) => { @@ -59,10 +75,46 @@ const Page = ({ FetchIssue(); }, []); + // * 🚀 handel comment + const handelComment = async () => { + setIsPandingComment(true); + await createComment({ + repositoryPath: repositoryPath, + body: textValue, + user: user?.username, + IssuePullRequestId: issue?.id, + }) + .then((data) => { + console.log(data); + FetchIssue(); + setTextValue(""); + }) + .finally(() => setIsPandingComment(false)); + }; + + const fetchCommentlist = async () => { + await fetchComments({ + repositoryPath: repositoryPath, + issuePullRequestDiscussionId: issue?.id, + }).then((data) => { + if (data.success && data.data) { + setCommentList(data?.data); + } + }); + }; + + React.useEffect(() => { + if (issue) { + fetchCommentlist(); + } + }, [issue]); + return (
{isLoadin ? ( - +
+ +
) : ( <> {/* // ! issue info section */} @@ -115,96 +167,220 @@ const Page = ({
{/* // ! left side section */} -
+
{/* // * massage body */} - + + {issue && ( + + )} + + {/* all comments are map here. */} + {/* // ? <><><><><><><><><> map start from bottom <><><><><><><><><> */} + + {/* // ! test section */} + + {/* // todo: first damin */} +
- - +
+
+
+ + + + + - - - + RU + + + ruru-m07{" "} + + added{" "} + + + good first issue + + + label{" "} + + + + 1 weeks ago{" "} + + + + +
-
+ + + {/* // todo: second damin */} + {/* // * commit on issue: 1 */} + +
+
+
+
-
-

- {issue?.author} commented{" "} - {issue - ? timeago.format(issue?.createdAt, "en_US") - : null} -

-
-
- -
-
- + + + + + + RU + +
+ + shadcn{" "} + + commit{" "} + + + fix(fetch-cache): removing unnecessary + 'FETCH' check{" "} + + + + 4 day ago{" "} + + + +
+ + + 98ch8ga + +
-
+
- {/* all comments are map here. */} - {/* // ? <><><><><><><><><> map start from bottom <><><><><><><><><> */} - - + {/* // * commit on issue: 2 */} +
- - +
+
+
+ + + + + - - - + RU + +
+ + samcx{" "} + + commit{" "} + + + fix(fetch-cache): re-add 'FETCH' check{" "} + + + + 2 day ago{" "} + + + +
+ + + 2cd7f6c + +
+
+
+
-
+ + + {/* // ! test section */} + + {commentList && issue && params + ? commentList?.map((comment, index) => ( + + )) + : null} + + {/* // * commit on issue: 2 */} + +
+
+
+
-
-

- rutvik commented{" "} - {issue - ? timeago.format(issue?.createdAt, "en_US") - : null} -

-
-
- -
-
- + + + + + + RU + +
+ + JeonEno{" "} + + commit{" "} + + + fix: prevent scrolling to hash{" "} + + + + 1 hours ago{" "} + + + +
+ + + 9d73jo8 + +
-
+
@@ -212,13 +388,13 @@ const Page = ({ {/* // ! Add a comment section */} - +
- + @@ -226,13 +402,13 @@ const Page = ({

Add a comment @@ -276,13 +452,20 @@ const Page = ({

- +
- {/* // todo: right side section */} - + {/* // ! right side section */} + {/* Assignees */}
diff --git a/app/[username]/[repository]/issues/new/page.tsx b/app/[username]/[repository]/issues/new/page.tsx index b6fab31..2f2c3df 100644 --- a/app/[username]/[repository]/issues/new/page.tsx +++ b/app/[username]/[repository]/issues/new/page.tsx @@ -6,7 +6,7 @@ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import { createIssue } from "@/actions/repo/createIssue"; +import { createIssue } from "@/actions/repo/issue/createIssue"; import { useCurrentUser } from "@/hooks/use-current-user"; import { fetchRepo } from "@/actions/repo/fetch"; import { Repository } from "@prisma/client"; diff --git a/app/[username]/[repository]/issues/page.tsx b/app/[username]/[repository]/issues/page.tsx index 06e1410..eff2871 100644 --- a/app/[username]/[repository]/issues/page.tsx +++ b/app/[username]/[repository]/issues/page.tsx @@ -20,10 +20,11 @@ import { IssuePullRequest, Repository } from "@prisma/client"; import Link from "next/link"; import { fetchRepo } from "@/actions/repo/fetch"; import React from "react"; -import { fetchIssues } from "@/actions/repo/fetchIssues"; +import { fetchIssues } from "@/actions/repo/issue/fetchIssues"; import { useCurrentUser } from "@/hooks/use-current-user"; import Loader2 from "@/components/Loader2"; import { CheckIcon } from "@radix-ui/react-icons"; +import ContentLoader from "@/components/ContentLoader"; const Page = ({ params, @@ -37,8 +38,7 @@ const Page = ({ ); const [openIssues, setOpenIssues] = React.useState(0); const [closedIssues, setClosedIssues] = React.useState(0); - const [isFetchingIssues, setIsFetchingIssues] = - React.useState(false); + const [isFetchingIssues, setIsFetchingIssues] = React.useState(true); // ! hooks const user = useCurrentUser(); @@ -58,7 +58,6 @@ const Page = ({ }; const fetchingIssue = async () => { - setIsFetchingIssues(true); await fetchIssues(repo) .then((res) => { setIssueData(res.issues); @@ -184,7 +183,7 @@ const Page = ({ {!isFetchingIssues ? ( issueData?.length ? (
- +

{openIssues} Open

@@ -198,7 +197,7 @@ const Page = ({ {issueData?.reverse().map((item, index) => (
@@ -206,7 +205,10 @@ const Page = ({
- + {item.title}
@@ -234,13 +236,15 @@ const Page = ({
) : ( -
-

no any issue yet

+
+

+ This repository has no open issues. +

) ) : ( -
- +
+
)} diff --git a/app/[username]/[repository]/page.tsx b/app/[username]/[repository]/page.tsx index 9e80d4d..110eb3f 100644 --- a/app/[username]/[repository]/page.tsx +++ b/app/[username]/[repository]/page.tsx @@ -1,19 +1,18 @@ "use client"; import { fetchRepo } from "@/actions/repo/fetch"; -import Loader2 from "@/components/Loader2"; import { Repository } from "@prisma/client"; import React, { useEffect, useState } from "react"; import NotFound from "./components/notFound"; import { Code } from "./components/Code"; import { useCurrentUser } from "@/hooks/use-current-user"; +import ContentLoader from "@/components/ContentLoader"; const Page = ({ params, }: { params: { username: string; repository: string }; }) => { - // * Hooks const user = useCurrentUser(); @@ -48,7 +47,7 @@ const Page = ({
{isloading ? (
- +
) : repoNotFound ? ( diff --git a/app/[username]/[repository]/upload/components/Upload.tsx b/app/[username]/[repository]/upload/components/Upload.tsx index 43e00b1..390db69 100644 --- a/app/[username]/[repository]/upload/components/Upload.tsx +++ b/app/[username]/[repository]/upload/components/Upload.tsx @@ -265,7 +265,7 @@ const Upload = () => { Drag files here to add them to your repository

- or + or {" "} choose your file diff --git a/app/settings/page.tsx b/app/settings/page.tsx index b88c92a..08bd22a 100644 --- a/app/settings/page.tsx +++ b/app/settings/page.tsx @@ -269,7 +269,11 @@ const Page = () => {

- +
diff --git a/components/Comment.tsx b/components/Comment.tsx new file mode 100644 index 0000000..8498eac --- /dev/null +++ b/components/Comment.tsx @@ -0,0 +1,162 @@ +import Link from "next/link"; +import { Avatar, AvatarFallback, AvatarImage } from "./ui/avatar"; +import { Card } from "./ui/card"; +import { ASSETS } from "@/data/variables"; +import { Comment, IssuePullRequest } from "@prisma/client"; +import * as timeago from "timeago.js"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { Badge } from "@/components/ui/badge"; +import { DotsHorizontalIcon } from "@radix-ui/react-icons"; +import { useCurrentUser } from "@/hooks/use-current-user"; +import { PUBLIC_URL } from "@/resources"; +import { Params } from "next/dist/shared/lib/router/utils/route-matcher"; +import { Write } from "./ui/fancy-area/write"; +import { Button } from "./ui/button"; +import MarkdownReader from "./mdx-components"; +import { Smile } from "lucide-react"; +import React from "react"; + +const CommentBox = ({ + comment, + refData, + params, + asHeader = false, +}: { + comment?: Comment; + refData: IssuePullRequest; + params: Params; + asHeader?: boolean; +}) => { + // * hooks + const user = useCurrentUser(); + + const [textValue, setTextValue] = React.useState(""); + + return ( + +
+ + + + + + +
+
+ +
+

+ {comment?.author || refData.author} commented{" "} + {refData + ? timeago.format( + comment?.createdAt || refData.createdAt, + "en_US", + ) + : null} +

+ {comment?.isEdited && â€ĸ Edited} +
+ {refData?.author === comment?.author && ( + + {" "} + Author{" "} + + )} + + + + + + + Actions + + {comment?.author === user?.username && ( + + + Edit + + + )} + + !asHeader && + navigator.clipboard.writeText( + `${PUBLIC_URL}/${params.username}/${params.repository}/issues/${params.issueNum}#comment-${comment?.number}`, + ) + } + > + Copy link + + + Report content + + + + + Edit comment #{comment?.number} + + This action cannot be undone. Are you sure you want to + edit this comment? + + + + + + + + + + +
+
+
+ +
+
+ +
+
+
+
+
+ ); +}; + +export default CommentBox; diff --git a/components/UploadImages.tsx b/components/UploadImages.tsx index 646045a..6cb0657 100644 --- a/components/UploadImages.tsx +++ b/components/UploadImages.tsx @@ -20,7 +20,11 @@ interface UploadImageProps { user: string | undefined; } -const ImageUpload: React.FC = ({ preview, setPreview, user }) => { +const ImageUpload: React.FC = ({ + preview, + setPreview, + user, +}) => { const [selectedFile, setSelectedFile] = useState(null); const [isLoading, setIsLoading] = useState(false); diff --git a/components/auth/new-verification-form.tsx b/components/auth/new-verification-form.tsx index 91655fb..1cbdbfc 100644 --- a/components/auth/new-verification-form.tsx +++ b/components/auth/new-verification-form.tsx @@ -10,7 +10,7 @@ import { FormSuccess } from "@/components/form-success"; import ContentLoader from "../ContentLoader"; export const NewVerificationForm = () => { - const router = useRouter() + const router = useRouter(); const [error, setError] = useState(); const [success, setSuccess] = useState(); diff --git a/components/mdx-components.tsx b/components/mdx-components.tsx index aadb4c0..bc346ac 100644 --- a/components/mdx-components.tsx +++ b/components/mdx-components.tsx @@ -31,6 +31,8 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { coldarkDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; import { remark } from "remark"; import { Mention } from "./ui/fancy-area/mention"; +import rehypeKatex from "rehype-katex"; +import remarkMath from "remark-math"; const customStyle = { backgroundColor: "#18181b", @@ -47,7 +49,7 @@ const components = { h1: ({ className, ...props }: React.HTMLAttributes) => (

) => (

) => (

) => (

) => (

) => (
{ return (
{mdSourse} diff --git a/components/repository/new/New.tsx b/components/repository/new/New.tsx index df241f5..c3025ad 100644 --- a/components/repository/new/New.tsx +++ b/components/repository/new/New.tsx @@ -97,11 +97,13 @@ const New = () => {

Required fields are marked with an asterisk (*).

-
+

owner *

-
@{user?.username}
+
+ @{user?.username} +
diff --git a/components/ui/breadcrumb.tsx b/components/ui/breadcrumb.tsx index 26560ef..d1f7d7d 100644 --- a/components/ui/breadcrumb.tsx +++ b/components/ui/breadcrumb.tsx @@ -1,16 +1,16 @@ -import * as React from "react" -import { ChevronRightIcon, DotsHorizontalIcon } from "@radix-ui/react-icons" -import { Slot } from "@radix-ui/react-slot" +import * as React from "react"; +import { ChevronRightIcon, DotsHorizontalIcon } from "@radix-ui/react-icons"; +import { Slot } from "@radix-ui/react-slot"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const Breadcrumb = React.forwardRef< HTMLElement, React.ComponentPropsWithoutRef<"nav"> & { - separator?: React.ReactNode + separator?: React.ReactNode; } ->(({ ...props }, ref) =>