-
Notifications
You must be signed in to change notification settings - Fork 42
/
Packages.js
executable file
·72 lines (60 loc) · 1.54 KB
/
Packages.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
/* eslint-disable */
import React, { useEffect } from 'react';
import { merge } from 'ramda';
import { useMappedState, useDispatch } from 'redux-react-hook';
import { SET_PACKAGES } from '../../constants/ActionTypes';
import useIpc from '../../commons/hooks/useIpc';
import styles from '../../styles/spectre.min.css';
const {
panel,
'panel-header': panelHeader,
'panel-body': panelBody,
'panel-nav': panelNav
} = styles;
const options = {
ipcEvent: 'get-packages',
cmd: ['list'],
activeManager: 'yarn'
};
const mapState = state => ({
mode: state.common.mode,
directory: state.common.directory,
packages: state.packages.packages
});
const Packages = props => {
const { packages, mode, directory } = useMappedState(mapState);
const dispatch = useDispatch();
const [newPackages, error] = useIpc(
'ipc-event',
merge(options, {
mode,
directory
})
);
if (error) {
console.error(error);
}
useEffect(
() => {
if (typeof newPackages === 'string' && !Boolean(newPackages.length)) {
return;
}
dispatch({ type: SET_PACKAGES, packages: newPackages });
},
[newPackages]
);
console.log(packages);
return (
<div className={panel} style={{ border: 'none' }}>
<div className={panelHeader} />
<div className={panelNav} />
<div className={panelBody}>
{/* {packages &&
packages.map((pkg, idx) => (
<Package key={`pkg-${idx}-key`} styles={styles} {...pkg} />
))} */}
</div>
</div>
);
};
export default Packages;