blob: 9128f449a128cdde856f323e91670ee757ebf80d (
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
|
import React from 'react'
import { connect } from 'react-redux'
import { closeEditRackNameModal } from '../../actions/modals/topology'
import { editRackName } from '../../actions/topology/rack'
import TextInputModal from '../../components/modals/TextInputModal'
const EditRackNameModalComponent = ({ visible, previousName, callback }) => (
<TextInputModal
title="Edit rack name"
label="Rack name"
show={visible}
initialValue={previousName}
callback={callback}
/>
)
const mapStateToProps = (state) => {
return {
visible: state.modals.editRackNameModalVisible,
previousName:
state.interactionLevel.mode === 'RACK'
? state.objects.rack[state.objects.tile[state.interactionLevel.tileId].rackId].name
: '',
}
}
const mapDispatchToProps = (dispatch) => {
return {
callback: (name) => {
if (name) {
dispatch(editRackName(name))
}
dispatch(closeEditRackNameModal())
},
}
}
const EditRackNameModal = connect(mapStateToProps, mapDispatchToProps)(EditRackNameModalComponent)
export default EditRackNameModal
|