summaryrefslogtreecommitdiff
path: root/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js
blob: e8722506d08b1373285e68acc75de9c2dde466aa (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(this.unitSelect.value)
                        }
                    >
                        <span className="fa fa-plus mr-2"/>
                        Add
                    </button>
                </div>
            </div>
        )
    }
}

export default UnitAddComponent