-
Notifications
You must be signed in to change notification settings - Fork 36
/
stats-components-widget.tsx
130 lines (125 loc) Β· 4.64 KB
/
stats-components-widget.tsx
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { VersionInfo } from '@sensenet/hooks-react'
import {
createStyles,
Link,
makeStyles,
Paper,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Tooltip,
} from '@material-ui/core'
import { green, grey, red } from '@material-ui/core/colors'
import { Close, Done, HelpOutline, Info } from '@material-ui/icons'
import clsx from 'clsx'
import React from 'react'
import { useGlobalStyles, useWidgetStyles } from '../../globalStyles'
import { useLocalization } from '../../hooks'
import { useDateUtils } from '../../hooks/use-date-utils'
const useStyles = makeStyles(() => {
return createStyles({
rowContainer: {
padding: '10px 0',
fontSize: '16px',
},
icon: {
marginLeft: '12px',
},
paragraph: {
marginBottom: '10px',
},
link: {
textDecoration: 'underline',
marginLeft: '16px',
},
info: {
height: '16px',
width: '16px',
marginLeft: '6px',
cursor: 'pointer',
},
})
})
export interface ComponentsWidgetProps {
data: VersionInfo
}
export const ComponentsWidget: React.FunctionComponent<ComponentsWidgetProps> = (props) => {
const classes = useStyles()
const globalClasses = useGlobalStyles()
const widgetClasses = useWidgetStyles()
const localization = useLocalization().settings
const dateUtils = useDateUtils()
const latestBackendRelease = props.data.LatestReleases.find((item) => item.ProductName === 'SenseNet.Services')
const latestFrontendRelease = props.data.LatestReleases.find((item) => item.ProductName === 'SenseNet.AdminUI')
return (
<div className={widgetClasses.root}>
<Paper elevation={0} className={widgetClasses.container}>
<div className={clsx(globalClasses.centeredVertical, classes.rowContainer)}>
{localization.components}
<Tooltip title={localization.componentsInfo} placement="top">
<Info className={classes.info} />
</Tooltip>
</div>
<div className={classes.paragraph}>
{localization.latestBackendRelease}{' '}
{latestBackendRelease?.ReleaseDate
? dateUtils.formatDate(latestBackendRelease!.ReleaseDate, 'yyyy.MM.dd HH:mm aaa')
: localization.notAvailable}
<Link className={classes.link} href="https://www.sensenet.com/backend-updates" target="_blank" rel="noopener">
{localization.goToChangeLog}
</Link>
</div>
<div className={classes.paragraph}>
{localization.latestFrontendRelease}{' '}
{latestFrontendRelease?.ReleaseDate
? dateUtils.formatDate(latestFrontendRelease!.ReleaseDate, 'yyyy.MM.dd HH:mm aaa')
: localization.notAvailable}
<Link
className={classes.link}
href="https://www.sensenet.com/frontend-updates"
target="_blank"
rel="noopener">
{localization.goToChangeLog}
</Link>
</div>
<TableContainer>
<Table size="small" aria-label="stats-components">
<TableHead>
<TableRow>
<TableCell align="left">{localization.componentId}</TableCell>
<TableCell align="left">{localization.version}</TableCell>
<TableCell align="left">{localization.latestOfficialVersion}</TableCell>
<TableCell align="left">{localization.latest}</TableCell>
<TableCell align="left">{localization.description}</TableCell>
</TableRow>
</TableHead>
<TableBody>
{props.data.Components.map((row) => (
<TableRow key={row.ComponentId}>
<TableCell align="left">{row.ComponentId}</TableCell>
<TableCell align="center">{row.Version}</TableCell>
<TableCell align="center">{row.LatestVersion || localization.notAvailable}</TableCell>
<TableCell align="center" className={globalClasses.centeredVertical}>
{row.LatestVersion !== null ? (
row.LatestVersion === row.Version ? (
<Done className={classes.icon} style={{ color: green[500] }} />
) : (
<Close className={classes.icon} style={{ color: red[500] }} />
)
) : (
<HelpOutline className={classes.icon} style={{ color: grey[500] }} />
)}
</TableCell>
<TableCell align="left">{row.Description}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
</Paper>
</div>
)
}