Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/apps/github/graphql/nodes/issue.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
"""GitHub issue GraphQL node."""

import graphene

from apps.common.graphql.nodes import BaseNode
from apps.github.models.issue import Issue


class IssueNode(BaseNode):
"""GitHub issue node."""

repository_name = graphene.String()

class Meta:
model = Issue
fields = (
Expand All @@ -17,3 +21,7 @@ class Meta:
"title",
"url",
)

def resolve_repository_name(self, info):
"""Resolve the repository name."""
return self.repository.name
5 changes: 5 additions & 0 deletions backend/apps/github/graphql/nodes/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class PullRequestNode(BaseNode):
"""GitHub pull request node."""

repository_name = graphene.String()
url = graphene.String()

class Meta:
Expand All @@ -19,6 +20,10 @@ class Meta:
"title",
)

def resolve_repository_name(self, info):
"""Resolve repository name."""
return self.repository.name

def resolve_url(self, info):
"""Resolve URL."""
return self.url
28 changes: 15 additions & 13 deletions frontend/src/app/members/[memberKey]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,16 @@ const UserDetailsPage: React.FC = () => {
const formattedIssues: ProjectIssuesType[] = useMemo(() => {
return (
issues?.map((issue) => ({
commentsCount: issue.commentsCount,
createdAt: issue.createdAt,
title: issue.title,
author: {
login: user?.login || '',
avatarUrl: user?.avatarUrl || '',
key: user?.login || '',
login: user?.login || '',
name: user?.name || user?.login || '',
},
commentsCount: issue.commentsCount,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still use the comments count?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no no . somehow i didn't noticed that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will do the cleanup!!!

createdAt: issue.createdAt,
repositoryName: issue.repositoryName,
title: issue.title,
url: issue.url,
})) || []
)
Expand All @@ -130,14 +131,15 @@ const UserDetailsPage: React.FC = () => {
const formattedPullRequest: ItemCardPullRequests[] = useMemo(() => {
return (
pullRequests?.map((pullRequest) => ({
createdAt: pullRequest.createdAt,
title: pullRequest.title,
author: {
login: user?.login || '',
avatarUrl: user?.avatarUrl || '',
key: user?.login || '',
login: user?.login || '',
name: user?.name || user?.login || '',
},
createdAt: pullRequest.createdAt,
repositoryName: pullRequest.repositoryName,
title: pullRequest.title,
url: pullRequest.url,
})) || []
)
Expand All @@ -146,17 +148,17 @@ const UserDetailsPage: React.FC = () => {
const formattedReleases: ProjectReleaseType[] = useMemo(() => {
return (
releases?.map((release) => ({
isPreRelease: release.isPreRelease,
name: release.name,
publishedAt: release.publishedAt,
tagName: release.tagName,
repositoryName: release.repositoryName,
author: {
login: user?.login || '',
avatarUrl: user?.avatarUrl || '',
key: user?.login || '',
login: user?.login || '',
name: user?.name || user?.login || '',
},
isPreRelease: release.isPreRelease,
name: release.name,
publishedAt: release.publishedAt,
repositoryName: release.repositoryName,
tagName: release.tagName,
url: release.url,
})) || []
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export default function Home() {
/>
<div className="grid-cols-2 gap-4 lg:grid">
<RecentIssues data={data?.recentIssues} />
<RecentPullRequests data={data?.recentPullRequests} showAuthor={true} />
<RecentPullRequests data={data?.recentPullRequests} />
</div>
<RecentReleases data={data?.recentReleases} />
<SecondaryCard icon={faNewspaper} title="News & Opinions" className="overflow-hidden">
Expand Down
33 changes: 22 additions & 11 deletions frontend/src/components/ItemCardList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IconProp } from '@fortawesome/fontawesome-svg-core'
import { Tooltip } from '@heroui/tooltip'
import Image from 'next/image'
import Link from 'next/link'
import { JSX } from 'react'
Expand All @@ -22,6 +23,7 @@ const ItemCardList = ({
createdAt: string
commentsCount: number
publishedAt: string
repositoryName: string
tagName: string
author: {
avatarUrl: string
Expand All @@ -38,18 +40,27 @@ const ItemCardList = ({
<div className="flex w-full flex-col justify-between">
<div className="flex w-full items-center">
{showAvatar && (
<Link
className="flex-shrink-0 text-blue-400 hover:underline"
href={`/members/${item?.author?.login}`}
<Tooltip
closeDelay={100}
content={item?.author?.name || item?.author?.login}
id={`avatar-tooltip-${index}`}
delay={100}
placement="bottom"
showArrow
>
<Image
height={24}
width={24}
src={item?.author?.avatarUrl}
alt={item?.author?.name || ''}
className="mr-2 rounded-full"
/>
</Link>
<Link
className="flex-shrink-0 text-blue-400 hover:underline"
href={`/members/${item?.author?.login}`}
>
<Image
height={24}
width={24}
src={item?.author?.avatarUrl}
alt={item?.author?.name || ''}
className="mr-2 rounded-full"
/>
</Link>
</Tooltip>
)}
<h3 className="flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-semibold">
<Link
Expand Down
19 changes: 11 additions & 8 deletions frontend/src/components/RecentIssues.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { faCalendar, faFileCode, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Link from 'next/link'
import React from 'react'
import { ProjectIssuesType } from 'types/project'
import { formatDate } from 'utils/dateFormatter'
import { pluralize } from 'utils/pluralize'
import ItemCardList from './ItemCardList'

interface RecentIssuesProps {
Expand All @@ -24,14 +24,17 @@ const RecentIssues: React.FC<RecentIssuesProps> = ({ data, showAvatar = true })
<FontAwesomeIcon icon={faCalendar} className="mr-2 h-4 w-4" />
<span>{formatDate(item.createdAt)}</span>
</div>
{item?.commentsCount ? (
<div className="flex items-center">
<FontAwesomeIcon icon={faFileCode} className="mr-2 h-4 w-4" />
<span>
{item.commentsCount} {pluralize(item.commentsCount, 'comment')}
</span>
{item?.repositoryName && (
<div className="item-center flex">
<FontAwesomeIcon icon={faFileCode} className="ml-4 mr-2 h-4 w-4" />
<Link
className="text-gray-600 hover:underline dark:text-gray-400"
href={`/repositories/${item?.repositoryName ? item.repositoryName.toLowerCase() : ''}`}
>
<span>{item.repositoryName}</span>
</Link>{' '}
</div>
) : null}
)}
</div>
)}
/>
Expand Down
28 changes: 14 additions & 14 deletions frontend/src/components/RecentPullRequests.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { faCalendar, faCodePullRequest, faUser } from '@fortawesome/free-solid-svg-icons'
import { faCalendar, faCodePullRequest, faFileCode } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Link from 'next/link'
import React from 'react'
import { PullRequestsType } from 'types/home'
import { ItemCardPullRequests } from 'types/user'
Expand All @@ -9,14 +10,9 @@ import ItemCardList from './ItemCardList'
interface RecentPullRequestsProps {
data: ItemCardPullRequests[] | PullRequestsType[]
showAvatar?: boolean
showAuthor?: boolean
}

const RecentPullRequests: React.FC<RecentPullRequestsProps> = ({
data,
showAvatar = true,
showAuthor = false,
}) => {
const RecentPullRequests: React.FC<RecentPullRequestsProps> = ({ data, showAvatar = true }) => {
return (
<ItemCardList
title="Recent Pull Requests"
Expand All @@ -30,13 +26,17 @@ const RecentPullRequests: React.FC<RecentPullRequestsProps> = ({
<span>{formatDate(item.createdAt)}</span>
</div>

{showAuthor &&
(item?.author?.name || item?.author?.login ? (
<div className="flex items-center">
<FontAwesomeIcon icon={faUser} className="mr-2 h-4 w-4" />
<span>{item.author.name || item.author.login}</span>
</div>
) : null)}
{item?.repositoryName && (
<div className="item-center flex">
<FontAwesomeIcon icon={faFileCode} className="ml-4 mr-2 h-4 w-4" />
<Link
className="text-gray-600 hover:underline dark:text-gray-400"
href={`/repositories/${item?.repositoryName ? item.repositoryName.toLowerCase() : ''}`}
>
<span>{item.repositoryName}</span>
</Link>{' '}
</div>
)}
</div>
)}
/>
Expand Down
32 changes: 21 additions & 11 deletions frontend/src/components/RecentReleases.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { faCalendar, faFileCode, faTag } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { Tooltip } from '@heroui/tooltip'
import Image from 'next/image'
import Link from 'next/link'
import React from 'react'
Expand Down Expand Up @@ -30,18 +31,27 @@ const RecentReleases: React.FC<RecentReleasesProps> = ({
<div className="flex w-full flex-col justify-between">
<div className="flex w-full items-center">
{showAvatar && (
<Link
className="flex-shrink-0 text-blue-400 hover:underline"
href={`/members/${item?.author?.login}`}
<Tooltip
closeDelay={100}
content={item?.author?.name || item?.author?.login}
id={`avatar-tooltip-${index}`}
delay={100}
placement="bottom"
showArrow
>
<Image
alt={item?.author?.name || 'author'}
className="mr-2 h-6 w-6 rounded-full"
height={24}
src={item?.author?.avatarUrl || ''}
width={24}
/>
</Link>
<Link
className="flex-shrink-0 text-blue-400 hover:underline"
href={`/members/${item?.author?.login}`}
>
<Image
alt={item?.author?.name || 'author'}
className="mr-2 h-6 w-6 rounded-full"
height={24}
src={item?.author?.avatarUrl || ''}
width={24}
/>
</Link>
</Tooltip>
)}
<h3 className="flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-semibold">
<Link
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/server/queries/homeQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const GET_MAIN_PAGE_DATA = gql`
recentIssues(limit: 5, distinct: $distinct) {
commentsCount
createdAt
repositoryName
title
url
author {
Expand All @@ -51,6 +52,7 @@ export const GET_MAIN_PAGE_DATA = gql`
}
createdAt
title
repositoryName
url
}
recentReleases(limit: 9, distinct: $distinct) {
Expand Down
18 changes: 10 additions & 8 deletions frontend/src/server/queries/organizationQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,25 @@ export const GET_ORGANIZATION_DATA = gql`
avatarUrl
}
recentPullRequests(limit: 5, organization: $login, distinct: true) {
title
createdAt
url
author {
login
avatarUrl
}
createdAt
repositoryName
title
url
}
recentReleases(limit: 6, organization: $login, distinct: true) {
name
tagName
publishedAt
url
repositoryName
author {
login
avatarUrl
}
name
publishedAt
repositoryName
tagName
url
}
repositories(organization: $login, limit: 12) {
name
Expand All @@ -65,6 +66,7 @@ export const GET_ORGANIZATION_DATA = gql`
}
commentsCount
createdAt
repositoryName
title
url
}
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/server/queries/projectQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ export const GET_PROJECT_DATA = gql`
level
name
recentIssues {
title
commentsCount
createdAt
url
author {
avatarUrl
login
name
url
}
commentsCount
createdAt
title
repositoryName
url
}
recentReleases {
author {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/server/queries/userQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export const GET_USER_DATA = gql`
recentIssues(limit: 5, login: $key) {
commentsCount
createdAt
repositoryName
title
url
}
recentPullRequests(limit: 5, login: $key) {
createdAt
repositoryName
title
url
}
Expand Down
Loading
Loading