diff --git a/src/js/components/login/AuthPage.jsx b/src/js/components/login/AuthPage.jsx index 637d308ba..3edc6d967 100644 --- a/src/js/components/login/AuthPage.jsx +++ b/src/js/components/login/AuthPage.jsx @@ -3,7 +3,6 @@ * Created by Kevin Li 10/24/16 */ -import React from 'react'; import AuthContainer from 'containers/login/AuthContainer'; import { kGlobalConstants } from '../../GlobalConstants'; import LoginWarningTxt from './LoginWarningTxt'; @@ -11,28 +10,28 @@ import LoginIntro from './LoginIntro'; import TestEnvironmentBanner from '../SharedComponents/banners/TestEnvironmentBanner'; -export default class AuthPage extends React.Component { - render() { - let testBanner = null; - if (!kGlobalConstants.PROD) { - testBanner = ; - } +const AuthPage = (props) => { + let testBanner = null; + if (!kGlobalConstants.PROD) { + testBanner = ; + } - return ( -
-
-
- {testBanner} -
-
- - -
+ return ( +
+
+
+ {testBanner} +
+
+ +
-
+
- ); - } -} +
+ ); +}; + +export default AuthPage; diff --git a/src/js/components/login/LoginBanner.jsx b/src/js/components/login/LoginBanner.jsx index 2113f207c..12f973408 100644 --- a/src/js/components/login/LoginBanner.jsx +++ b/src/js/components/login/LoginBanner.jsx @@ -3,19 +3,18 @@ * Created by Kyle Fox 2/19/16 */ -import React from 'react'; import LoginIntro from './LoginIntro'; import LoginContainer from '../../containers/login/LoginContainer'; -export default class LoginBanner extends React.Component { - render() { - return ( -
-
- - -
+const LoginBanner = (props) => { + return ( +
+
+ +
- ); - } -} +
+ ); +}; + +export default LoginBanner; diff --git a/src/js/components/login/LoginCaia.jsx b/src/js/components/login/LoginCaia.jsx index 9c2a10a32..16ac8dfbd 100644 --- a/src/js/components/login/LoginCaia.jsx +++ b/src/js/components/login/LoginCaia.jsx @@ -3,9 +3,8 @@ * Createdd by Kevin Li 10/13/16 */ -import React from 'react'; +import { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; -import _ from 'lodash'; import Cookies from 'js-cookie'; import { kGlobalConstants } from '../../GlobalConstants'; import { getRedirectPath } from '../../helpers/loginHelper'; @@ -14,52 +13,41 @@ const propTypes = { location: PropTypes.object }; -const defaultProps = { - location: null -}; +const LoginCaia = ({location = null}) => { + const [loginRedirect, setLoginRedirect] = useState(''); -export default class LoginCaia extends React.Component { - constructor(props) { - super(props); - this.state = { - redirect: '' - }; - this.handleClick = this.handleClick.bind(this); - } + useEffect(() => { + detectRedirection(); + }, []); - componentDidMount() { - this.detectRedirection(); - } + useEffect(() => { + detectRedirection(); + }, [location]); - componentDidUpdate(prevProps) { - if (!_.isEqual(prevProps.location, this.props.location)) { - this.detectRedirection(); + useEffect(() => { + if(loginRedirect === '') { + // remove the redirect destination cookie + Cookies.remove('brokerRedirect'); + } + else { + // save the redirect destination as a cookie, expire after 5 min (expressed in units of + // days per library documentation) + Cookies.set('brokerRedirect', loginRedirect, { expires: (5 / (24 * 60)) }); } - } + }, [loginRedirect]); - detectRedirection() { + const detectRedirection = () => { // check if the URL has a redirect param, save it in the state - const redirectPath = getRedirectPath(this.props.location); + const redirectPath = getRedirectPath(location); if (redirectPath) { - this.setState({ - redirect: redirectPath - }, () => { - // save the redirect destination as a cookie, expire after 5 min (expressed in units of - // days per library documentation) - Cookies.set('brokerRedirect', this.state.redirect, { expires: (5 / (24 * 60)) }); - }); + setLoginRedirect(redirectPath); } else { - this.setState({ - redirect: '' - }, () => { - // remove the redirect destination cookie - Cookies.remove('brokerRedirect'); - }); + setLoginRedirect(''); } - } + }; - handleClick(e) { + const handleClick = (e) => { if (e.keyCode === '13' || !e.keyCode) { const scope = "openid email profile address phone"; const url = `${kGlobalConstants.CAIA_ROOT}/as/authorization.oauth2?` @@ -69,28 +57,26 @@ export default class LoginCaia extends React.Component { + `&client_id=${encodeURIComponent(kGlobalConstants.CAIA_CLIENT)}`; window.location.assign(url); } - } + }; - render() { - return ( -
-
-

- Sign in or register for the Data Broker using your CAIA login. -

- -
+ return ( +
+
+

+ Sign in or register for the Data Broker using your CAIA login. +

+
- ); - } -} +
+ ); +}; LoginCaia.propTypes = propTypes; -LoginCaia.defaultProps = defaultProps; +export default LoginCaia; diff --git a/src/js/components/login/LoginCaiaErrorMessage.jsx b/src/js/components/login/LoginCaiaErrorMessage.jsx index 4c64785a3..dee8285c5 100644 --- a/src/js/components/login/LoginCaiaErrorMessage.jsx +++ b/src/js/components/login/LoginCaiaErrorMessage.jsx @@ -3,7 +3,6 @@ * Created by Nipun Monga 11/18/16 */ -import React from 'react'; import PropTypes from 'prop-types'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -11,18 +10,17 @@ const propTypes = { message: PropTypes.string.isRequired }; -export default class LoginCaiaErrorMessage extends React.Component { - render() { - return ( -
- -
Error
-

- {this.props.message} Please work with your agency to request Data Broker access through CAIA. -

-
- ); - } -} +const LoginCaiaErrorMessage = (props) => { + return ( +
+ +
Error
+

+ {props.message} Please work with your agency to request Data Broker access through CAIA. +

+
+ ); +}; LoginCaiaErrorMessage.propTypes = propTypes; +export default LoginCaiaErrorMessage; diff --git a/src/js/components/login/LoginCaiaLoading.jsx b/src/js/components/login/LoginCaiaLoading.jsx index c81bfb48b..065e6acd6 100644 --- a/src/js/components/login/LoginCaiaLoading.jsx +++ b/src/js/components/login/LoginCaiaLoading.jsx @@ -3,7 +3,6 @@ * Created by Kevin Li 10/14/16 */ -import React from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router'; @@ -14,46 +13,40 @@ const propTypes = { errorMessage: PropTypes.string }; -const defaultProps = { - errorMessage: '' -}; - -export default class LoginCaiaLoading extends React.Component { - render() { - let errorMessageComponent = null; - let hideLoading = ''; - let hideError = ' hide'; +const LoginCaiaLoading = ({errorMessage = ''}) => { + let errorMessageComponent = null; + let hideLoading = ''; + let hideError = ' hide'; - if (this.props.errorMessage) { - errorMessageComponent = ; - hideLoading = ' hide'; - hideError = ''; - } + if (errorMessage) { + errorMessageComponent = ; + hideLoading = ' hide'; + hideError = ''; + } - return ( -
-
-
-
- -
-
- Signing into Data Broker... -
+ return ( +
+
+
+
+ +
+
+ Signing into Data Broker...
-
-
- {errorMessageComponent} -
- Back to login page -
+
+
+
+ {errorMessageComponent} +
+ Back to login page
- ); - } -} +
+ ); +}; LoginCaiaLoading.propTypes = propTypes; -LoginCaiaLoading.defaultProps = defaultProps; +export default LoginCaiaLoading; diff --git a/src/js/components/login/LoginIntro.jsx b/src/js/components/login/LoginIntro.jsx index 858de6843..307f47a3f 100644 --- a/src/js/components/login/LoginIntro.jsx +++ b/src/js/components/login/LoginIntro.jsx @@ -3,18 +3,16 @@ * Created by Kyle Fox 12/4/15 */ -import React from 'react'; +const LoginIntro = () => { + return ( +
+
Data Broker
+

+ Sign in to upload your agency financial data and validate it against the Governmentwide Spending + Data Model (GSDM), formerly known as the DATA Act Information Model Schema (DAIMS). +

+
+ ); +}; -export default class LoginIntro extends React.Component { - render() { - return ( -
-
Data Broker
-

- Sign in to upload your agency financial data and validate it against the Governmentwide Spending - Data Model (GSDM), formerly known as the DATA Act Information Model Schema (DAIMS). -

-
- ); - } -} +export default LoginIntro; diff --git a/src/js/components/login/LoginPage.jsx b/src/js/components/login/LoginPage.jsx index 6cdc9e667..b68458385 100644 --- a/src/js/components/login/LoginPage.jsx +++ b/src/js/components/login/LoginPage.jsx @@ -3,29 +3,28 @@ * Created by Kyle Fox 12/4/15 */ -import React from 'react'; import { kGlobalConstants } from '../../GlobalConstants'; import LoginBanner from './LoginBanner'; import LoginWarningTxt from './LoginWarningTxt'; import TestEnvironmentBanner from '../SharedComponents/banners/TestEnvironmentBanner'; -export default class LoginPage extends React.Component { - render() { - let testBanner = null; - if (!kGlobalConstants.PROD) { - testBanner = ; - } +const LoginPage = (props) => { + let testBanner = null; + if (!kGlobalConstants.PROD) { + testBanner = ; + } - return ( -
-
-
- {testBanner} - - -
+ return ( +
+
+
+ {testBanner} + +
- ); - } -} +
+ ); +}; + +export default LoginPage; diff --git a/src/js/components/login/LoginPanel.jsx b/src/js/components/login/LoginPanel.jsx index 6b1d2c2da..b93dba7a7 100644 --- a/src/js/components/login/LoginPanel.jsx +++ b/src/js/components/login/LoginPanel.jsx @@ -3,7 +3,7 @@ * Created by Kyle Fox 2/19/16 */ -import React from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import Username from './Username'; import Password from './Password'; @@ -17,85 +17,58 @@ const propTypes = { loading: PropTypes.bool }; -const defaultProps = { - performLogin: null, - session: null, - errorMessage: '', - loading: false -}; +const LoginPanel = ({performLogin = null, session = null, errorMessage = '', loading = false}) => { + const [username, setUsername] = useState(''); + const [password, setPassword] = useState(''); -export default class LoginPanel extends React.Component { - constructor(props) { - super(props); + const loginClicked = () => { + performLogin(username, password); + }; - this.state = { - username: '', - password: '' - }; - } + const handleUsernameChange = (e) => { + setUsername(e.target.value); + }; - loginClicked() { - this.props.performLogin(this.state.username, this.state.password); - } - - handleKeyPress(e) { - const enterKey = 13; - if (e.charCode === enterKey) { - this.loginClicked(); - e.preventDefault(); - } - } + const handlePasswordChange = (e) => { + setPassword(e.target.value); + }; - handleUsernameChange(e) { - this.setState({ - username: e.target.value - }); - } + let errorMessageComponent = null; - handlePasswordChange(e) { - this.setState({ - password: e.target.value - }); + if (session.login === "failed") { + errorMessageComponent = ; } - render() { - let errorMessageComponent = null; - - if (this.props.session.login === "failed") { - errorMessageComponent = ; - } - - return ( -
-
-
-
- -
+ return ( +
+ +
+
+
-
-
- -
+
+
+
+
-
-
- -
+
+
+
+
-
-
- {errorMessageComponent} -
+
+
+
+ {errorMessageComponent}
- -
- ); - } -} +
+ +
+ ); +}; LoginPanel.propTypes = propTypes; -LoginPanel.defaultProps = defaultProps; +export default LoginPanel; diff --git a/src/js/components/login/LoginWarningTxt.jsx b/src/js/components/login/LoginWarningTxt.jsx index a6f6f998a..90e053734 100644 --- a/src/js/components/login/LoginWarningTxt.jsx +++ b/src/js/components/login/LoginWarningTxt.jsx @@ -3,34 +3,32 @@ * Created by Destin Frasier 4/15/16 */ -import React from 'react'; - -export default class LoginWarningTxt extends React.Component { - render() { - return ( -
-
-
-

- WARNING WARNING WARNING You have accessed a U.S. Government information - system, which includes (1) this computer, (2) this network, (3) all computers connected to - this network, and (4) all devices and storage media attached to this network or to a - computer on this network. U.S. Government information systems are provided for the - processing of official U.S. Government information only. Unauthorized or improper use of - this information system is prohibited and may subject you to disciplinary action, as well - as civil and criminal penalties. All data contained on U.S. Government information systems - is owned by the U.S. Government and may, for the purpose of protecting the rights and - property of the U.S. Government, be monitored, intercepted, recorded, read, searched, - copied, or captured in any manner and disclosed or used for any lawful government purpose - at any time. THERE IS NO RIGHT TO PRIVACY IN THIS SYSTEM. System personnel may give to law - enforcement officials any potential evidence of crime found on U.S. Government information - systems. USE OF THIS SYSTEM BY ANY USER, AUTHORIZED OR UNAUTHORIZED, CONSTITUTES YOUR - UNDERSTANDING AND CONSENT TO THIS MONITORING, INTERCEPTION, RECORDING, READING, COPYING, OR - CAPTURING AND DISCLOSURE. -

-
+const LoginWarningTxt = () => { + return ( +
+
+
+

+ WARNING WARNING WARNING You have accessed a U.S. Government information + system, which includes (1) this computer, (2) this network, (3) all computers connected to + this network, and (4) all devices and storage media attached to this network or to a + computer on this network. U.S. Government information systems are provided for the + processing of official U.S. Government information only. Unauthorized or improper use of + this information system is prohibited and may subject you to disciplinary action, as well + as civil and criminal penalties. All data contained on U.S. Government information systems + is owned by the U.S. Government and may, for the purpose of protecting the rights and + property of the U.S. Government, be monitored, intercepted, recorded, read, searched, + copied, or captured in any manner and disclosed or used for any lawful government purpose + at any time. THERE IS NO RIGHT TO PRIVACY IN THIS SYSTEM. System personnel may give to law + enforcement officials any potential evidence of crime found on U.S. Government information + systems. USE OF THIS SYSTEM BY ANY USER, AUTHORIZED OR UNAUTHORIZED, CONSTITUTES YOUR + UNDERSTANDING AND CONSENT TO THIS MONITORING, INTERCEPTION, RECORDING, READING, COPYING, OR + CAPTURING AND DISCLOSURE. +

- ); - } -} +
+ ); +}; + +export default LoginWarningTxt; diff --git a/src/js/components/login/Password.jsx b/src/js/components/login/Password.jsx index 7d24e6192..2e0f95ab6 100644 --- a/src/js/components/login/Password.jsx +++ b/src/js/components/login/Password.jsx @@ -3,7 +3,6 @@ * Created by Kyle Fox 12/4/15 */ -import React from 'react'; import PropTypes from 'prop-types'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -16,40 +15,32 @@ const propTypes = { isRequired: PropTypes.bool }; -const defaultProps = { - fieldID: "password", - error: false, - tabIndex: "2", - placeholder: "Password", - isRequired: true -}; - -export default class Password extends React.Component { - render() { - let className = ''; - if (this.props.error) { - className = ' error'; - } - return ( -
- - - - - -
- ); +const Password = ({ + fieldID = 'password', error = false, tabIndex = '2', placeholder = 'Password', isRequired = true, ...props +}) => { + let className = ''; + if (error) { + className = ' error'; } -} + return ( +
+ + + + + +
+ ); +}; Password.propTypes = propTypes; -Password.defaultProps = defaultProps; +export default Password; diff --git a/src/js/components/login/PendingPage.jsx b/src/js/components/login/PendingPage.jsx index 9ec876e51..40d915290 100644 --- a/src/js/components/login/PendingPage.jsx +++ b/src/js/components/login/PendingPage.jsx @@ -3,17 +3,15 @@ * Created by Kevin Li 3/21/16 */ -import React from 'react'; - -export default class PendingPage extends React.Component { - render() { - return ( -
-