mirror of
https://github.com/ansible/awx.git
synced 2026-02-01 09:38:10 -03:30
Merge pull request #10849 from nixocio/ui_issue_10775_again
Update useBrandName
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"BRAND_NAME": "Ansible AWX",
|
"BRAND_NAME": "Ansible AWX",
|
||||||
"COMPONENT_NAME": "",
|
|
||||||
"PENDO_API_KEY": ""
|
"PENDO_API_KEY": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,17 @@ 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 {
|
const brandName = useBrandName();
|
||||||
current: { brandName, componentName },
|
|
||||||
} = useBrandName();
|
|
||||||
const createSpeechBubble = () => {
|
const createSpeechBubble = () => {
|
||||||
let text =
|
let text = '';
|
||||||
componentName !== ''
|
if (typeof brandName === 'string' && brandName.length > 0) {
|
||||||
? `${brandName} ${componentName} ${version}`
|
text =
|
||||||
: `${brandName} ${version}`;
|
brandName.indexOf('AWX') === -1
|
||||||
|
? `${brandName} Controller ${version}`
|
||||||
|
: `${brandName} ${version}`;
|
||||||
|
}
|
||||||
|
|
||||||
let top = '';
|
let top = '';
|
||||||
let bottom = '';
|
let bottom = '';
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import About from './About';
|
|||||||
jest.mock('../../hooks/useBrandName', () => ({
|
jest.mock('../../hooks/useBrandName', () => ({
|
||||||
__esModule: true,
|
__esModule: true,
|
||||||
default: () => ({
|
default: () => ({
|
||||||
current: { brandName: 'AWX', componentName: '' },
|
current: 'AWX',
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ describe('<About />', () => {
|
|||||||
const modal = wrapper.find('AboutModal');
|
const modal = wrapper.find('AboutModal');
|
||||||
expect(modal).toHaveLength(1);
|
expect(modal).toHaveLength(1);
|
||||||
expect(modal.prop('onClose')).toEqual(onClose);
|
expect(modal.prop('onClose')).toEqual(onClose);
|
||||||
expect(modal.prop('productName')).toEqual('AWX');
|
expect(modal.prop('productName')).toEqual({ current: 'AWX' });
|
||||||
expect(modal.prop('isOpen')).toEqual(true);
|
expect(modal.prop('isOpen')).toEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ const TooltipWrapper = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
function AdHocDetailsStep({ verbosityOptions, moduleOptions }) {
|
function AdHocDetailsStep({ verbosityOptions, moduleOptions }) {
|
||||||
const {
|
const brandName = useBrandName();
|
||||||
current: { brandName },
|
|
||||||
} = useBrandName();
|
|
||||||
const [moduleNameField, moduleNameMeta, moduleNameHelpers] = useField({
|
const [moduleNameField, moduleNameMeta, moduleNameHelpers] = useField({
|
||||||
name: 'module_name',
|
name: 'module_name',
|
||||||
validate: required(null),
|
validate: required(null),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ 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',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -100,7 +99,6 @@ describe('<AppContainer />', () => {
|
|||||||
RootAPI.readAssetVariables.mockResolvedValue({
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
BRAND_NAME: 'AWX',
|
BRAND_NAME: 'AWX',
|
||||||
COMPONENT_NAME: '',
|
|
||||||
PENDO_API_KEY: '',
|
PENDO_API_KEY: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { RootAPI } from 'api';
|
import { RootAPI } from 'api';
|
||||||
|
|
||||||
export default function useBrandName() {
|
export default function useBrandName() {
|
||||||
const platform = useRef({});
|
const [brandName, setBrandName] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchBrandName() {
|
async function fetchBrandName() {
|
||||||
const {
|
const {
|
||||||
data: { BRAND_NAME, COMPONENT_NAME },
|
data: { BRAND_NAME },
|
||||||
} = await RootAPI.readAssetVariables();
|
} = await RootAPI.readAssetVariables();
|
||||||
platform.current.brandName = BRAND_NAME;
|
setBrandName(BRAND_NAME);
|
||||||
platform.current.componentName = COMPONENT_NAME || '';
|
|
||||||
}
|
}
|
||||||
fetchBrandName();
|
fetchBrandName();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return platform;
|
return brandName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ const ManualSubForm = ({
|
|||||||
project_base_dir,
|
project_base_dir,
|
||||||
project_local_paths,
|
project_local_paths,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const brandName = useBrandName();
|
||||||
current: { brandName },
|
|
||||||
} = useBrandName();
|
|
||||||
const localPaths = [...new Set([...project_local_paths, localPath])];
|
const localPaths = [...new Set([...project_local_paths, localPath])];
|
||||||
const options = [
|
const options = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,9 +45,8 @@ const CardDescription = styled.div`
|
|||||||
|
|
||||||
function SettingList() {
|
function SettingList() {
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const {
|
const brandName = useBrandName();
|
||||||
current: { brandName },
|
|
||||||
} = useBrandName();
|
|
||||||
const settingRoutes = [
|
const settingRoutes = [
|
||||||
{
|
{
|
||||||
header: t`Authentication`,
|
header: t`Authentication`,
|
||||||
|
|||||||
@@ -66,9 +66,7 @@ function JobTemplateForm({
|
|||||||
Boolean(template.webhook_service)
|
Boolean(template.webhook_service)
|
||||||
);
|
);
|
||||||
const isMounted = useIsMounted();
|
const isMounted = useIsMounted();
|
||||||
const {
|
const brandName = useBrandName();
|
||||||
current: { brandName },
|
|
||||||
} = useBrandName();
|
|
||||||
|
|
||||||
const [askInventoryOnLaunchField] = useField('ask_inventory_on_launch');
|
const [askInventoryOnLaunchField] = useField('ask_inventory_on_launch');
|
||||||
const [jobTypeField, jobTypeMeta, jobTypeHelpers] = useField({
|
const [jobTypeField, jobTypeMeta, jobTypeHelpers] = useField({
|
||||||
|
|||||||
Reference in New Issue
Block a user