|
1 | | -import React, { useEffect } from 'react'; |
2 | | -import { Snackbar, TableCell, TableRow } from '@material-ui/core'; |
3 | | -import GridContainer from '../../../components/Grid/GridContainer'; |
4 | | -import GridItem from '../../../components/Grid/GridItem'; |
5 | | -import { CodeReviewIcon, LawIcon, PeopleIcon } from '@primer/octicons-react'; |
| 1 | +// src/constants/languageColors.ts |
6 | 2 |
|
7 | | -const colors = { |
| 3 | +export const languageColors: Record<string, string> = { |
8 | 4 | '1C Enterprise': '#814CCC', |
9 | 5 | '2-Dimensional Array': '#38761D', |
10 | 6 | '4D': '#004289', |
@@ -563,125 +559,3 @@ const colors = { |
563 | 559 | ZIL: '#dc75e5', |
564 | 560 | Zimpl: '#d67711', |
565 | 561 | }; |
566 | | - |
567 | | -import axios from 'axios'; |
568 | | -import moment from 'moment'; |
569 | | -import CodeActionButton from '../../../components/CustomButtons/CodeActionButton'; |
570 | | - |
571 | | -export default function Repositories(props) { |
572 | | - const [github, setGitHub] = React.useState({}); |
573 | | - |
574 | | - const [errorMessage, setErrorMessage] = React.useState(''); |
575 | | - const [snackbarOpen, setSnackbarOpen] = React.useState(false); |
576 | | - |
577 | | - useEffect(() => { |
578 | | - getGitHubRepository(); |
579 | | - }, [props.data.project, props.data.name]); |
580 | | - |
581 | | - const getGitHubRepository = async () => { |
582 | | - await axios |
583 | | - .get(`https://api.github.com/repos/${props.data.project}/${props.data.name}`) |
584 | | - .then((res) => { |
585 | | - setGitHub(res.data); |
586 | | - }) |
587 | | - .catch((error) => { |
588 | | - setErrorMessage(`Error fetching GitHub repository ${props.data.project}/${props.data.name}: ${error}`); |
589 | | - setSnackbarOpen(true); |
590 | | - }); |
591 | | - }; |
592 | | - |
593 | | - const { project: org, name, proxyURL } = props?.data || {}; |
594 | | - const cloneURL = `${proxyURL}/${org}/${name}.git`; |
595 | | - |
596 | | - return ( |
597 | | - <TableRow> |
598 | | - <TableCell> |
599 | | - <div style={{ padding: '15px' }}> |
600 | | - <a href={`/dashboard/repo/${props.data.name}`}> |
601 | | - <span style={{ fontSize: '17px' }}> |
602 | | - {props.data.project}/{props.data.name} |
603 | | - </span> |
604 | | - </a> |
605 | | - {github.parent && ( |
606 | | - <span |
607 | | - style={{ |
608 | | - fontSize: '11.5px', |
609 | | - display: 'block', |
610 | | - opacity: 0.8, |
611 | | - }} |
612 | | - > |
613 | | - Forked from{' '} |
614 | | - <a |
615 | | - style={{ |
616 | | - fontWeight: 'normal', |
617 | | - color: 'inherit', |
618 | | - }} |
619 | | - href={github.parent.html_url} |
620 | | - > |
621 | | - {github.parent.full_name} |
622 | | - </a> |
623 | | - </span> |
624 | | - )} |
625 | | - {github.description && <p style={{ maxWidth: '80%' }}>{github.description}</p>} |
626 | | - <GridContainer> |
627 | | - {github.language && ( |
628 | | - <GridItem> |
629 | | - <span |
630 | | - style={{ |
631 | | - height: '12px', |
632 | | - width: '12px', |
633 | | - backgroundColor: `${colors[github.language]}`, |
634 | | - borderRadius: '50px', |
635 | | - display: 'inline-block', |
636 | | - marginRight: '5px', |
637 | | - }} |
638 | | - ></span> |
639 | | - {github.language} |
640 | | - </GridItem> |
641 | | - )} |
642 | | - {github.license && ( |
643 | | - <GridItem> |
644 | | - <LawIcon size='small' />{' '} |
645 | | - <span style={{ marginLeft: '5px' }}>{github.license.spdx_id}</span> |
646 | | - </GridItem> |
647 | | - )} |
648 | | - <GridItem> |
649 | | - <PeopleIcon size='small' />{' '} |
650 | | - <span style={{ marginLeft: '5px' }}>{props.data.users?.canPush?.length || 0}</span> |
651 | | - </GridItem> |
652 | | - <GridItem> |
653 | | - <CodeReviewIcon size='small' />{' '} |
654 | | - <span style={{ marginLeft: '5px' }}> |
655 | | - {props.data.users?.canAuthorise?.length || 0} |
656 | | - </span> |
657 | | - </GridItem> |
658 | | - {(github.created_at || github.updated_at || github.pushed_at) && ( |
659 | | - <GridItem> |
660 | | - Last updated{' '} |
661 | | - {moment |
662 | | - .max([ |
663 | | - moment(github.created_at), |
664 | | - moment(github.updated_at), |
665 | | - moment(github.pushed_at), |
666 | | - ]) |
667 | | - .fromNow()} |
668 | | - </GridItem> |
669 | | - )} |
670 | | - </GridContainer> |
671 | | - </div> |
672 | | - </TableCell> |
673 | | - <TableCell align='right'> |
674 | | - <div style={{ padding: '15px' }}> |
675 | | - <CodeActionButton cloneURL={cloneURL} /> |
676 | | - </div> |
677 | | - </TableCell> |
678 | | - <Snackbar |
679 | | - anchorOrigin={{ vertical: 'top', horizontal: 'center' }} |
680 | | - open={snackbarOpen} |
681 | | - autoHideDuration={6000} |
682 | | - onClose={() => setSnackbarOpen(false)} |
683 | | - message={errorMessage} |
684 | | - /> |
685 | | - </TableRow> |
686 | | - ); |
687 | | -} |
0 commit comments