Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 14 additions & 5 deletions src/api/PrsApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Pull Request API hooks - uses /prs endpoints
import { useApiQuery } from './ApiUtils';
import { type CommitLog, type PullRequestDetails } from './models/Dashboard';
import {
type CommitLog,
type PullRequestComment,
type PullRequestDetails,
} from './models/Dashboard';

/**
* Helper to create /prs endpoint queries
Expand Down Expand Up @@ -54,7 +58,12 @@ export const usePullRequestDetails = (
* @param number - Pull request number
*/
export const usePullRequestComments = (repo: string, number: number) =>
usePrsQuery<any[]>('usePullRequestComments', '/comments', undefined, {
repo,
number,
});
usePrsQuery<PullRequestComment[]>(
'usePullRequestComments',
'/comments',
undefined,
{
repo,
number,
},
);
4 changes: 2 additions & 2 deletions src/api/models/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type Stats = {
percentChange24h: number;
percentChange7d: number;
lastUpdated: string;
metadata: any;
metadata: Record<string, unknown>;
} | null;
lastUpdated: string | null;
};
Expand All @@ -60,7 +60,7 @@ export type Stats = {
percentChange24h: number;
percentChange7d: number;
lastUpdated: string;
metadata: any;
metadata: Record<string, unknown>;
} | null;
lastUpdated: string | null;
};
Expand Down
21 changes: 18 additions & 3 deletions src/components/issues/IssueConversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,30 @@ import remarkGfm from 'remark-gfm';
import rehypeRaw from 'rehype-raw';
import { type IssueDetails } from '../../api/models/Issues';
import { STATUS_COLORS } from '../../theme';

import 'github-markdown-css/github-markdown-dark.css';

/** An issue comment or the issue body rendered in the conversation timeline. */
type ConversationItem = {
id: string;
user: {
login: string | null;
avatarUrl: string;
htmlUrl: string;
};
body: string;
createdAt: string;
authorAssociation: string;
isDescription?: boolean;
};

interface IssueConversationProps {
issue: IssueDetails;
}

