summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/RoomNameContainer.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-13 17:42:53 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-17 17:06:50 +0200
commit1edbae1a0224e30bafb98638f419e1f967a9286f (patch)
tree2047c5a684379dfd395891e9447199f6001cef9b /opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/RoomNameContainer.js
parent1891a6f3963d3ddeae0ea093f9a7e3608a97b4d7 (diff)
ui: Move modal state outside of Redux
This change updates the frontend so that the modal state is not stored inside Redux but instead is stored using the useState hook. This simplifies the design of the modal components.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/RoomNameContainer.js')
-rw-r--r--opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/RoomNameContainer.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/RoomNameContainer.js b/opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/RoomNameContainer.js
index 1f53aeb6..946bb864 100644
--- a/opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/RoomNameContainer.js
+++ b/opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/RoomNameContainer.js
@@ -1,13 +1,31 @@
-import React from 'react'
+import React, { useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
-import { openEditRoomNameModal } from '../../../../../actions/modals/topology'
-import RoomNameComponent from '../../../../../components/app/sidebars/topology/room/RoomNameComponent'
+import NameComponent from '../../../../../components/app/sidebars/topology/NameComponent'
+import TextInputModal from '../../../../../components/modals/TextInputModal'
+import { editRoomName } from '../../../../../actions/topology/room'
-const RoomNameContainer = (props) => {
+const RoomNameContainer = () => {
+ const [isVisible, setVisible] = useState(false)
const roomName = useSelector((state) => state.objects.room[state.interactionLevel.roomId].name)
const dispatch = useDispatch()
- const onEdit = () => dispatch(openEditRoomNameModal())
- return <RoomNameComponent {...props} onEdit={onEdit} roomName={roomName} />
+ const callback = (name) => {
+ if (name) {
+ dispatch(editRoomName(name))
+ }
+ setVisible(false)
+ }
+ return (
+ <>
+ <NameComponent name={roomName} onEdit={() => setVisible(true)} />
+ <TextInputModal
+ title="Edit room name"
+ label="Room name"
+ show={isVisible}
+ initialValue={roomName}
+ callback={callback}
+ />
+ </>
+ )
}
export default RoomNameContainer