mirror of
https://github.com/ansible/awx.git
synced 2026-04-06 18:49:21 -02:30
Merge pull request #11168 from AlexSCorey/11103-AllowJinjaOnSettings
Sufrace ALLOW_JINJA_IN_EXTRA_VARS on the job settings page
This commit is contained in:
@@ -30,7 +30,6 @@ function JobsDetail() {
|
|||||||
const { data } = await SettingsAPI.readCategory('jobs');
|
const { data } = await SettingsAPI.readCategory('jobs');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ALLOW_JINJA_IN_EXTRA_VARS,
|
|
||||||
STDOUT_MAX_BYTES_DISPLAY,
|
STDOUT_MAX_BYTES_DISPLAY,
|
||||||
EVENT_STDOUT_MAX_BYTES_DISPLAY,
|
EVENT_STDOUT_MAX_BYTES_DISPLAY,
|
||||||
...jobsData
|
...jobsData
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { useCallback, useEffect } from 'react';
|
import React, { useCallback, useEffect } from 'react';
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { Formik } from 'formik';
|
import { Formik } from 'formik';
|
||||||
import { Form } from '@patternfly/react-core';
|
import { Form } from '@patternfly/react-core';
|
||||||
@@ -18,6 +19,7 @@ import {
|
|||||||
ObjectField,
|
ObjectField,
|
||||||
RevertAllAlert,
|
RevertAllAlert,
|
||||||
RevertFormActionGroup,
|
RevertFormActionGroup,
|
||||||
|
ChoiceField,
|
||||||
} from '../../shared';
|
} from '../../shared';
|
||||||
|
|
||||||
function JobsEdit() {
|
function JobsEdit() {
|
||||||
@@ -34,7 +36,6 @@ function JobsEdit() {
|
|||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const { data } = await SettingsAPI.readCategory('jobs');
|
const { data } = await SettingsAPI.readCategory('jobs');
|
||||||
const {
|
const {
|
||||||
ALLOW_JINJA_IN_EXTRA_VARS,
|
|
||||||
EVENT_STDOUT_MAX_BYTES_DISPLAY,
|
EVENT_STDOUT_MAX_BYTES_DISPLAY,
|
||||||
STDOUT_MAX_BYTES_DISPLAY,
|
STDOUT_MAX_BYTES_DISPLAY,
|
||||||
...jobsData
|
...jobsData
|
||||||
@@ -112,6 +113,23 @@ function JobsEdit() {
|
|||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
// We have to rebuild the ALLOW_JINJA_IN_EXTRA_VARS object because the default value
|
||||||
|
// is 'template' but its label that comes from the api is 'Only On Job Template
|
||||||
|
// Definitions'. The problem is that this label does not match whats in the help
|
||||||
|
// text, or what is rendered on the screen in the details, 'template' is what is
|
||||||
|
// rendered in those locations. For consistency sake I have changed that label
|
||||||
|
// value below.
|
||||||
|
|
||||||
|
const jinja = {
|
||||||
|
default: 'template',
|
||||||
|
help_text: jobs?.ALLOW_JINJA_IN_EXTRA_VARS?.help_text,
|
||||||
|
label: jobs?.ALLOW_JINJA_IN_EXTRA_VARS?.label,
|
||||||
|
};
|
||||||
|
jinja.choices = jobs?.ALLOW_JINJA_IN_EXTRA_VARS?.choices.map(
|
||||||
|
([value, label]) =>
|
||||||
|
value === 'template' ? [value, t`Template`] : [value, label]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardBody>
|
<CardBody>
|
||||||
{isLoading && <ContentLoading />}
|
{isLoading && <ContentLoading />}
|
||||||
@@ -157,6 +175,7 @@ function JobsEdit() {
|
|||||||
config={jobs.MAX_FORKS}
|
config={jobs.MAX_FORKS}
|
||||||
type="number"
|
type="number"
|
||||||
/>
|
/>
|
||||||
|
<ChoiceField name="ALLOW_JINJA_IN_EXTRA_VARS" config={jinja} />
|
||||||
<BooleanField
|
<BooleanField
|
||||||
name="PROJECT_UPDATE_VVV"
|
name="PROJECT_UPDATE_VVV"
|
||||||
config={jobs.PROJECT_UPDATE_VVV}
|
config={jobs.PROJECT_UPDATE_VVV}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ describe('<JobsEdit />', () => {
|
|||||||
});
|
});
|
||||||
expect(SettingsAPI.updateAll).toHaveBeenCalledTimes(1);
|
expect(SettingsAPI.updateAll).toHaveBeenCalledTimes(1);
|
||||||
const {
|
const {
|
||||||
ALLOW_JINJA_IN_EXTRA_VARS,
|
|
||||||
EVENT_STDOUT_MAX_BYTES_DISPLAY,
|
EVENT_STDOUT_MAX_BYTES_DISPLAY,
|
||||||
STDOUT_MAX_BYTES_DISPLAY,
|
STDOUT_MAX_BYTES_DISPLAY,
|
||||||
...jobRequest
|
...jobRequest
|
||||||
|
|||||||
Reference in New Issue
Block a user