Skip to content
Merged
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
27 changes: 24 additions & 3 deletions src/components/repositories/RepositoryMaintainers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,28 @@ import {
useTheme,
} from '@mui/material';
import { useRepositoryMaintainers } from '../../api';
import { type RepositoryMaintainer } from '../../api/models';
import { STATUS_COLORS } from '../../theme';

interface RepositoryMaintainersProps {
repositoryFullName: string;
}

// When the API lists no maintainers (or the request fails), fall back to the
// repo owner so the section never disappears from the sidebar.
const ownerFallback = (repositoryFullName: string): RepositoryMaintainer[] => {
const owner = repositoryFullName.split('/')[0];
if (!owner) return [];
return [
{
login: owner,
avatarUrl: `https://github.com/${owner}.png?size=80`,
htmlUrl: `https://github.com/${owner}`,
type: 'User',
},
];
};

const RepositoryMaintainers: React.FC<RepositoryMaintainersProps> = ({
repositoryFullName,
}) => {
Expand Down Expand Up @@ -44,7 +60,12 @@ const RepositoryMaintainers: React.FC<RepositoryMaintainersProps> = ({
);
}

if (!maintainers || maintainers.length === 0) {
const displayMaintainers =
maintainers && maintainers.length > 0
? maintainers
: ownerFallback(repositoryFullName);

if (displayMaintainers.length === 0) {
return null;
}

Expand All @@ -62,12 +83,12 @@ const RepositoryMaintainers: React.FC<RepositoryMaintainersProps> = ({
component="span"
sx={{ color: STATUS_COLORS.open, fontSize: '0.8em' }}
>
({maintainers.length})
({displayMaintainers.length})
</Typography>
</Typography>

<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1.5 }}>
{maintainers.map((maintainer) => (
{displayMaintainers.map((maintainer) => (
<Tooltip key={maintainer.login} title={maintainer.login} arrow>
<Link
href={maintainer.htmlUrl}
Expand Down
10 changes: 4 additions & 6 deletions src/pages/RepositoryDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,10 @@ const RepositoryDetailsPage: React.FC = () => {
{/* Repository Stats */}
<RepositoryStats repositoryFullName={repo} />

{tabValue === 4 || tabValue === 5 ? (
<RepositoryPrActivityChart
repositoryFullName={repo}
viewMode={tabValue === 4 ? 'issues' : 'prs'}
/>
) : null}
<RepositoryPrActivityChart
repositoryFullName={repo}
viewMode={tabValue === 4 ? 'issues' : 'prs'}
/>

<RepositorySocialLinks repositoryFullName={repo} />

Expand Down
Loading