From 2e41d9f4601a54f549cd7fe1064172e513be8a77 Mon Sep 17 00:00:00 2001 From: jharris4 Date: Sun, 6 May 2018 10:40:44 -0400 Subject: [PATCH 1/2] fix: disable autocomplete on search so it doesn't default to username --- src/webui/src/components/Search/index.js | 20 +++++++++++++------ .../__snapshots__/search.spec.js.snap | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/webui/src/components/Search/index.js b/src/webui/src/components/Search/index.js index 709f5d106..7d78af044 100644 --- a/src/webui/src/components/Search/index.js +++ b/src/webui/src/components/Search/index.js @@ -4,14 +4,22 @@ import PropTypes from 'prop-types'; import classes from './search.scss'; +const noSubmit = (e) => { + e.preventDefault(); +}; + const Search = (props) => { return ( - +
+ +
); }; diff --git a/test/webui/components/__snapshots__/search.spec.js.snap b/test/webui/components/__snapshots__/search.spec.js.snap index db744e042..bfa984b61 100644 --- a/test/webui/components/__snapshots__/search.spec.js.snap +++ b/test/webui/components/__snapshots__/search.spec.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` component should match the snapshot 1`] = `""`; +exports[` component should match the snapshot 1`] = `"
"`; From f89b4985ab7da0c1a6bdefb7e2d080390d48ae42 Mon Sep 17 00:00:00 2001 From: jharris4 Date: Sun, 6 May 2018 11:50:17 -0400 Subject: [PATCH 2/2] fix: make enter key submit the login modal form --- src/webui/src/components/Header/index.js | 48 ++++++++++--------- .../__snapshots__/header.spec.js.snap | 2 +- test/webui/components/header.spec.js | 2 +- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/webui/src/components/Header/index.js b/src/webui/src/components/Header/index.js index b149887f7..573c29290 100644 --- a/src/webui/src/components/Header/index.js +++ b/src/webui/src/components/Header/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import {Button, Dialog, Input, Alert} from 'element-react'; +import {Form, Button, Dialog, Input, Alert} from 'element-react'; import isString from 'lodash/isString'; import isNumber from 'lodash/isNumber'; import {Link} from 'react-router-dom'; @@ -50,7 +50,9 @@ export default class Header extends React.Component { }); } - async handleSubmit() { + async handleSubmit(event) { + event.preventDefault(); + if (this.state.username === '' || this.state.password === '') { return this.setState({loginError: { title: 'Unable to login', @@ -161,26 +163,28 @@ export default class Header extends React.Component { visible={ this.state.showLogin } onCancel={ () => this.toggleLoginModal() } > - - { this.state.loginError && - - - } -
- -

- -
- - - - +
+ + { this.state.loginError && + + + } +
+ +

+ +
+ + + + +
); diff --git a/test/webui/components/__snapshots__/header.spec.js.snap b/test/webui/components/__snapshots__/header.spec.js.snap index 3b7b8105f..d7bff72e9 100644 --- a/test/webui/components/__snapshots__/header.spec.js.snap +++ b/test/webui/components/__snapshots__/header.spec.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`
snapshot test shoud match snapshot 1`] = `"
npm set registry nullblank
npm adduser --registry nullblank
Login



"`; +exports[`
snapshot test shoud match snapshot 1`] = `"
npm set registry nullblank
npm adduser --registry nullblank
Login



"`; diff --git a/test/webui/components/header.spec.js b/test/webui/components/header.spec.js index e567375cf..ee0f64ff5 100644 --- a/test/webui/components/header.spec.js +++ b/test/webui/components/header.spec.js @@ -61,7 +61,7 @@ describe('
component shallow', () => { title: 'Unable to login', type: 'error' }; - expect(handleSubmit()).toBeDefined(); + expect(handleSubmit({ preventDefault: () => {} })).toBeDefined(); expect(HeaderWrapper.state('loginError')).toEqual(error); });