diff --git a/ui/cypress/support.js b/ui/cypress/support.js
index 81fa688aa..01de273d4 100644
--- a/ui/cypress/support.js
+++ b/ui/cypress/support.js
@@ -20,7 +20,7 @@ Cypress.Commands.add('takeControl', (returnPage = '/datacollection') => {
// control only needs to be taken, when observer mode is present
cy.get('body').then(($body) => {
if ($body.text().includes('Observer mode')) {
- cy.findByRole('button', { name: 'OK' }).click();
+ cy.findByRole('button', { name: 'Continue' }).click();
cy.findByRole('link', { name: /Remote/u, hidden: true }).click();
cy.findByRole('button', { name: 'Take control' }).click();
cy.visit(returnPage);
diff --git a/ui/src/actions/remoteAccess.js b/ui/src/actions/remoteAccess.js
index 8b38849fc..694aa5004 100644
--- a/ui/src/actions/remoteAccess.js
+++ b/ui/src/actions/remoteAccess.js
@@ -15,10 +15,6 @@ import { showErrorPanel } from './general';
import { getLoginInfo } from './login';
import { showWaitDialog } from './waitDialog';
-export function showObserverDialog(show = true) {
- return { type: 'SHOW_OBSERVER_DIALOG', show };
-}
-
export function getRaState() {
return async (dispatch) => {
const data = await fetchRemoteAccessState();
diff --git a/ui/src/components/RemoteAccess/ObserverDialog.jsx b/ui/src/components/RemoteAccess/ObserverDialog.jsx
index 8ced49a08..218084fe6 100644
--- a/ui/src/components/RemoteAccess/ObserverDialog.jsx
+++ b/ui/src/components/RemoteAccess/ObserverDialog.jsx
@@ -1,113 +1,63 @@
-/* eslint-disable react/jsx-handler-names */
-import React from 'react';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux';
-import { Modal, Button, Form, Row, Col } from 'react-bootstrap';
-import { showObserverDialog, updateNickname } from '../../actions/remoteAccess';
-
-export class ObserverDialog extends React.Component {
- constructor(props) {
- super(props);
- this.accept = this.accept.bind(this);
- this.reject = this.reject.bind(this);
- this.show = this.show.bind(this);
- }
-
- componentDidUpdate() {
- if (this.name && this.name.value === '') {
- try {
- this.name.value = this.props.login.user.nickname;
- } catch {
- this.name.value = '';
- }
- }
- }
-
- show() {
- return (
- !this.props.login.user.inControl && this.props.login.user.nickname === ''
- );
+import React, { useEffect } from 'react';
+import { useDispatch, useSelector } from 'react-redux';
+import { Modal, Button, Form } from 'react-bootstrap';
+import { updateNickname } from '../../actions/remoteAccess';
+import { useForm } from 'react-hook-form';
+
+function ObserverDialog() {
+ const dispatch = useDispatch();
+
+ const { loginType, loginID, user } = useSelector((state) => state.login);
+ const isUserLogin = loginType === 'User';
+ const showDialog = !user.inControl && !user.nickname;
+
+ const {
+ register,
+ handleSubmit: makeOnSubmit,
+ setFocus,
+ } = useForm({
+ defaultValues: { name: loginID },
+ });
+
+ function handleSubmit(data) {
+ dispatch(updateNickname(data.name || user.username));
}
- accept(evt) {
- evt.preventDefault();
-
- const name = this.name ? this.name.value : this.props.login.loginID;
-
- if (name) {
- this.props.updateNickname(name);
- } else {
- this.props.updateNickname(this.props.login.user.username);
+ useEffect(() => {
+ if (showDialog) {
+ setFocus('name');
}
-
- this.props.hide();
- }
-
- reject() {
- this.props.hide();
- }
-
- title() {
- return 'Observer mode';
- }
-
- render() {
- return (
-