-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRepositoryDetails.js
More file actions
110 lines (90 loc) · 3.2 KB
/
RepositoryDetails.js
File metadata and controls
110 lines (90 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import React from "react";
import styled from "styled-components";
import Helmet from 'react-helmet';
import MuiPaper from "@material-ui/core/Paper";
import {
Breadcrumbs as MuiBreadcrumbs,
Divider as MuiDivider,
Grid,
Link,
Table,
TableBody,
TableCell,
TableRow,
Typography
} from "@material-ui/core";
import {spacing} from "@material-ui/system";
import {Link as RouterLink, useParams} from "react-router-dom";
import SupersetChart from "../components/superset/SupersetChart";
import {person_languages_url} from "../../utils/superset";
import {useOne} from "../../context/OneContext";
import {useProjectsRepositoriesRead} from "../../api-client/one-api";
const Paper = styled(MuiPaper)(spacing);
const TableCellLabel = styled(TableCell)`
width: 200px;
text-align: right;
`;
const Divider = styled(MuiDivider)(spacing);
const Breadcrumbs = styled(MuiBreadcrumbs)(spacing);
const RepositoryInfo = ({repository}) => {
return (
<Table>
<TableBody>
<TableRow>
<TableCellLabel variant="head">
Name
</TableCellLabel>
<TableCell>
{repository.name}
</TableCell>
</TableRow>
</TableBody>
</Table>
)
}
const RepositoryDetails = () => {
const {selectedProject} = useOne();
let {id: repositoryId} = useParams();
const {data: repository, refetch: reloadRepository} = useProjectsRepositoriesRead({
project_pk: selectedProject ? selectedProject.id : undefined,
repository_pk: repositoryId,
lazy: !Boolean(selectedProject)
});
const chartUrl = repository ?
person_languages_url('repository', repository.name)
:
undefined
return (
<React.Fragment>
<Helmet title={`Repository: ${repository && repository.name}`}/>
<Typography variant="h3" gutterBottom display="inline">
Repository: {repository && repository.name}
</Typography>
<Breadcrumbs aria-label="Breadcrumb" mt={2}>
<Link component={RouterLink} to="/repositories">
Repositories
</Link>
<Typography>{repository && repository.name}</Typography>
</Breadcrumbs>
<Divider my={6}/>
<Grid container spacing={6}>
<Grid item xs={12} xl={6}>
<Paper p={6} mb={6}>
<Typography variant="h4">Repository info</Typography>
{repository && (
<RepositoryInfo project={selectedProject} repository={repository}
onRepositoryUpdate={reloadRepository}/>
)}
</Paper>
</Grid>
<Grid item xs={12} xl={6}>
<Paper p={6} mb={6}>
<Typography variant="h4">Languages</Typography>
<SupersetChart chartUrl={chartUrl}/>
</Paper>
</Grid>
</Grid>
</React.Fragment>
);
}
export default RepositoryDetails;