From 7ff82db691ae191e3d7938f85ae861bc29a6be19 Mon Sep 17 00:00:00 2001 From: mabashian Date: Mon, 30 Nov 2020 10:38:41 -0500 Subject: [PATCH] Fix login after source variables change --- awx/ui_next/src/screens/Login/Login.jsx | 29 ++++++++++++-------- awx/ui_next/src/screens/Login/Login.test.jsx | 10 +++++-- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/awx/ui_next/src/screens/Login/Login.jsx b/awx/ui_next/src/screens/Login/Login.jsx index d4c56c26df..ca358a0d74 100644 --- a/awx/ui_next/src/screens/Login/Login.jsx +++ b/awx/ui_next/src/screens/Login/Login.jsx @@ -7,11 +7,10 @@ import styled from 'styled-components'; import { LoginForm, LoginPage as PFLoginPage } from '@patternfly/react-core'; import useRequest, { useDismissableError } from '../../util/useRequest'; import { RootAPI } from '../../api'; -import { BrandName } from '../../variables'; import AlertModal from '../../components/AlertModal'; import ErrorDetail from '../../components/ErrorDetail'; -import brandLogo from './brand-logo.svg'; +const loginLogoSrc = '/static/media/logo-login.svg'; const LoginPage = styled(PFLoginPage)` & .pf-c-brand { @@ -24,21 +23,27 @@ function AWXLogin({ alt, i18n, isAuthenticated }) { isLoading: isCustomLoginInfoLoading, error: customLoginInfoError, request: fetchCustomLoginInfo, - result: { logo, loginInfo }, + result: { brandName, logo, loginInfo }, } = useRequest( useCallback(async () => { - const { - data: { custom_logo, custom_login_info }, - } = await RootAPI.read(); + const [ + { + data: { custom_logo, custom_login_info }, + }, + { + data: { BRAND_NAME }, + }, + ] = await Promise.all([RootAPI.read(), RootAPI.readAssetVariables()]); const logoSrc = custom_logo ? `data:image/jpeg;${custom_logo}` - : brandLogo; + : loginLogoSrc; return { + brandName: BRAND_NAME, logo: logoSrc, loginInfo: custom_login_info, }; }, []), - { logo: brandLogo, loginInfo: null } + { brandName: null, logo: loginLogoSrc, loginInfo: null } ); const { @@ -70,8 +75,6 @@ function AWXLogin({ alt, i18n, isAuthenticated }) { await authenticate(values); }; - const brandName = BrandName; - if (isCustomLoginInfoLoading) { return null; } @@ -91,7 +94,11 @@ function AWXLogin({ alt, i18n, isAuthenticated }) { ', () => { async function findChildren(wrapper) { const [ @@ -100,7 +106,7 @@ describe('', () => { }); const { loginHeaderLogo } = await findChildren(wrapper); const { alt, src } = loginHeaderLogo.props(); - expect([alt, src]).toEqual(['AWX', 'brand-logo.svg']); + expect([alt, src]).toEqual(['AWX', '/static/media/logo-login.svg']); done(); }); @@ -123,7 +129,7 @@ describe('', () => { }); const { loginHeaderLogo } = await findChildren(wrapper); const { alt, src } = loginHeaderLogo.props(); - expect([alt, src]).toEqual(['AWX', 'brand-logo.svg']); + expect([alt, src]).toEqual([null, '/static/media/logo-login.svg']); expect(wrapper.find('AlertModal').length).toBe(1); done(); });