updates product name in About modal

This commit is contained in:
Alex Corey
2021-07-13 14:43:57 -04:00
parent 3f44c5d18b
commit fb91c8fba1
5 changed files with 17 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
{ {
"BRAND_NAME": "Ansible AWX", "BRAND_NAME": "Ansible AWX",
"COMPONENT_NAME": "",
"PENDO_API_KEY": "" "PENDO_API_KEY": ""
} }

View File

@@ -5,9 +5,14 @@ import { AboutModal } from '@patternfly/react-core';
import useBrandName from 'hooks/useBrandName'; import useBrandName from 'hooks/useBrandName';
function About({ version, isOpen, onClose }) { function About({ version, isOpen, onClose }) {
const brandName = useBrandName(); const {
current: { brandName, componentName },
} = useBrandName();
const createSpeechBubble = () => { const createSpeechBubble = () => {
let text = `${brandName.current} ${version}`; let text =
componentName !== ''
? `${brandName} ${componentName} ${version}`
: `${brandName} ${version}`;
let top = ''; let top = '';
let bottom = ''; let bottom = '';
@@ -31,7 +36,7 @@ function About({ version, isOpen, onClose }) {
<AboutModal <AboutModal
isOpen={isOpen} isOpen={isOpen}
onClose={onClose} onClose={onClose}
productName={brandName.current} productName={brandName}
trademark={`${copyright} ${new Date().getFullYear()} ${redHatInc}`} trademark={`${copyright} ${new Date().getFullYear()} ${redHatInc}`}
brandImageSrc="/static/media/logo-header.svg" brandImageSrc="/static/media/logo-header.svg"
brandImageAlt={t`Brand Image`} brandImageAlt={t`Brand Image`}

View File

@@ -5,7 +5,7 @@ import About from './About';
jest.mock('../../hooks/useBrandName', () => ({ jest.mock('../../hooks/useBrandName', () => ({
__esModule: true, __esModule: true,
default: () => ({ default: () => ({
current: 'AWX', current: { brandName: 'AWX', componentName: '' },
}), }),
})); }));

View File

@@ -22,6 +22,7 @@ describe('<AppContainer />', () => {
RootAPI.readAssetVariables.mockResolvedValue({ RootAPI.readAssetVariables.mockResolvedValue({
data: { data: {
BRAND_NAME: 'AWX', BRAND_NAME: 'AWX',
COMPONENT_NAME: '',
PENDO_API_KEY: 'some-pendo-key', PENDO_API_KEY: 'some-pendo-key',
}, },
}); });
@@ -99,6 +100,7 @@ describe('<AppContainer />', () => {
RootAPI.readAssetVariables.mockResolvedValue({ RootAPI.readAssetVariables.mockResolvedValue({
data: { data: {
BRAND_NAME: 'AWX', BRAND_NAME: 'AWX',
COMPONENT_NAME: '',
PENDO_API_KEY: '', PENDO_API_KEY: '',
}, },
}); });

View File

@@ -2,18 +2,18 @@ import { useEffect, useRef } from 'react';
import { RootAPI } from 'api'; import { RootAPI } from 'api';
export default function useBrandName() { export default function useBrandName() {
const brandName = useRef(''); const platform = useRef({});
useEffect(() => { useEffect(() => {
async function fetchBrandName() { async function fetchBrandName() {
const { const {
data: { BRAND_NAME }, data: { BRAND_NAME, COMPONENT_NAME },
} = await RootAPI.readAssetVariables(); } = await RootAPI.readAssetVariables();
platform.current.brandName = BRAND_NAME;
brandName.current = BRAND_NAME; platform.current.componentName = COMPONENT_NAME || '';
} }
fetchBrandName(); fetchBrandName();
}, []); }, []);
return brandName; return platform;
} }