Skip to content

Commit bc01995

Browse files
committed
chore: replace anchors to user with UserLink so in one place
1 parent a0e5bcc commit bc01995

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

src/routes.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,10 @@ const dashboardRoutes: Route[] = [
9090
visible: true,
9191
},
9292
{
93-
path: '/admin/user/:id',
93+
path: '/user/:id',
9494
name: 'User',
9595
icon: Person,
96-
component: (props) => (
97-
<RouteGuard component={User} fullRoutePath={`/dashboard/admin/user/:id`} />
98-
),
96+
component: (props) => <RouteGuard component={User} fullRoutePath={`/dashboard/user/:id`} />,
9997
layout: '/dashboard',
10098
visible: false,
10199
},
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import { Link } from 'react-router-dom';
3+
4+
interface UserLinkProps {
5+
username: string;
6+
children?: React.ReactNode;
7+
}
8+
9+
const UserLink: React.FC<UserLinkProps> = ({ username, children }) => {
10+
return <Link to={`/dashboard/user/${username}`}>{children || username}</Link>;
11+
};
12+
13+
export default UserLink;

src/ui/views/PushDetails/PushDetails.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Tooltip from '@material-ui/core/Tooltip';
2525
import { PushData } from '../../../types/models';
2626
import { trimPrefixRefsHeads, trimTrailingDotGit } from '../../../db/helper';
2727
import { generateEmailLink, getGitProvider } from '../../utils';
28+
import UserLink from '../../components/UserLink/UserLink';
2829

2930
const Dashboard: React.FC = () => {
3031
const { id } = useParams<{ id: string }>();
@@ -198,25 +199,21 @@ const Dashboard: React.FC = () => {
198199
) : (
199200
<>
200201
{isGitHub && (
201-
<a href={`/dashboard/user/${data.attestation.reviewer.username}`}>
202+
<UserLink username={data.attestation.reviewer.username}>
202203
<img
203204
style={{ width: '45px', borderRadius: '20px' }}
204205
src={`https://github.com/${data.attestation.reviewer.gitAccount}.png`}
205206
/>
206-
</a>
207+
</UserLink>
207208
)}
208209
<div>
209210
<p>
210211
{isGitHub && (
211-
<a href={`/dashboard/user/${data.attestation.reviewer.username}`}>
212+
<UserLink username={data.attestation.reviewer.username}>
212213
{data.attestation.reviewer.gitAccount}
213-
</a>
214+
</UserLink>
214215
)}
215-
{!isGitHub && (
216-
<a href={`/dashboard/user/${data.attestation.reviewer.username}`}>
217-
{data.attestation.reviewer.username}
218-
</a>
219-
)}{' '}
216+
{!isGitHub && <UserLink username={data.attestation.reviewer.username} />}{' '}
220217
approved this contribution
221218
</p>
222219
</div>

src/ui/views/RepoDetails/RepoDetails.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import CodeActionButton from '../../components/CustomButtons/CodeActionButton';
2323
import { trimTrailingDotGit } from '../../../db/helper';
2424
import { fetchRemoteRepositoryData } from '../../utils';
2525
import { SCMRepositoryMetadata } from '../../../types/models';
26+
import UserLink from '../../components/UserLink/UserLink';
2627

2728
interface RepoData {
2829
_id: string;
@@ -200,7 +201,7 @@ const RepoDetails: React.FC = () => {
200201
{data.users.canAuthorise.map((row) => (
201202
<TableRow key={row}>
202203
<TableCell align='left'>
203-
<a href={`/dashboard/user/${row}`}>{row}</a>
204+
<UserLink username={row} />
204205
</TableCell>
205206
{user.admin && (
206207
<TableCell align='right' component='th' scope='row'>
@@ -243,7 +244,7 @@ const RepoDetails: React.FC = () => {
243244
{data.users.canPush.map((row) => (
244245
<TableRow key={row}>
245246
<TableCell align='left'>
246-
<a href={`/dashboard/user/${row}`}>{row}</a>
247+
<UserLink username={row} />
247248
</TableCell>
248249
{user.admin && (
249250
<TableCell align='right' component='th' scope='row'>

0 commit comments

Comments
 (0)