Skip to content

Commit

Permalink
feat: make project URL clickable (#1429)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt authored Jan 7, 2024
1 parent c21abf9 commit c48cd2b
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion frontend/src/pages/LiveFeedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PageLayout from './PageLayout';
import {
Box,
LinearProgress,
Link,
Table,
TableBody,
TableCell,
Expand All @@ -14,6 +15,7 @@ import { Error } from '@mui/icons-material';
import React from 'react';
import AppBreadcrumbs from '../component/StyledBreadCrumb';
import { DateTimeFormatter, LocalDateTime } from '@js-joda/core';
import { useNavigate } from 'react-router-dom';

const breadcrumbItems = [{ text: 'Home', href: '/home' }, { text: 'LiveFeed' }];

Expand Down Expand Up @@ -85,7 +87,7 @@ export function LiveFeedPage() {
)}
>
<TableCell>{run?.projectName}</TableCell>
<TableCell>{run?.projectUrl}</TableCell>
<TableCell>{ClickableTableCell(run!.projectUrl!)}</TableCell>
<TableCell>{stripCommitHash(run?.commitHash)}</TableCell>
<TableCell>{run?.analyzerName}</TableCell>
<TableCell>{run?.numberOfIssues}</TableCell>
Expand All @@ -110,3 +112,32 @@ const formatTimestamp = (timestamp: string): string => {
const dateTime = LocalDateTime.parse(timestamp);
return dateTime.format(DateTimeFormatter.ofPattern(' d/M/yyyy HH:mm'));
};

function ClickableTableCell(url: string) {
const navigate = useNavigate();

return (
<TableCell>
<Link
sx={{
color: 'white',
'&:hover': {
color: 'black',
},
}}
>
<a
href={url}
target="_blank"
rel="noopener noreferrer"
onClick={(event) => {
event.preventDefault();
navigate(url);
}}
>
{url}
</a>
</Link>
</TableCell>
);
}

0 comments on commit c48cd2b

Please sign in to comment.