-
Notifications
You must be signed in to change notification settings - Fork 42
/
Dashboard.js
executable file
·115 lines (105 loc) · 2.45 KB
/
Dashboard.js
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
import React from 'react';
import PropTypes from 'prop-types';
import { useMappedState } from 'redux-react-hook';
import { withStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid';
import { APP_MODES, APP_INFO } from 'constants/AppConstants';
import { BasicCard, DetailsCard } from 'components/common/Cards';
import styles from './styles';
const mapState = ({
common: {
manager,
mode,
directory,
loader: { loading }
},
packages: {
lastUpdatedAt,
packages,
packagesOutdated,
projectName,
projectVersion,
projectDescription,
projectLicense,
projectAuthor
}
}) => ({
manager,
mode,
directory,
loading,
lastUpdatedAt,
packages,
packagesOutdated,
projectName,
projectVersion,
projectDescription,
projectLicense,
projectAuthor
});
const Dashboard = props => {
const { classes } = props;
const {
packages,
packagesOutdated,
loading,
directory,
mode,
projectName,
projectVersion,
projectDescription,
projectLicense,
lastUpdatedAt
} = useMappedState(mapState);
const title =
mode === APP_MODES.LOCAL ? `Project ${projectName || ''}` : 'Global';
const text =
mode === APP_MODES.LOCAL ? projectDescription : APP_INFO.GLOBAL_MESSAGE;
return (
<section className={classes.root}>
<Grid container justify="space-between">
<Grid item xs={12} sm={12} md={3} lg={3} xl={3}>
<DetailsCard
mode={mode}
directory={directory}
title={title}
aside={projectVersion}
text={text}
smallText={projectLicense}
lastUpdatedAt={lastUpdatedAt || ''}
loading={loading}
/>
</Grid>
<Grid
item
xs={12}
sm={12}
md={3}
lg={3}
xl={3}
className={classes.cardInfo}
>
<BasicCard title="Dependencies" value={packages && packages.length} />
</Grid>
<Grid
item
xs={12}
sm={12}
md={3}
lg={4}
xl={4}
className={classes.cardInfo}
>
<BasicCard
title="Outdated"
value={packagesOutdated && packagesOutdated.length}
/>
</Grid>
</Grid>
</section>
);
};
Dashboard.propTypes = {
classes: PropTypes.objectOf(PropTypes.string).isRequired
};
export default withStyles(styles)(Dashboard);