mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Pull brand name from default.strings.json
This commit is contained in:
@@ -37,7 +37,6 @@
|
|||||||
name="description"
|
name="description"
|
||||||
content="AWX"
|
content="AWX"
|
||||||
/>
|
/>
|
||||||
<title>AWX</title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import { ErrorBoundary } from 'react-error-boundary';
|
|||||||
import { I18nProvider } from '@lingui/react';
|
import { I18nProvider } from '@lingui/react';
|
||||||
import { i18n } from '@lingui/core';
|
import { i18n } from '@lingui/core';
|
||||||
import { Card, PageSection } from '@patternfly/react-core';
|
import { Card, PageSection } from '@patternfly/react-core';
|
||||||
|
|
||||||
import { ConfigProvider, useAuthorizedPath } from './contexts/Config';
|
import { ConfigProvider, useAuthorizedPath } from './contexts/Config';
|
||||||
import { SessionProvider, useSession } from './contexts/Session';
|
import { SessionProvider, useSession } from './contexts/Session';
|
||||||
import AppContainer from './components/AppContainer';
|
import AppContainer from './components/AppContainer';
|
||||||
@@ -20,15 +19,14 @@ import Background from './components/Background';
|
|||||||
import ContentError from './components/ContentError';
|
import ContentError from './components/ContentError';
|
||||||
import NotFound from './screens/NotFound';
|
import NotFound from './screens/NotFound';
|
||||||
import Login from './screens/Login';
|
import Login from './screens/Login';
|
||||||
|
|
||||||
import { isAuthenticated } from './util/auth';
|
import { isAuthenticated } from './util/auth';
|
||||||
import { getLanguageWithoutRegionCode } from './util/language';
|
import { getLanguageWithoutRegionCode } from './util/language';
|
||||||
import { dynamicActivate, locales } from './i18nLoader';
|
import { dynamicActivate, locales } from './i18nLoader';
|
||||||
import Metrics from './screens/Metrics';
|
import Metrics from './screens/Metrics';
|
||||||
|
|
||||||
import getRouteConfig from './routeConfig';
|
import getRouteConfig from './routeConfig';
|
||||||
import SubscriptionEdit from './screens/Setting/Subscription/SubscriptionEdit';
|
import SubscriptionEdit from './screens/Setting/Subscription/SubscriptionEdit';
|
||||||
import { SESSION_REDIRECT_URL } from './constants';
|
import { SESSION_REDIRECT_URL } from './constants';
|
||||||
|
import { RootAPI } from './api';
|
||||||
|
|
||||||
function ErrorFallback({ error }) {
|
function ErrorFallback({ error }) {
|
||||||
return (
|
return (
|
||||||
@@ -113,10 +111,22 @@ function App() {
|
|||||||
// preferred language, default to one that has strings.
|
// preferred language, default to one that has strings.
|
||||||
language = 'en';
|
language = 'en';
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dynamicActivate(language);
|
dynamicActivate(language);
|
||||||
}, [language]);
|
}, [language]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function fetchBrandName() {
|
||||||
|
const {
|
||||||
|
data: { BRAND_NAME },
|
||||||
|
} = await RootAPI.readAssetVariables();
|
||||||
|
|
||||||
|
document.title = BRAND_NAME;
|
||||||
|
}
|
||||||
|
fetchBrandName();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const redirectURL = window.sessionStorage.getItem(SESSION_REDIRECT_URL);
|
const redirectURL = window.sessionStorage.getItem(SESSION_REDIRECT_URL);
|
||||||
if (redirectURL) {
|
if (redirectURL) {
|
||||||
window.sessionStorage.removeItem(SESSION_REDIRECT_URL);
|
window.sessionStorage.removeItem(SESSION_REDIRECT_URL);
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
import { mountWithContexts } from '../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../testUtils/enzymeHelpers';
|
||||||
|
import { RootAPI } from './api';
|
||||||
import * as SessionContext from './contexts/Session';
|
import * as SessionContext from './contexts/Session';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
|
||||||
jest.mock('./api');
|
jest.mock('./api');
|
||||||
|
|
||||||
describe('<App />', () => {
|
describe('<App />', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('renders ok', async () => {
|
test('renders ok', async () => {
|
||||||
const contextValues = {
|
const contextValues = {
|
||||||
setAuthRedirectTo: jest.fn(),
|
setAuthRedirectTo: jest.fn(),
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { AboutModal } from '@patternfly/react-core';
|
import { AboutModal } from '@patternfly/react-core';
|
||||||
|
import useBrandName from '../../util/useBrandName';
|
||||||
import { BrandName } from '../../variables';
|
|
||||||
|
|
||||||
function About({ version, isOpen, onClose }) {
|
function About({ version, isOpen, onClose }) {
|
||||||
|
const brandName = useBrandName();
|
||||||
const createSpeechBubble = () => {
|
const createSpeechBubble = () => {
|
||||||
let text = `${BrandName} ${version}`;
|
let text = `${brandName.current} ${version}`;
|
||||||
let top = '';
|
let top = '';
|
||||||
let bottom = '';
|
let bottom = '';
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ function About({ version, isOpen, onClose }) {
|
|||||||
<AboutModal
|
<AboutModal
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
productName={`Ansible ${BrandName}`}
|
productName={`Ansible ${brandName.current}`}
|
||||||
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`}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
InventoriesAPI,
|
InventoriesAPI,
|
||||||
CredentialsAPI,
|
CredentialsAPI,
|
||||||
ExecutionEnvironmentsAPI,
|
ExecutionEnvironmentsAPI,
|
||||||
|
RootAPI,
|
||||||
} from '../../api';
|
} from '../../api';
|
||||||
import AdHocCommands from './AdHocCommands';
|
import AdHocCommands from './AdHocCommands';
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ jest.mock('../../api/models/CredentialTypes');
|
|||||||
jest.mock('../../api/models/Inventories');
|
jest.mock('../../api/models/Inventories');
|
||||||
jest.mock('../../api/models/Credentials');
|
jest.mock('../../api/models/Credentials');
|
||||||
jest.mock('../../api/models/ExecutionEnvironments');
|
jest.mock('../../api/models/ExecutionEnvironments');
|
||||||
|
jest.mock('../../api/models/Root');
|
||||||
|
|
||||||
jest.mock('react-router-dom', () => ({
|
jest.mock('react-router-dom', () => ({
|
||||||
...jest.requireActual('react-router-dom'),
|
...jest.requireActual('react-router-dom'),
|
||||||
@@ -40,6 +42,11 @@ const adHocItems = [
|
|||||||
|
|
||||||
describe('<AdHocCommands />', () => {
|
describe('<AdHocCommands />', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
InventoriesAPI.readAdHocOptions.mockResolvedValue({
|
InventoriesAPI.readAdHocOptions.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
actions: {
|
actions: {
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import {
|
|||||||
mountWithContexts,
|
mountWithContexts,
|
||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../testUtils/enzymeHelpers';
|
} from '../../../testUtils/enzymeHelpers';
|
||||||
import { CredentialsAPI, ExecutionEnvironmentsAPI } from '../../api';
|
import { CredentialsAPI, ExecutionEnvironmentsAPI, RootAPI } from '../../api';
|
||||||
import AdHocCommandsWizard from './AdHocCommandsWizard';
|
import AdHocCommandsWizard from './AdHocCommandsWizard';
|
||||||
|
|
||||||
jest.mock('../../api/models/CredentialTypes');
|
jest.mock('../../api/models/CredentialTypes');
|
||||||
jest.mock('../../api/models/Inventories');
|
jest.mock('../../api/models/Inventories');
|
||||||
jest.mock('../../api/models/Credentials');
|
jest.mock('../../api/models/Credentials');
|
||||||
jest.mock('../../api/models/ExecutionEnvironments');
|
jest.mock('../../api/models/ExecutionEnvironments');
|
||||||
|
jest.mock('../../api/models/Root');
|
||||||
|
|
||||||
const verbosityOptions = [
|
const verbosityOptions = [
|
||||||
{ value: '0', key: '0', label: '0 (Normal)' },
|
{ value: '0', key: '0', label: '0 (Normal)' },
|
||||||
@@ -32,6 +33,11 @@ describe('<AdHocCommandsWizard/>', () => {
|
|||||||
let wrapper;
|
let wrapper;
|
||||||
const onLaunch = jest.fn();
|
const onLaunch = jest.fn();
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<AdHocCommandsWizard
|
<AdHocCommandsWizard
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import PropTypes from 'prop-types';
|
|||||||
import { useField } from 'formik';
|
import { useField } from 'formik';
|
||||||
import { Form, FormGroup, Switch, Checkbox } from '@patternfly/react-core';
|
import { Form, FormGroup, Switch, Checkbox } from '@patternfly/react-core';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { BrandName } from '../../variables';
|
|
||||||
import AnsibleSelect from '../AnsibleSelect';
|
import AnsibleSelect from '../AnsibleSelect';
|
||||||
import FormField from '../FormField';
|
import FormField from '../FormField';
|
||||||
import { VariablesField } from '../CodeEditor';
|
import { VariablesField } from '../CodeEditor';
|
||||||
@@ -18,17 +16,14 @@ import {
|
|||||||
} from '../FormLayout';
|
} from '../FormLayout';
|
||||||
import Popover from '../Popover';
|
import Popover from '../Popover';
|
||||||
import { required } from '../../util/validators';
|
import { required } from '../../util/validators';
|
||||||
|
import useBrandName from '../../util/useBrandName';
|
||||||
|
|
||||||
const TooltipWrapper = styled.div`
|
const TooltipWrapper = styled.div`
|
||||||
text-align: left;
|
text-align: left;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Setting BrandName to a variable here is necessary to get the jest tests
|
|
||||||
// passing. Attempting to use BrandName in the template literal results
|
|
||||||
// in failing tests.
|
|
||||||
const brandName = BrandName;
|
|
||||||
|
|
||||||
function AdHocDetailsStep({ verbosityOptions, moduleOptions }) {
|
function AdHocDetailsStep({ verbosityOptions, moduleOptions }) {
|
||||||
|
const brandName = useBrandName();
|
||||||
const [moduleNameField, moduleNameMeta, moduleNameHelpers] = useField({
|
const [moduleNameField, moduleNameMeta, moduleNameHelpers] = useField({
|
||||||
name: 'module_name',
|
name: 'module_name',
|
||||||
validate: required(null),
|
validate: required(null),
|
||||||
@@ -70,7 +65,7 @@ function AdHocDetailsStep({ verbosityOptions, moduleOptions }) {
|
|||||||
}
|
}
|
||||||
labelIcon={
|
labelIcon={
|
||||||
<Popover
|
<Popover
|
||||||
content={t`These are the modules that ${brandName} supports running commands against.`}
|
content={t`These are the modules that ${brandName.current} supports running commands against.`}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import React from 'react';
|
|||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
import { Formik } from 'formik';
|
import { Formik } from 'formik';
|
||||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
|
import { RootAPI } from '../../api';
|
||||||
import DetailsStep from './AdHocDetailsStep';
|
import DetailsStep from './AdHocDetailsStep';
|
||||||
|
|
||||||
jest.mock('../../api/models/Credentials');
|
jest.mock('../../api/models/Credentials');
|
||||||
|
jest.mock('../../api/models/Root');
|
||||||
|
|
||||||
const verbosityOptions = [
|
const verbosityOptions = [
|
||||||
{ key: -1, value: '', label: '', isDisabled: false },
|
{ key: -1, value: '', label: '', isDisabled: false },
|
||||||
@@ -32,6 +34,14 @@ const initialValues = {
|
|||||||
describe('<AdHocDetailsStep />', () => {
|
describe('<AdHocDetailsStep />', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('should mount properly', async () => {
|
test('should mount properly', async () => {
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ import ReactDOM from 'react-dom';
|
|||||||
import './setupCSP';
|
import './setupCSP';
|
||||||
import '@patternfly/react-core/dist/styles/base.css';
|
import '@patternfly/react-core/dist/styles/base.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import { BrandName } from './variables';
|
|
||||||
|
|
||||||
document.title = `${BrandName}`;
|
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../../testUtils/enzymeHelpers';
|
} from '../../../../testUtils/enzymeHelpers';
|
||||||
import ProjectEdit from './ProjectEdit';
|
import ProjectEdit from './ProjectEdit';
|
||||||
import { ProjectsAPI, CredentialTypesAPI } from '../../../api';
|
import { ProjectsAPI, CredentialTypesAPI, RootAPI } from '../../../api';
|
||||||
|
|
||||||
jest.mock('../../../api');
|
jest.mock('../../../api');
|
||||||
|
|
||||||
@@ -83,6 +83,11 @@ describe('<ProjectEdit />', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
await ProjectsAPI.readOptions.mockImplementation(
|
await ProjectsAPI.readOptions.mockImplementation(
|
||||||
() => projectOptionsResolve
|
() => projectOptionsResolve
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../../testUtils/enzymeHelpers';
|
} from '../../../../testUtils/enzymeHelpers';
|
||||||
import ProjectForm from './ProjectForm';
|
import ProjectForm from './ProjectForm';
|
||||||
import { CredentialTypesAPI, ProjectsAPI } from '../../../api';
|
import { CredentialTypesAPI, ProjectsAPI, RootAPI } from '../../../api';
|
||||||
|
|
||||||
jest.mock('../../../api');
|
jest.mock('../../../api');
|
||||||
|
|
||||||
@@ -81,6 +81,11 @@ describe('<ProjectForm />', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
await ProjectsAPI.readOptions.mockImplementation(
|
await ProjectsAPI.readOptions.mockImplementation(
|
||||||
() => projectOptionsResolve
|
() => projectOptionsResolve
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'styled-components/macro';
|
import 'styled-components/macro';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useField } from 'formik';
|
import { useField } from 'formik';
|
||||||
import { FormGroup, Alert } from '@patternfly/react-core';
|
import { FormGroup, Alert } from '@patternfly/react-core';
|
||||||
@@ -8,18 +7,14 @@ import { required } from '../../../../util/validators';
|
|||||||
import AnsibleSelect from '../../../../components/AnsibleSelect';
|
import AnsibleSelect from '../../../../components/AnsibleSelect';
|
||||||
import FormField from '../../../../components/FormField';
|
import FormField from '../../../../components/FormField';
|
||||||
import Popover from '../../../../components/Popover';
|
import Popover from '../../../../components/Popover';
|
||||||
import { BrandName } from '../../../../variables';
|
import useBrandName from '../../../../util/useBrandName';
|
||||||
|
|
||||||
// Setting BrandName to a variable here is necessary to get the jest tests
|
|
||||||
// passing. Attempting to use BrandName in the template literal results
|
|
||||||
// in failing tests.
|
|
||||||
const brandName = BrandName;
|
|
||||||
|
|
||||||
const ManualSubForm = ({
|
const ManualSubForm = ({
|
||||||
localPath,
|
localPath,
|
||||||
project_base_dir,
|
project_base_dir,
|
||||||
project_local_paths,
|
project_local_paths,
|
||||||
}) => {
|
}) => {
|
||||||
|
const brandName = useBrandName();
|
||||||
const localPaths = [...new Set([...project_local_paths, localPath])];
|
const localPaths = [...new Set([...project_local_paths, localPath])];
|
||||||
const options = [
|
const options = [
|
||||||
{
|
{
|
||||||
@@ -54,7 +49,7 @@ const ManualSubForm = ({
|
|||||||
Either that directory is empty, or all of the contents are already
|
Either that directory is empty, or all of the contents are already
|
||||||
assigned to other projects. Create a new directory there and make
|
assigned to other projects. Create a new directory there and make
|
||||||
sure the playbook files can be read by the "awx" system user,
|
sure the playbook files can be read by the "awx" system user,
|
||||||
or have ${brandName} directly retrieve your playbooks from
|
or have ${brandName.current} directly retrieve your playbooks from
|
||||||
source control using the Source Control Type option above.`}
|
source control using the Source Control Type option above.`}
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import {
|
import {
|
||||||
Card as _Card,
|
Card as _Card,
|
||||||
@@ -14,14 +13,9 @@ import {
|
|||||||
PageSection,
|
PageSection,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { BrandName } from '../../variables';
|
|
||||||
import { useConfig } from '../../contexts/Config';
|
import { useConfig } from '../../contexts/Config';
|
||||||
import ContentLoading from '../../components/ContentLoading/ContentLoading';
|
import ContentLoading from '../../components/ContentLoading/ContentLoading';
|
||||||
|
import useBrandName from '../../util/useBrandName';
|
||||||
// Setting BrandName to a variable here is necessary to get the jest tests
|
|
||||||
// passing. Attempting to use BrandName in the template literal results
|
|
||||||
// in failing tests.
|
|
||||||
const brandName = BrandName;
|
|
||||||
|
|
||||||
const SplitLayout = styled(PageSection)`
|
const SplitLayout = styled(PageSection)`
|
||||||
column-count: 1;
|
column-count: 1;
|
||||||
@@ -50,10 +44,11 @@ const CardDescription = styled.div`
|
|||||||
|
|
||||||
function SettingList() {
|
function SettingList() {
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
|
const brandName = useBrandName();
|
||||||
const settingRoutes = [
|
const settingRoutes = [
|
||||||
{
|
{
|
||||||
header: t`Authentication`,
|
header: t`Authentication`,
|
||||||
description: t`Enable simplified login for your ${brandName} applications`,
|
description: t`Enable simplified login for your ${brandName.current} applications`,
|
||||||
id: 'authentication',
|
id: 'authentication',
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
@@ -88,7 +83,7 @@ function SettingList() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: t`Jobs`,
|
header: t`Jobs`,
|
||||||
description: t`Update settings pertaining to Jobs within ${brandName}`,
|
description: t`Update settings pertaining to Jobs within ${brandName.current}`,
|
||||||
id: 'jobs',
|
id: 'jobs',
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
mountWithContexts,
|
mountWithContexts,
|
||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../testUtils/enzymeHelpers';
|
} from '../../../testUtils/enzymeHelpers';
|
||||||
import { SettingsAPI } from '../../api';
|
import { SettingsAPI, RootAPI } from '../../api';
|
||||||
import mockAllOptions from './shared/data.allSettingOptions.json';
|
import mockAllOptions from './shared/data.allSettingOptions.json';
|
||||||
import Settings from './Settings';
|
import Settings from './Settings';
|
||||||
|
|
||||||
@@ -19,6 +19,11 @@ describe('<Settings />', () => {
|
|||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
SettingsAPI.readAllOptions.mockResolvedValue({
|
SettingsAPI.readAllOptions.mockResolvedValue({
|
||||||
data: mockAllOptions,
|
data: mockAllOptions,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
JobTemplatesAPI,
|
JobTemplatesAPI,
|
||||||
LabelsAPI,
|
LabelsAPI,
|
||||||
ProjectsAPI,
|
ProjectsAPI,
|
||||||
|
RootAPI,
|
||||||
} from '../../../api';
|
} from '../../../api';
|
||||||
|
|
||||||
jest.mock('../../../api');
|
jest.mock('../../../api');
|
||||||
@@ -67,6 +68,11 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
CredentialsAPI.read.mockResolvedValue({
|
CredentialsAPI.read.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
results: [],
|
results: [],
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
InventoriesAPI,
|
InventoriesAPI,
|
||||||
ExecutionEnvironmentsAPI,
|
ExecutionEnvironmentsAPI,
|
||||||
InstanceGroupsAPI,
|
InstanceGroupsAPI,
|
||||||
|
RootAPI,
|
||||||
} from '../../../api';
|
} from '../../../api';
|
||||||
import JobTemplateEdit from './JobTemplateEdit';
|
import JobTemplateEdit from './JobTemplateEdit';
|
||||||
import useDebounce from '../../../util/useDebounce';
|
import useDebounce from '../../../util/useDebounce';
|
||||||
@@ -27,6 +28,7 @@ jest.mock('../../../api/models/Projects');
|
|||||||
jest.mock('../../../api/models/Inventories');
|
jest.mock('../../../api/models/Inventories');
|
||||||
jest.mock('../../../api/models/ExecutionEnvironments');
|
jest.mock('../../../api/models/ExecutionEnvironments');
|
||||||
jest.mock('../../../api/models/InstanceGroups');
|
jest.mock('../../../api/models/InstanceGroups');
|
||||||
|
jest.mock('../../../api/models/Root');
|
||||||
|
|
||||||
const mockJobTemplate = {
|
const mockJobTemplate = {
|
||||||
allow_callbacks: false,
|
allow_callbacks: false,
|
||||||
@@ -203,6 +205,11 @@ const mockExecutionEnvironment = [
|
|||||||
|
|
||||||
describe('<JobTemplateEdit />', () => {
|
describe('<JobTemplateEdit />', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
JobTemplatesAPI.readCredentials.mockResolvedValue({
|
JobTemplatesAPI.readCredentials.mockResolvedValue({
|
||||||
data: mockRelatedCredentials,
|
data: mockRelatedCredentials,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,11 +13,10 @@ import {
|
|||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import ContentError from '../../../components/ContentError';
|
import ContentError from '../../../components/ContentError';
|
||||||
import ContentLoading from '../../../components/ContentLoading';
|
import ContentLoading from '../../../components/ContentLoading';
|
||||||
import { BrandName } from '../../../variables';
|
|
||||||
import AnsibleSelect from '../../../components/AnsibleSelect';
|
import AnsibleSelect from '../../../components/AnsibleSelect';
|
||||||
import { TagMultiSelect } from '../../../components/MultiSelect';
|
import { TagMultiSelect } from '../../../components/MultiSelect';
|
||||||
import useRequest from '../../../util/useRequest';
|
import useRequest from '../../../util/useRequest';
|
||||||
|
import useBrandName from '../../../util/useBrandName';
|
||||||
import FormActionGroup from '../../../components/FormActionGroup';
|
import FormActionGroup from '../../../components/FormActionGroup';
|
||||||
import FormField, {
|
import FormField, {
|
||||||
CheckboxField,
|
CheckboxField,
|
||||||
@@ -67,6 +66,7 @@ function JobTemplateForm({
|
|||||||
Boolean(template.webhook_service)
|
Boolean(template.webhook_service)
|
||||||
);
|
);
|
||||||
const isMounted = useIsMounted();
|
const isMounted = useIsMounted();
|
||||||
|
const 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({
|
||||||
@@ -567,7 +567,7 @@ function JobTemplateForm({
|
|||||||
|
|
||||||
<Popover
|
<Popover
|
||||||
content={t`Enables creation of a provisioning
|
content={t`Enables creation of a provisioning
|
||||||
callback URL. Using the URL a host can contact ${BrandName}
|
callback URL. Using the URL a host can contact ${brandName.current}
|
||||||
and request a configuration update using this job
|
and request a configuration update using this job
|
||||||
template.`}
|
template.`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
CredentialsAPI,
|
CredentialsAPI,
|
||||||
CredentialTypesAPI,
|
CredentialTypesAPI,
|
||||||
InventoriesAPI,
|
InventoriesAPI,
|
||||||
|
RootAPI,
|
||||||
} from '../../../api';
|
} from '../../../api';
|
||||||
|
|
||||||
jest.mock('../../../api');
|
jest.mock('../../../api');
|
||||||
@@ -95,6 +96,11 @@ describe('<JobTemplateForm />', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
consoleError = global.console.error;
|
consoleError = global.console.error;
|
||||||
global.console.error = jest.fn();
|
global.console.error = jest.fn();
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
LabelsAPI.read.mockReturnValue({
|
LabelsAPI.read.mockReturnValue({
|
||||||
data: mockData.summary_fields.labels,
|
data: mockData.summary_fields.labels,
|
||||||
});
|
});
|
||||||
|
|||||||
19
awx/ui_next/src/util/useBrandName.js
Normal file
19
awx/ui_next/src/util/useBrandName.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
import { RootAPI } from '../api';
|
||||||
|
|
||||||
|
export default function useBrandName() {
|
||||||
|
const brandName = useRef('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function fetchBrandName() {
|
||||||
|
const {
|
||||||
|
data: { BRAND_NAME },
|
||||||
|
} = await RootAPI.readAssetVariables();
|
||||||
|
|
||||||
|
brandName.current = BRAND_NAME;
|
||||||
|
}
|
||||||
|
fetchBrandName();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return brandName;
|
||||||
|
}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
export const BrandName = 'AWX';
|
|
||||||
export const PendoAPIKey = '';
|
|
||||||
Reference in New Issue
Block a user