const IssueConversation: React.FC<IssueConversationProps> = ({ issue }) => {
const theme = useTheme();
const allItems = [
const allItems: ConversationItem[] = [
{
id: 'issue-description',
user: {
Expand Down Expand Up @@ -63,7 +78,7 @@ const IssueConversation: React.FC<IssueConversationProps> = ({ issue }) => {
position: 'relative',
}}
>
{allItems.map((item: any, index: number) => (
{allItems.map((item, index) => (
<Box
key={item.id}
sx={{
Expand Down Expand Up @@ -92,7 +107,7 @@ const IssueConversation: React.FC<IssueConversationProps> = ({ issue }) => {
>
<Avatar
src={item.user.avatarUrl}
alt={item.user.login}
alt={item.user.login ?? undefined}
sx={{
width: 40,
height: 40,
Expand Down
12 changes: 10 additions & 2 deletions src/components/leaderboard/SectionCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import React from 'react';
import { Card, Box, Typography, CardContent, Grid } from '@mui/material';
import {
Card,
Box,
Typography,
CardContent,
Grid,
type SxProps,
type Theme,
} from '@mui/material';

export const SectionCard: React.FC<{
children: React.ReactNode;
sx?: any;
sx?: SxProps<Theme>;
title?: string;
action?: React.ReactNode;
centerContent?: React.ReactNode;
Expand Down
4 changes: 3 additions & 1 deletion src/components/leaderboard/TopRepositoriesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
Button,
Switch,
FormControlLabel,
type SxProps,
type Theme,
} from '@mui/material';
import SearchIcon from '@mui/icons-material/Search';
import BarChartIcon from '@mui/icons-material/BarChart';
Expand Down Expand Up @@ -412,7 +414,7 @@ const TopRepositoriesTable: React.FC<TopRepositoriesTableProps> = ({
column: SortColumn;
children: React.ReactNode;
align?: 'left' | 'right';
sx?: any;
sx?: SxProps<Theme>;
}) => (
<TableCell
align={align}
Expand Down
3 changes: 2 additions & 1 deletion src/components/miners/MinerScoreCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
useAllMiners,
useMinerGithubData,
useGeneralConfig,
type MinerEvaluation,
} from '../../api';
import {
RANK_COLORS,
Expand Down Expand Up @@ -233,7 +234,7 @@ const MinerScoreCard: React.FC<MinerScoreCardProps> = ({ githubId }) => {

const rankings = useMemo(() => {
if (!allMinersStats || !minerStats) return null;
const rank = (_key: string, extract: (m: any) => number) =>
const rank = (_key: string, extract: (m: MinerEvaluation) => number) =>
allMinersStats
.slice()
.sort((a, b) => extract(b) - extract(a))
Expand Down
17 changes: 14 additions & 3 deletions src/components/prs/PRComments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@ import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import rehypeRaw from 'rehype-raw';
import { usePullRequestComments } from '../../api';
import { type PullRequestDetails } from '../../api/models/Dashboard';
import {
type PullRequestComment,
type PullRequestDetails,
} from '../../api/models/Dashboard';
import { STATUS_COLORS } from '../../theme';
import 'github-markdown-css/github-markdown-dark.css'; // Import standard GitHub Dark styles

/** A comment or the PR description rendered in the conversation timeline. */
type ConversationItem = Omit<PullRequestComment, 'id'> & {
id: number | string;
isDescription?: boolean;
};

interface PRCommentsProps {
repository: string;
pullRequestNumber: number;
Expand Down Expand Up @@ -51,7 +60,7 @@ const PRComments: React.FC<PRCommentsProps> = ({
);
}

const allItems = [
const allItems: ConversationItem[] = [
{
id: 'pr-description',
user: {
Expand All @@ -61,6 +70,8 @@ const PRComments: React.FC<PRCommentsProps> = ({
},
body: prDetails.description || '<em>No description provided.</em>',
createdAt: prDetails.createdAt,
updatedAt: prDetails.createdAt,
htmlUrl: '',
authorAssociation: 'OWNER',
isDescription: true,
},
Expand Down Expand Up @@ -102,7 +113,7 @@ const PRComments: React.FC<PRCommentsProps> = ({
position: 'relative',
}}
>
{allItems.map((item: any, index: number) => (
{allItems.map((item, index) => (
<Box
key={item.id}
sx={{
Expand Down
3 changes: 2 additions & 1 deletion src/components/prs/PRHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { Box, Typography, Avatar, Tooltip, alpha } from '@mui/material';
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
import { useNavigate } from 'react-router-dom';
import { formatUsdEstimate } from '../../utils';
import { type PullRequestDetails } from '../../api/models/Dashboard';
import theme, { STATUS_COLORS } from '../../theme';
interface PRHeaderProps {
repository: string;
pullRequestNumber: number;
prDetails: any; // Using any for now to avoid duplicating the full type definition, or import it if available
prDetails: PullRequestDetails;
}

const PRHeader: React.FC<PRHeaderProps> = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/repositories/ContributingViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const ContributingViewer: React.FC<ContributingViewerProps> = ({
}

// Custom renderer for images to handle relative paths
const ImageRenderer = (props: any) => {
const ImageRenderer = (props: React.ImgHTMLAttributes<HTMLImageElement>) => {
const { src, alt, ...rest } = props;
let finalSrc = src;

Expand Down
4 changes: 3 additions & 1 deletion src/components/repositories/FileExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ const FileItem: React.FC<{
);
};

export const buildFileTree = (flatFiles: any[]): FileNode[] => {
export const buildFileTree = (
flatFiles: { path: string; type: 'blob' | 'tree' }[],
): FileNode[] => {
const root: FileNode[] = [];
const map: Record<string, FileNode> = {};

Expand Down
2 changes: 1 addition & 1 deletion src/components/repositories/ReadmeViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const ReadmeViewer: React.FC<ReadmeViewerProps> = ({ repositoryFullName }) => {
}

// Custom renderer for images to handle relative paths
const ImageRenderer = (props: any) => {
const ImageRenderer = (props: React.ImgHTMLAttributes<HTMLImageElement>) => {
const { src, alt, ...rest } = props;
let finalSrc = src;

Expand Down
6 changes: 4 additions & 2 deletions src/components/repositories/RepositoryCheckTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ const RepositoryCheckTab: React.FC<RepositoryCheckTabProps> = ({
`https://api.github.com/repos/${repositoryFullName}/git/trees/${branch}?recursive=1`,
);
if (treeRes.data.tree) {
setFileTree(treeRes.data.tree.map((node: any) => node.path));
setFileTree(
treeRes.data.tree.map((node: { path: string }) => node.path),
);
}

// Fetch issue counts
Expand All @@ -96,7 +98,7 @@ const RepositoryCheckTab: React.FC<RepositoryCheckTabProps> = ({
setOpenIssuesCount(repoData.open_issues_count);
}
}
} catch (err: any) {
} catch (err: unknown) {
console.error('Failed to fetch repo check data', err);
setError('Failed to load repository health data.');
} finally {
Expand Down
4 changes: 2 additions & 2 deletions src/components/repositories/RepositoryCodeBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ const RepositoryCodeBrowser: React.FC<RepositoryCodeBrowserProps> = ({
const nodes = buildFileTree(treeResponse.data.tree);
setTree(nodes);
}
} catch (err: any) {
} catch (err: unknown) {
console.error('Failed to load repository data', err);
if (err.response?.status === 403) {
if (axios.isAxiosError(err) && err.response?.status === 403) {
setError('GitHub API rate limit exceeded. Please try again later.');
} else {
setError('Failed to load repository structure.');
Expand Down