This repository was archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathBoardConfig.tsx
73 lines (65 loc) · 2.54 KB
/
BoardConfig.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as React from "react";
import { Grid, Row } from "react-bootstrap";
import { connect } from "react-redux";
import * as actions from "../actions";
import * as API from "../actions/api";
import BoardConfigItemView from "./BoardConfigItemView";
import BoardSelector from "./BoardSelector";
interface IBoardConfigProps extends React.Props<any> {
configitems: any;
installedBoards: any;
loadConfigItems: () => void;
loadInstalledBoards(): () => void;
}
const mapStateToProps = (state) => {
return {
installedBoards: state.boardConfigStore.installedBoards,
configitems: state.boardConfigStore.configitems,
};
};
const mapDispatchToProps = (dispatch) => {
return {
loadInstalledBoards: () => actions.getInstalledBoards(dispatch),
loadConfigItems: () => actions.getConfigItems(dispatch),
};
};
class BoardConfig extends React.Component<IBoardConfigProps, React.Props<any>> {
constructor(props) {
super(props);
this.state = {};
}
public componentWillMount() {
this.props.loadInstalledBoards();
this.props.loadConfigItems();
}
public render() {
let installWarning;
if (this.props.installedBoards.length === 0) {
installWarning = (<div className="theme-bgcolor arduinomanager-toolbar">
No boards are installed. <a className="help-link"
onClick={() => API.runCommand("arduino.showBoardManager")}>Install a board with the Boards Manager.</a>
</div>);
}
return (
<div>
{installWarning}
<div className="boardConfig">
<Grid fluid>
<Row key="board-selector">
<BoardSelector installedBoards={this.props.installedBoards} loadConfigItems={this.props.loadConfigItems} />
</Row>
{
this.props.configitems.map((configitem, index) => {
return (<Row key={configitem.id}>
<BoardConfigItemView configitem={configitem} />
</Row>);
})
}
</Grid>
</div>
</div>);
}
}
export default connect(mapStateToProps, mapDispatchToProps)(BoardConfig);