summaryrefslogtreecommitdiff
path: root/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js
blob: 0c903228ac441fd6deb95a29fc45877b268c7786 (plain)
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
import PropTypes from "prop-types";
import React from "react";

class UnitAddComponent extends React.Component {
  static propTypes = {
    units: PropTypes.array.isRequired,
    onAdd: PropTypes.func.isRequired
  };

  render() {
    return (
      <div className="form-inline">
        <div className="form-group w-100">
          <select
            className="form-control w-75 mr-1"
            ref={unitSelect => (this.unitSelect = unitSelect)}
          >
            {this.props.units.map(unit => (
              <option value={unit.id} key={unit.id}>
                {unit.manufacturer +
                  " " +
                  unit.family +
                  " " +
                  unit.model +
                  " " +
                  unit.generation}
              </option>
            ))}
          </select>
          <button
            type="submit"
            className="btn btn-outline-primary"
            onClick={() =>
              this.props.onAdd(parseInt(this.unitSelect.value, 10))
            }
          >
            <span className="fa fa-plus mr-2" />
            Add
          </button>
        </div>
      </div>
    );
  }
}

export default UnitAddComponent;