summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/room/RackConstructionComponent.js
blob: 0a27910c0de14ed440dba6819f36b16a882a7d2b (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
import PropTypes from 'prop-types'
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faTimes, faPlus } from '@fortawesome/free-solid-svg-icons'
import { Button } from 'reactstrap'

const RackConstructionComponent = ({ onStart, onStop, inRackConstructionMode, isEditingRoom }) => {
    if (inRackConstructionMode) {
        return (
            <Button color="primary" block onClick={onStop}>
                <FontAwesomeIcon icon={faTimes} className="mr-2" />
                Stop rack construction
            </Button>
        )
    }

    return (
        <Button
            color="primary"
            outline
            block
            disabled={isEditingRoom}
            onClick={() => (isEditingRoom ? undefined : onStart())}
        >
            <FontAwesomeIcon icon={faPlus} className="mr-2" />
            Start rack construction
        </Button>
    )
}

RackConstructionComponent.propTypes = {
    onStart: PropTypes.func,
    onStop: PropTypes.func,
    inRackConstructionMode: PropTypes.bool,
    isEditingRoom: PropTypes.bool,
}

export default RackConstructionComponent