mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Update useBrandName
Update useBrandName and its usage. It was verified on downstrean this solution. See:https://github.com/ansible/awx/issues/10775
This commit is contained in:
parent
80053cea83
commit
efcac6d55a
@ -1,5 +1,4 @@
|
||||
{
|
||||
"BRAND_NAME": "Ansible AWX",
|
||||
"COMPONENT_NAME": "",
|
||||
"PENDO_API_KEY": ""
|
||||
}
|
||||
|
||||
@ -5,14 +5,17 @@ import { AboutModal } from '@patternfly/react-core';
|
||||
import useBrandName from 'hooks/useBrandName';
|
||||
|
||||
function About({ version, isOpen, onClose }) {
|
||||
const {
|
||||
current: { brandName, componentName },
|
||||
} = useBrandName();
|
||||
const brandName = useBrandName();
|
||||
|
||||
const createSpeechBubble = () => {
|
||||
let text =
|
||||
componentName !== ''
|
||||
? `${brandName} ${componentName} ${version}`
|
||||
: `${brandName} ${version}`;
|
||||
let text = '';
|
||||
if (typeof brandName === 'string' && brandName.length > 0) {
|
||||
text =
|
||||
brandName.indexOf('AWX') === -1
|
||||
? `${brandName} Controller ${version}`
|
||||
: `${brandName} ${version}`;
|
||||
}
|
||||
|
||||
let top = '';
|
||||
let bottom = '';
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import About from './About';
|
||||
jest.mock('../../hooks/useBrandName', () => ({
|
||||
__esModule: true,
|
||||
default: () => ({
|
||||
current: { brandName: 'AWX', componentName: '' },
|
||||
current: 'AWX',
|
||||
}),
|
||||
}));
|
||||
|
||||
|
||||
@ -22,9 +22,7 @@ const TooltipWrapper = styled.div`
|
||||
`;
|
||||
|
||||
function AdHocDetailsStep({ verbosityOptions, moduleOptions }) {
|
||||
const {
|
||||
current: { brandName },
|
||||
} = useBrandName();
|
||||
const brandName = useBrandName();
|
||||
const [moduleNameField, moduleNameMeta, moduleNameHelpers] = useField({
|
||||
name: 'module_name',
|
||||
validate: required(null),
|
||||
|
||||
@ -22,7 +22,6 @@ describe('<AppContainer />', () => {
|
||||
RootAPI.readAssetVariables.mockResolvedValue({
|
||||
data: {
|
||||
BRAND_NAME: 'AWX',
|
||||
COMPONENT_NAME: '',
|
||||
PENDO_API_KEY: 'some-pendo-key',
|
||||
},
|
||||
});
|
||||
@ -100,7 +99,6 @@ describe('<AppContainer />', () => {
|
||||
RootAPI.readAssetVariables.mockResolvedValue({
|
||||
data: {
|
||||
BRAND_NAME: 'AWX',
|
||||
COMPONENT_NAME: '',
|
||||
PENDO_API_KEY: '',
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { RootAPI } from 'api';
|
||||
|
||||
export default function useBrandName() {
|
||||
const platform = useRef({});
|
||||
const [brandName, setBrandName] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchBrandName() {
|
||||
const {
|
||||
data: { BRAND_NAME, COMPONENT_NAME },
|
||||
data: { BRAND_NAME },
|
||||
} = await RootAPI.readAssetVariables();
|
||||
platform.current.brandName = BRAND_NAME;
|
||||
platform.current.componentName = COMPONENT_NAME || '';
|
||||
setBrandName(BRAND_NAME);
|
||||
}
|
||||
fetchBrandName();
|
||||
}, []);
|
||||
|
||||
return platform;
|
||||
return brandName;
|
||||
}
|
||||
|
||||
@ -14,9 +14,8 @@ const ManualSubForm = ({
|
||||
project_base_dir,
|
||||
project_local_paths,
|
||||
}) => {
|
||||
const {
|
||||
current: { brandName },
|
||||
} = useBrandName();
|
||||
const brandName = useBrandName();
|
||||
|
||||
const localPaths = [...new Set([...project_local_paths, localPath])];
|
||||
const options = [
|
||||
{
|
||||
|
||||
@ -45,9 +45,8 @@ const CardDescription = styled.div`
|
||||
|
||||
function SettingList() {
|
||||
const config = useConfig();
|
||||
const {
|
||||
current: { brandName },
|
||||
} = useBrandName();
|
||||
const brandName = useBrandName();
|
||||
|
||||
const settingRoutes = [
|
||||
{
|
||||
header: t`Authentication`,
|
||||
|
||||
@ -66,9 +66,7 @@ function JobTemplateForm({
|
||||
Boolean(template.webhook_service)
|
||||
);
|
||||
const isMounted = useIsMounted();
|
||||
const {
|
||||
current: { brandName },
|
||||
} = useBrandName();
|
||||
const brandName = useBrandName();
|
||||
|
||||
const [askInventoryOnLaunchField] = useField('ask_inventory_on_launch');
|
||||
const [jobTypeField, jobTypeMeta, jobTypeHelpers] = useField({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user