1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-28 02:25:27 +03:00

Making verbosity list and options a constant and adding WinRM debug to everything

This commit is contained in:
John Westcott IV 2022-06-14 17:16:12 -04:00
parent 31d8ddcf84
commit 21bed7473d
11 changed files with 33 additions and 85 deletions

View File

@ -14,6 +14,8 @@ import ErrorDetail from '../ErrorDetail';
import AdHocCommandsWizard from './AdHocCommandsWizard';
import ContentError from '../ContentError';
import { VERBOSE_OPTIONS } from '../../constants';
function AdHocCommands({
adHocItems,
hasListItems,
@ -26,13 +28,6 @@ function AdHocCommands({
const [isWizardOpen, setIsWizardOpen] = useState(false);
const { isKebabified, onKebabModalChange } = useContext(KebabifiedContext);
const verbosityOptions = [
{ value: '0', key: '0', label: t`0 (Normal)` },
{ value: '1', key: '1', label: t`1 (Verbose)` },
{ value: '2', key: '2', label: t`2 (More Verbose)` },
{ value: '3', key: '3', label: t`3 (Debug)` },
{ value: '4', key: '4', label: t`4 (Connection Debug)` },
];
useEffect(() => {
if (isKebabified) {
onKebabModalChange(isWizardOpen);
@ -159,7 +154,7 @@ function AdHocCommands({
adHocItems={adHocItems}
organizationId={organizationId}
moduleOptions={moduleOptions}
verbosityOptions={verbosityOptions}
verbosityOptions={VERBOSE_OPTIONS}
credentialTypeId={credentialTypeId}
onCloseWizard={() => setIsWizardOpen(false)}
onLaunch={handleSubmit}

View File

@ -6,6 +6,7 @@ import {
waitForElement,
} from '../../../testUtils/enzymeHelpers';
import AdHocCommandsWizard from './AdHocCommandsWizard';
import { VERBOSE_OPTIONS } from '../../constants';
jest.mock('../../api/models/CredentialTypes');
jest.mock('../../api/models/Inventories');
@ -13,13 +14,6 @@ jest.mock('../../api/models/Credentials');
jest.mock('../../api/models/ExecutionEnvironments');
jest.mock('../../api/models/Root');
const verbosityOptions = [
{ value: '0', key: '0', label: '0 (Normal)' },
{ value: '1', key: '1', label: '1 (Verbose)' },
{ value: '2', key: '2', label: '2 (More Verbose)' },
{ value: '3', key: '3', label: '3 (Debug)' },
{ value: '4', key: '4', label: '4 (Connection Debug)' },
];
const moduleOptions = [
['command', 'command'],
['shell', 'shell'],
@ -44,7 +38,7 @@ describe('<AdHocCommandsWizard/>', () => {
adHocItems={adHocItems}
onLaunch={onLaunch}
moduleOptions={moduleOptions}
verbosityOptions={verbosityOptions}
verbosityOptions={VERBOSE_OPTIONS}
onCloseWizard={() => {}}
credentialTypeId={1}
organizationId={1}

View File

@ -9,6 +9,7 @@ import { TagMultiSelect } from '../../MultiSelect';
import AnsibleSelect from '../../AnsibleSelect';
import { VariablesField } from '../../CodeEditor';
import Popover from '../../Popover';
import { VERBOSE_OPTIONS } from '../../../constants';
const FieldHeader = styled.div`
display: flex;
@ -130,14 +131,6 @@ function JobTypeField() {
function VerbosityField() {
const [field, meta, helpers] = useField('verbosity');
const options = [
{ value: '0', key: '0', label: t`0 (Normal)` },
{ value: '1', key: '1', label: t`1 (Verbose)` },
{ value: '2', key: '2', label: t`2 (More Verbose)` },
{ value: '3', key: '3', label: t`3 (Debug)` },
{ value: '4', key: '4', label: t`4 (Connection Debug)` },
];
const isValid = !(meta.touched && meta.error);
return (
@ -154,7 +147,7 @@ function VerbosityField() {
>
<AnsibleSelect
id="prompt-verbosity"
data={options}
data={VERBOSE_OPTIONS}
{...field}
onChange={(event, value) => helpers.setValue(value)}
/>

View File

@ -14,6 +14,7 @@ import PromptProjectDetail from './PromptProjectDetail';
import PromptInventorySourceDetail from './PromptInventorySourceDetail';
import PromptJobTemplateDetail from './PromptJobTemplateDetail';
import PromptWFJobTemplateDetail from './PromptWFJobTemplateDetail';
import { VERBOSITY } from '../../constants';
const PromptTitle = styled(Title)`
margin-top: var(--pf-global--spacer--xl);
@ -93,14 +94,6 @@ function PromptDetail({
overrides = {},
workflowNode = false,
}) {
const VERBOSITY = {
0: t`0 (Normal)`,
1: t`1 (Verbose)`,
2: t`2 (More Verbose)`,
3: t`3 (Debug)`,
4: t`4 (Connection Debug)`,
};
const details = omitOverrides(resource, overrides, launchConfig.defaults);
details.type = overrides?.nodeType || details.type;
const hasOverrides = Object.keys(overrides).length > 0;

View File

@ -13,6 +13,7 @@ import { VariablesDetail } from '../CodeEditor';
import CredentialChip from '../CredentialChip';
import ChipGroup from '../ChipGroup';
import ExecutionEnvironmentDetail from '../ExecutionEnvironmentDetail';
import { VERBOSITY } from '../../constants';
function PromptInventorySourceDetail({ resource }) {
const {
@ -32,14 +33,6 @@ function PromptInventorySourceDetail({ resource }) {
verbosity,
} = resource;
const VERBOSITY = {
0: t`0 (Normal)`,
1: t`1 (Verbose)`,
2: t`2 (More Verbose)`,
3: t`3 (Debug)`,
4: t`4 (Connection Debug)`,
};
let optionsList = '';
if (
overwrite ||

View File

@ -15,6 +15,7 @@ import Sparkline from '../Sparkline';
import { Detail, DeletedDetail } from '../DetailList';
import { VariablesDetail } from '../CodeEditor';
import ExecutionEnvironmentDetail from '../ExecutionEnvironmentDetail';
import { VERBOSITY } from '../../constants';
function PromptJobTemplateDetail({ resource }) {
const {
@ -42,14 +43,6 @@ function PromptJobTemplateDetail({ resource }) {
custom_virtualenv,
} = resource;
const VERBOSITY = {
0: t`0 (Normal)`,
1: t`1 (Verbose)`,
2: t`2 (More Verbose)`,
3: t`3 (Debug)`,
4: t`4 (Connection Debug)`,
};
let optionsList = '';
if (
become_enabled ||

View File

@ -23,6 +23,7 @@ import DeleteButton from '../../DeleteButton';
import ErrorDetail from '../../ErrorDetail';
import ChipGroup from '../../ChipGroup';
import { VariablesDetail } from '../../CodeEditor';
import { VERBOSITY } from '../../../constants';
const PromptDivider = styled(Divider)`
margin-top: var(--pf-global--spacer--lg);
@ -67,14 +68,6 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, surveyConfig }) {
const { pathname } = useLocation();
const pathRoot = pathname.substr(0, pathname.indexOf('schedules'));
const VERBOSITY = {
0: t`0 (Normal)`,
1: t`1 (Verbose)`,
2: t`2 (More Verbose)`,
3: t`3 (Debug)`,
4: t`4 (Connection Debug)`,
};
const {
request: deleteSchedule,
isLoading: isDeleteLoading,

View File

@ -1,3 +1,5 @@
import { t } from '@lingui/macro';
/* eslint-disable-next-line import/prefer-default-export */
export const JOB_TYPE_URL_SEGMENTS = {
job: 'playbook',
@ -12,3 +14,18 @@ export const SESSION_TIMEOUT_KEY = 'awx-session-timeout';
export const SESSION_REDIRECT_URL = 'awx-redirect-url';
export const PERSISTENT_FILTER_KEY = 'awx-persistent-filter';
export const SESSION_USER_ID = 'awx-session-user-id';
export const VERBOSITY = {
0: t`0 (Normal)`,
1: t`1 (Verbose)`,
2: t`2 (More Verbose)`,
3: t`3 (Debug)`,
4: t`4 (Connection Debug)`,
5: t`5 (WinRM Debug)`,
};
export const VERBOSE_OPTIONS = Object.entries(VERBOSITY).map(([k, v]) => ({
key: k,
value: k,
label: v,
}));

View File

@ -28,6 +28,7 @@ import ExecutionEnvironmentDetail from 'components/ExecutionEnvironmentDetail';
import { getJobModel, isJobRunning } from 'util/jobs';
import { formatDateString } from 'util/dates';
import { Job } from 'types';
import { VERBOSITY } from '../../../constants';
import jobHelpText from '../Job.helptext';
const StatusDetailValue = styled.div`
@ -37,14 +38,6 @@ const StatusDetailValue = styled.div`
grid-template-columns: auto auto;
`;
const VERBOSITY = {
0: '0 (Normal)',
1: '1 (Verbose)',
2: '2 (More Verbose)',
3: '3 (Debug)',
4: '4 (Connection Debug)',
};
function JobDetail({ job, inventorySourceLabels }) {
const { me } = useConfig();
const {

View File

@ -33,6 +33,7 @@ import useRequest, { useDismissableError } from 'hooks/useRequest';
import useBrandName from 'hooks/useBrandName';
import ExecutionEnvironmentDetail from 'components/ExecutionEnvironmentDetail';
import { relatedResourceDeleteRequests } from 'util/getRelatedResourceDeleteDetails';
import { VERBOSITY } from '../../../constants';
import helpText from '../shared/JobTemplate.helptext';
function JobTemplateDetail({ template }) {
@ -104,17 +105,6 @@ function JobTemplateDetail({ template }) {
relatedResourceDeleteRequests.template(template);
const canLaunch =
summary_fields.user_capabilities && summary_fields.user_capabilities.start;
const verbosityOptions = [
{ verbosity: 0, details: t`0 (Normal)` },
{ verbosity: 1, details: t`1 (Verbose)` },
{ verbosity: 2, details: t`2 (More Verbose)` },
{ verbosity: 3, details: t`3 (Debug)` },
{ verbosity: 4, details: t`4 (Connection Debug)` },
{ verbosity: 5, details: t`5 (WinRM Debug)` },
];
const verbosityDetails = verbosityOptions.filter(
(option) => option.verbosity === verbosity
);
const generateCallBackUrl = `${window.location.origin + url}callback/`;
const renderOptionsField =
become_enabled ||
@ -272,7 +262,7 @@ function JobTemplateDetail({ template }) {
/>
<Detail
label={t`Verbosity`}
value={verbosityDetails[0].details}
value={VERBOSITY[verbosity]}
dataCy="jt-detail-verbosity"
helpText={helpText.verbosity}
/>

View File

@ -46,6 +46,7 @@ import LabelSelect from 'components/LabelSelect';
import PlaybookSelect from './PlaybookSelect';
import WebhookSubForm from './WebhookSubForm';
import helpText from './JobTemplate.helptext';
import { VERBOSE_OPTIONS } from '../../../constants';
const { origin } = document.location;
@ -215,13 +216,6 @@ function JobTemplateForm({
isDisabled: false,
},
];
const verbosityOptions = [
{ value: '0', key: '0', label: t`0 (Normal)` },
{ value: '1', key: '1', label: t`1 (Verbose)` },
{ value: '2', key: '2', label: t`2 (More Verbose)` },
{ value: '3', key: '3', label: t`3 (Debug)` },
{ value: '4', key: '4', label: t`4 (Connection Debug)` },
];
let callbackUrl;
if (template?.related) {
const path = template.related.callback || `${template.url}callback`;
@ -437,7 +431,7 @@ function JobTemplateForm({
>
<AnsibleSelect
id="template-verbosity"
data={verbosityOptions}
data={VERBOSE_OPTIONS}
{...verbosityField}
/>
</FieldWithPrompt>