Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: style security related input fields properly, enable enter #1568

Merged
merged 1 commit into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/server-admin-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signalk/server-admin-ui",
"version": "2.0.1",
"version": "2.0.2",
"description": "Signal K server admin webapp",
"author": "Scott Bender, Teppo Kurki",
"contributors": [
Expand Down
28 changes: 20 additions & 8 deletions packages/server-admin-ui/src/views/security/EnableSecurity.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
Input,
InputGroup,
InputGroupAddon,
HelpBlock,
InputGroupText,
} from 'reactstrap'
import { connect } from 'react-redux'
import { login, enableSecurity, fetchLoginStatus } from '../../actions'
import { enableSecurity, fetchLoginStatus } from '../../actions'
import Login from './Login'

class EnableSecurity extends Component {
Expand All @@ -25,6 +25,7 @@ class EnableSecurity extends Component {
errorMessage: null,
}
this.handleInputChange = this.handleInputChange.bind(this)
this.handleInputKeyUp = this.handleInputKeyUp.bind(this)
this.handleClick = this.handleClick.bind(this)
}

Expand All @@ -48,6 +49,11 @@ class EnableSecurity extends Component {
handleInputChange(event) {
this.setState({ [event.target.name]: event.target.value })
}
handleInputKeyUp(event) {
if (event.key === 'Enter') {
this.handleClick()
}
}

render() {
return (
Expand All @@ -70,29 +76,35 @@ class EnableSecurity extends Component {
</p>
)}
{!this.props.loginStatus.securityWasEnabled && (
<div>
<Form>
<h1>Enable Security</h1>
<p className="text-muted">Create an admin account</p>
<InputGroup className="mb-3">
<InputGroupAddon>
<i className="icon-user" />
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="icon-user" />
</InputGroupText>
</InputGroupAddon>
<Input
type="text"
name="username"
placeholder="Username"
onChange={this.handleInputChange}
onKeyUp={this.handleInputKeyUp}
/>
</InputGroup>
<InputGroup className="mb-4">
<InputGroupAddon>
<i className="icon-lock" />
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="icon-lock" />
</InputGroupText>
</InputGroupAddon>
<Input
type="password"
name="password"
placeholder="Password"
onChange={this.handleInputChange}
onKeyUp={this.handleInputKeyUp}
/>
</InputGroup>
<Row>
Expand All @@ -118,7 +130,7 @@ class EnableSecurity extends Component {
</p>
</Col>
</Row>
</div>
</Form>
)}
</CardBody>
</Card>
Expand Down
33 changes: 24 additions & 9 deletions packages/server-admin-ui/src/views/security/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {
Input,
InputGroup,
InputGroupAddon,
HelpBlock,
InputGroupText,
Label,
} from 'reactstrap'
import { Link } from 'react-router-dom'
import { connect } from 'react-redux'
import { login, fetchAllData } from '../../actions'
import { login } from '../../actions'
import Dashboard from '../Dashboard/Dashboard'
import EnableSecurity from './EnableSecurity'

Expand All @@ -28,6 +28,7 @@ class Login extends Component {
loginErrorMessage: null,
}
this.handleInputChange = this.handleInputChange.bind(this)
this.handleInputKeyUp = this.handleInputKeyUp.bind(this)
this.handleClick = this.handleClick.bind(this)
}

Expand Down Expand Up @@ -56,6 +57,12 @@ class Login extends Component {
this.setState({ [event.target.name]: value })
}

handleInputKeyUp(event) {
if (event.key === 'Enter') {
this.handleClick()
}
}

render() {
if (
this.props.loginStatus.status === 'notLoggedIn' &&
Expand All @@ -75,25 +82,31 @@ class Login extends Component {
<h1>Login</h1>
<p className="text-muted">Sign In to your account</p>
<InputGroup className="mb-3">
<InputGroupAddon>
<i className="icon-user" />
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="icon-user" />
</InputGroupText>
</InputGroupAddon>
<Input
type="text"
name="username"
placeholder="Username"
onChange={this.handleInputChange}
onKeyUp={this.handleInputKeyUp}
/>
</InputGroup>
<InputGroup className="mb-4">
<InputGroupAddon>
<i className="icon-lock" />
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="icon-lock" />
</InputGroupText>
</InputGroupAddon>
<Input
type="password"
name="password"
placeholder="Password"
onChange={this.handleInputChange}
onKeyUp={this.handleInputKeyUp}
/>
</InputGroup>
<Row>
Expand Down Expand Up @@ -135,9 +148,11 @@ class Login extends Component {
</Button>
</Col>
<Col xs="6" className="text-right">
<p className="text-danger">
{this.state.loginErrorMessage}
</p>
{this.state.loginErrorMessage && (
<p className="text-danger">
{this.state.loginErrorMessage}
</p>
)}
{!this.state.loginErrorMessage &&
this.props.loginStatus
.allowNewUserRegistration && (
Expand Down
31 changes: 21 additions & 10 deletions packages/server-admin-ui/src/views/security/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import {
CardBody,
CardFooter,
Button,
Form,
Input,
InputGroup,
InputGroupAddon,
FormText,
InputGroupText,
} from 'reactstrap'

class Register extends Component {
Expand Down Expand Up @@ -94,10 +95,12 @@ class Register extends Component {
</p>
)}
{!this.state.registrationSent && (
<div>
<Form>
<p className="text-muted">Create your account</p>
<InputGroup className="mb-3">
<InputGroupAddon>@</InputGroupAddon>
<InputGroupAddon addonType="prepend">
<InputGroupText>@</InputGroupText>
</InputGroupAddon>
<Input
name="email"
type="text"
Expand All @@ -106,8 +109,10 @@ class Register extends Component {
/>
</InputGroup>
<InputGroup className="mb-3">
<InputGroupAddon>
<i className="icon-lock"></i>
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="icon-lock" />
</InputGroupText>
</InputGroupAddon>
<Input
name="password"
Expand All @@ -116,9 +121,11 @@ class Register extends Component {
onChange={this.handleInputChange}
/>
</InputGroup>
<InputGroup className="mb-4">
<InputGroupAddon>
<i className="icon-lock"></i>
<InputGroup className="mb-0">
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="icon-lock" />
</InputGroupText>
</InputGroupAddon>
<Input
name="confirmPassword"
Expand All @@ -127,8 +134,12 @@ class Register extends Component {
onChange={this.handleInputChange}
/>
</InputGroup>
<p className="text-danger">{this.state.errorMessage}</p>
</div>
{this.state.errorMessage && (
<p className="text-danger mt-3 mb-0">
{this.state.errorMessage}
</p>
)}
</Form>
)}
</CardBody>
{!this.state.registrationSent && (
Expand Down
Loading