mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 09:18:48 -03:30
Update label and display of "Last gathered entries..." setting
This commit is contained in:
@@ -687,7 +687,7 @@ register(
|
|||||||
register(
|
register(
|
||||||
'AUTOMATION_ANALYTICS_LAST_ENTRIES',
|
'AUTOMATION_ANALYTICS_LAST_ENTRIES',
|
||||||
field_class=fields.CharField,
|
field_class=fields.CharField,
|
||||||
label=_('Last gathered entries for expensive collectors for Insights for Ansible Automation Platform.'),
|
label=_('Last gathered entries from the data collection service of Insights for Ansible Automation Platform'),
|
||||||
default='',
|
default='',
|
||||||
allow_blank=True,
|
allow_blank=True,
|
||||||
category=_('System'),
|
category=_('System'),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { Button } from '@patternfly/react-core';
|
import { Button } from '@patternfly/react-core';
|
||||||
import { CaretLeftIcon } from '@patternfly/react-icons';
|
import { CaretLeftIcon } from '@patternfly/react-icons';
|
||||||
import { CardBody, CardActionsRow } from 'components/Card';
|
import { CardBody, CardActionsRow } from 'components/Card';
|
||||||
|
import CodeDetail from 'components/DetailList/CodeDetail';
|
||||||
import ContentError from 'components/ContentError';
|
import ContentError from 'components/ContentError';
|
||||||
import ContentLoading from 'components/ContentLoading';
|
import ContentLoading from 'components/ContentLoading';
|
||||||
import { DetailList } from 'components/DetailList';
|
import { DetailList } from 'components/DetailList';
|
||||||
@@ -14,7 +15,11 @@ import useRequest from 'hooks/useRequest';
|
|||||||
import { useConfig } from 'contexts/Config';
|
import { useConfig } from 'contexts/Config';
|
||||||
import { useSettings } from 'contexts/Settings';
|
import { useSettings } from 'contexts/Settings';
|
||||||
import { SettingDetail } from '../../shared';
|
import { SettingDetail } from '../../shared';
|
||||||
import { sortNestedDetails, pluck } from '../../shared/settingUtils';
|
import {
|
||||||
|
formatJson,
|
||||||
|
pluck,
|
||||||
|
sortNestedDetails,
|
||||||
|
} from '../../shared/settingUtils';
|
||||||
|
|
||||||
function MiscSystemDetail() {
|
function MiscSystemDetail() {
|
||||||
const { me } = useConfig();
|
const { me } = useConfig();
|
||||||
@@ -62,7 +67,12 @@ function MiscSystemDetail() {
|
|||||||
const mergedData = {};
|
const mergedData = {};
|
||||||
Object.keys(systemData).forEach((key) => {
|
Object.keys(systemData).forEach((key) => {
|
||||||
mergedData[key] = options[key];
|
mergedData[key] = options[key];
|
||||||
mergedData[key].value = systemData[key];
|
|
||||||
|
if (key === 'AUTOMATION_ANALYTICS_LAST_ENTRIES') {
|
||||||
|
mergedData[key].value = formatJson(systemData[key]) ?? '';
|
||||||
|
} else {
|
||||||
|
mergedData[key].value = systemData[key];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return sortNestedDetails(mergedData);
|
return sortNestedDetails(mergedData);
|
||||||
}, [options]),
|
}, [options]),
|
||||||
@@ -91,6 +101,11 @@ function MiscSystemDetail() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Display this detail in a code editor for readability
|
||||||
|
if (options?.AUTOMATION_ANALYTICS_LAST_ENTRIES) {
|
||||||
|
options.AUTOMATION_ANALYTICS_LAST_ENTRIES.type = 'nested object';
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RoutedTabs tabsArray={tabsArray} />
|
<RoutedTabs tabsArray={tabsArray} />
|
||||||
@@ -99,17 +114,36 @@ function MiscSystemDetail() {
|
|||||||
{!isLoading && error && <ContentError error={error} />}
|
{!isLoading && error && <ContentError error={error} />}
|
||||||
{!isLoading && system && (
|
{!isLoading && system && (
|
||||||
<DetailList>
|
<DetailList>
|
||||||
{system.map(([key, detail]) => (
|
{system.map(([key, detail]) => {
|
||||||
<SettingDetail
|
if (key === 'AUTOMATION_ANALYTICS_LAST_ENTRIES') {
|
||||||
key={key}
|
return (
|
||||||
id={key}
|
<CodeDetail
|
||||||
helpText={detail?.help_text}
|
key={key}
|
||||||
label={detail?.label}
|
dataCy={key}
|
||||||
type={detail?.type}
|
helpText={detail?.help_text}
|
||||||
unit={detail?.unit}
|
label={detail?.label}
|
||||||
value={detail?.value}
|
mode="javascript"
|
||||||
/>
|
rows={4}
|
||||||
))}
|
value={
|
||||||
|
detail?.value
|
||||||
|
? JSON.stringify(detail.value, undefined, 2)
|
||||||
|
: ''
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<SettingDetail
|
||||||
|
key={key}
|
||||||
|
id={key}
|
||||||
|
helpText={detail?.help_text}
|
||||||
|
label={detail?.label}
|
||||||
|
type={detail?.type}
|
||||||
|
unit={detail?.unit}
|
||||||
|
value={detail?.value}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</DetailList>
|
</DetailList>
|
||||||
)}
|
)}
|
||||||
{me?.is_superuser && (
|
{me?.is_superuser && (
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ describe('<MiscSystemDetail />', () => {
|
|||||||
CUSTOM_VENV_PATHS: [],
|
CUSTOM_VENV_PATHS: [],
|
||||||
INSIGHTS_TRACKING_STATE: false,
|
INSIGHTS_TRACKING_STATE: false,
|
||||||
AUTOMATION_ANALYTICS_LAST_GATHER: null,
|
AUTOMATION_ANALYTICS_LAST_GATHER: null,
|
||||||
AUTOMATION_ANALYTICS_LAST_ENTRIES: 'foo',
|
AUTOMATION_ANALYTICS_LAST_ENTRIES:
|
||||||
|
'{"foo": "2021-11-24R06:35:15.179Z"}',
|
||||||
AUTOMATION_ANALYTICS_GATHER_INTERVAL: 14400,
|
AUTOMATION_ANALYTICS_GATHER_INTERVAL: 14400,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -80,11 +81,6 @@ describe('<MiscSystemDetail />', () => {
|
|||||||
'Unique identifier for an installation',
|
'Unique identifier for an installation',
|
||||||
'db39b9ec-0c6e-4554-987d-42aw9c732ed8'
|
'db39b9ec-0c6e-4554-987d-42aw9c732ed8'
|
||||||
);
|
);
|
||||||
assertDetail(
|
|
||||||
wrapper,
|
|
||||||
'Last gathered entries for expensive collectors for Insights for Ansible Automation Platform.',
|
|
||||||
'foo'
|
|
||||||
);
|
|
||||||
assertDetail(wrapper, 'All Users Visible to Organization Admins', 'On');
|
assertDetail(wrapper, 'All Users Visible to Organization Admins', 'On');
|
||||||
assertDetail(
|
assertDetail(
|
||||||
wrapper,
|
wrapper,
|
||||||
@@ -113,6 +109,11 @@ describe('<MiscSystemDetail />', () => {
|
|||||||
assertDetail(wrapper, 'Red Hat customer username', 'name1');
|
assertDetail(wrapper, 'Red Hat customer username', 'name1');
|
||||||
assertDetail(wrapper, 'Red Hat or Satellite password', 'Encrypted');
|
assertDetail(wrapper, 'Red Hat or Satellite password', 'Encrypted');
|
||||||
assertDetail(wrapper, 'Red Hat or Satellite username', 'name2');
|
assertDetail(wrapper, 'Red Hat or Satellite username', 'name2');
|
||||||
|
assertVariableDetail(
|
||||||
|
wrapper,
|
||||||
|
'Last gathered entries from the data collection service of Insights for Ansible Automation Platform',
|
||||||
|
'{\n "foo": "2021-11-24R06:35:15.179Z"\n}'
|
||||||
|
);
|
||||||
assertVariableDetail(wrapper, 'Remote Host Headers', '[]');
|
assertVariableDetail(wrapper, 'Remote Host Headers', '[]');
|
||||||
assertVariableDetail(wrapper, 'Proxy IP Allowed List', '[]');
|
assertVariableDetail(wrapper, 'Proxy IP Allowed List', '[]');
|
||||||
assertDetail(wrapper, 'Global default execution environment', 'Foo');
|
assertDetail(wrapper, 'Global default execution environment', 'Foo');
|
||||||
|
|||||||
@@ -222,9 +222,10 @@ function MiscSystemEdit() {
|
|||||||
type="number"
|
type="number"
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
<InputField
|
<ObjectField
|
||||||
name="AUTOMATION_ANALYTICS_LAST_ENTRIES"
|
name="AUTOMATION_ANALYTICS_LAST_ENTRIES"
|
||||||
config={system.AUTOMATION_ANALYTICS_LAST_ENTRIES}
|
config={system.AUTOMATION_ANALYTICS_LAST_ENTRIES}
|
||||||
|
revertValue={system.AUTOMATION_ANALYTICS_LAST_ENTRIES.default}
|
||||||
/>
|
/>
|
||||||
<ObjectField
|
<ObjectField
|
||||||
name="REMOTE_HOST_HEADERS"
|
name="REMOTE_HOST_HEADERS"
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ TextAreaField.propTypes = {
|
|||||||
config: shape({}).isRequired,
|
config: shape({}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ObjectField = ({ name, config, isRequired = false }) => {
|
const ObjectField = ({ name, config, revertValue, isRequired = false }) => {
|
||||||
const validate = isRequired ? required(null) : null;
|
const validate = isRequired ? required(null) : null;
|
||||||
const [field, meta, helpers] = useField({ name, validate });
|
const [field, meta, helpers] = useField({ name, validate });
|
||||||
const isValid = !(meta.touched && meta.error);
|
const isValid = !(meta.touched && meta.error);
|
||||||
@@ -446,7 +446,7 @@ const ObjectField = ({ name, config, isRequired = false }) => {
|
|||||||
return config ? (
|
return config ? (
|
||||||
<FormFullWidthLayout>
|
<FormFullWidthLayout>
|
||||||
<SettingGroup
|
<SettingGroup
|
||||||
defaultValue={defaultRevertValue}
|
defaultValue={revertValue ?? defaultRevertValue}
|
||||||
fieldId={name}
|
fieldId={name}
|
||||||
helperTextInvalid={meta.error}
|
helperTextInvalid={meta.error}
|
||||||
isRequired={isRequired}
|
isRequired={isRequired}
|
||||||
|
|||||||
@@ -575,7 +575,7 @@
|
|||||||
"AUTOMATION_ANALYTICS_LAST_ENTRIES": {
|
"AUTOMATION_ANALYTICS_LAST_ENTRIES": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": false,
|
"required": false,
|
||||||
"label": "Last gathered entries for expensive collectors for Insights for Ansible Automation Platform.",
|
"label": "Last gathered entries from the data collection service of Insights for Ansible Automation Platform",
|
||||||
"category": "System",
|
"category": "System",
|
||||||
"category_slug": "system",
|
"category_slug": "system",
|
||||||
"default": ""
|
"default": ""
|
||||||
@@ -4208,7 +4208,7 @@
|
|||||||
},
|
},
|
||||||
"AUTOMATION_ANALYTICS_LAST_ENTRIES": {
|
"AUTOMATION_ANALYTICS_LAST_ENTRIES": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"label": "Last gathered entries for expensive collectors for Insights for Ansible Automation Platform.",
|
"label": "Last gathered entries from the data collection service of Insights for Ansible Automation Platform",
|
||||||
"category": "System",
|
"category": "System",
|
||||||
"category_slug": "system",
|
"category_slug": "system",
|
||||||
"defined_in_file": false
|
"defined_in_file": false
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ export {
|
|||||||
ChoiceField,
|
ChoiceField,
|
||||||
EncryptedField,
|
EncryptedField,
|
||||||
ExecutionEnvField,
|
ExecutionEnvField,
|
||||||
|
InputAlertField,
|
||||||
InputField,
|
InputField,
|
||||||
ObjectField,
|
ObjectField,
|
||||||
InputAlertField,
|
TextAreaField,
|
||||||
} from './SharedFields';
|
} from './SharedFields';
|
||||||
|
|||||||
Reference in New Issue
Block a user