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",
"COMPONENT_NAME": "",
"PENDO_API_KEY": ""
}

View File

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

View File

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

View File

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

View File

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