blob: e5c87e351709e1c2cd80cd58b1d49abf8e555c96 (
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
|
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].objectId
].name
: '',
}
}
const mapDispatchToProps = dispatch => {
return {
callback: name => {
if (name) {
dispatch(editRackName(name))
}
dispatch(closeEditRackNameModal())
},
}
}
const EditRackNameModal = connect(mapStateToProps, mapDispatchToProps)(
EditRackNameModalComponent,
)
export default EditRackNameModal
|