Skip to content

Commit fd962d2

Browse files
committed
feat: add snackbar for repo fetching errors
1 parent e96e876 commit fd962d2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/ui/components/PrivateRoute/PrivateRoute.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useAuth } from '../../auth/AuthProvider';
44

55
const PrivateRoute = ({ component: Component, adminOnly = false }) => {
66
const { user, isLoading } = useAuth();
7-
console.debug('PrivateRoute', { user, isLoading, adminOnly });
87

98
if (isLoading) {
109
return <CircularProgress />;
@@ -15,7 +14,6 @@ const PrivateRoute = ({ component: Component, adminOnly = false }) => {
1514
}
1615

1716
if (adminOnly && !user.admin) {
18-
console.debug('User is not an admin, redirecting to not authorized page');
1917
return <Navigate to="/not-authorized" />;
2018
}
2119

src/ui/views/RepoList/Components/RepoOverview.jsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useEffect } from 'react';
2-
import TableCell from '@material-ui/core/TableCell';
3-
import TableRow from '@material-ui/core/TableRow';
2+
import { Snackbar, TableCell, TableRow } from '@material-ui/core';
43
import GridContainer from '../../../components/Grid/GridContainer';
54
import GridItem from '../../../components/Grid/GridItem';
65
import { CodeReviewIcon, LawIcon, PeopleIcon } from '@primer/octicons-react';
@@ -572,6 +571,9 @@ import CodeActionButton from '../../../components/CustomButtons/CodeActionButton
572571
export default function Repositories(props) {
573572
const [github, setGitHub] = React.useState({});
574573

574+
const [errorMessage, setErrorMessage] = React.useState('');
575+
const [snackbarOpen, setSnackbarOpen] = React.useState(false);
576+
575577
useEffect(() => {
576578
getGitHubRepository();
577579
}, [props.data.project, props.data.name]);
@@ -582,8 +584,9 @@ export default function Repositories(props) {
582584
.then((res) => {
583585
setGitHub(res.data);
584586
})
585-
.catch((err) => {
586-
console.error(`Error fetching GitHub repository ${props.data.project}/${props.data.name}: ${err}`);
587+
.catch((error) => {
588+
setErrorMessage(`Error fetching GitHub repository ${props.data.project}/${props.data.name}: ${error}`);
589+
setSnackbarOpen(true);
587590
});
588591
};
589592

@@ -672,6 +675,13 @@ export default function Repositories(props) {
672675
<CodeActionButton cloneURL={cloneURL} />
673676
</div>
674677
</TableCell>
678+
<Snackbar
679+
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
680+
open={snackbarOpen}
681+
autoHideDuration={6000}
682+
onClose={() => setSnackbarOpen(false)}
683+
message={errorMessage}
684+
/>
675685
</TableRow>
676686
);
677687
}

0 commit comments

Comments
 (0)