mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Adds Variables detail to node view when node is a system job template
This commit is contained in:
@@ -1,18 +1,15 @@
|
|||||||
import 'styled-components/macro';
|
import 'styled-components/macro';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shape } from 'prop-types';
|
import { shape } from 'prop-types';
|
||||||
|
|
||||||
import { t, Trans } from '@lingui/macro';
|
import { t, Trans } from '@lingui/macro';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Chip, Divider, Title } from '@patternfly/react-core';
|
import { Chip, Divider, Title } from '@patternfly/react-core';
|
||||||
import { toTitleCase } from 'util/strings';
|
import { toTitleCase } from 'util/strings';
|
||||||
|
|
||||||
import CredentialChip from '../CredentialChip';
|
import CredentialChip from '../CredentialChip';
|
||||||
import ChipGroup from '../ChipGroup';
|
import ChipGroup from '../ChipGroup';
|
||||||
import { DetailList, Detail, UserDateDetail } from '../DetailList';
|
import { DetailList, Detail, UserDateDetail } from '../DetailList';
|
||||||
import { VariablesDetail } from '../CodeEditor';
|
import { VariablesDetail } from '../CodeEditor';
|
||||||
|
|
||||||
import PromptProjectDetail from './PromptProjectDetail';
|
import PromptProjectDetail from './PromptProjectDetail';
|
||||||
import PromptInventorySourceDetail from './PromptInventorySourceDetail';
|
import PromptInventorySourceDetail from './PromptInventorySourceDetail';
|
||||||
import PromptJobTemplateDetail from './PromptJobTemplateDetail';
|
import PromptJobTemplateDetail from './PromptJobTemplateDetail';
|
||||||
@@ -139,123 +136,136 @@ function PromptDetail({ resource, launchConfig = {}, overrides = {} }) {
|
|||||||
user={details?.summary_fields?.modified_by}
|
user={details?.summary_fields?.modified_by}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{details?.type === 'system_job_template' && (
|
||||||
|
<VariablesDetail
|
||||||
|
label={t`Variables`}
|
||||||
|
rows={4}
|
||||||
|
value={overrides.extra_vars}
|
||||||
|
name="extra_vars"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</DetailList>
|
</DetailList>
|
||||||
|
|
||||||
{hasPromptData(launchConfig) && hasOverrides && (
|
{details?.type !== 'system_job_template' &&
|
||||||
<>
|
hasPromptData(launchConfig) &&
|
||||||
<PromptTitle headingLevel="h2">{t`Prompted Values`}</PromptTitle>
|
hasOverrides && (
|
||||||
<PromptDivider />
|
<>
|
||||||
<PromptDetailList aria-label={t`Prompt Overrides`}>
|
<PromptTitle headingLevel="h2">{t`Prompted Values`}</PromptTitle>
|
||||||
{launchConfig.ask_job_type_on_launch && (
|
<PromptDivider />
|
||||||
<Detail
|
<PromptDetailList aria-label={t`Prompt Overrides`}>
|
||||||
label={t`Job Type`}
|
{launchConfig.ask_job_type_on_launch && (
|
||||||
value={toTitleCase(overrides.job_type)}
|
<Detail
|
||||||
/>
|
label={t`Job Type`}
|
||||||
)}
|
value={toTitleCase(overrides.job_type)}
|
||||||
{launchConfig.ask_credential_on_launch && (
|
/>
|
||||||
<Detail
|
)}
|
||||||
fullWidth
|
{launchConfig.ask_credential_on_launch && (
|
||||||
label={t`Credentials`}
|
<Detail
|
||||||
rows={4}
|
fullWidth
|
||||||
value={
|
label={t`Credentials`}
|
||||||
<ChipGroup
|
rows={4}
|
||||||
numChips={5}
|
value={
|
||||||
totalChips={overrides.credentials.length}
|
<ChipGroup
|
||||||
>
|
numChips={5}
|
||||||
{overrides.credentials.map((cred) => (
|
totalChips={overrides.credentials.length}
|
||||||
<CredentialChip
|
>
|
||||||
key={cred.id}
|
{overrides.credentials.map((cred) => (
|
||||||
credential={cred}
|
<CredentialChip
|
||||||
isReadOnly
|
key={cred.id}
|
||||||
/>
|
credential={cred}
|
||||||
))}
|
isReadOnly
|
||||||
</ChipGroup>
|
/>
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{launchConfig.ask_inventory_on_launch && (
|
|
||||||
<Detail label={t`Inventory`} value={overrides.inventory?.name} />
|
|
||||||
)}
|
|
||||||
{launchConfig.ask_scm_branch_on_launch && (
|
|
||||||
<Detail
|
|
||||||
label={t`Source Control Branch`}
|
|
||||||
value={overrides.scm_branch}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{launchConfig.ask_limit_on_launch && (
|
|
||||||
<Detail label={t`Limit`} value={overrides.limit} />
|
|
||||||
)}
|
|
||||||
{Object.prototype.hasOwnProperty.call(overrides, 'verbosity') &&
|
|
||||||
launchConfig.ask_verbosity_on_launch ? (
|
|
||||||
<Detail
|
|
||||||
label={t`Verbosity`}
|
|
||||||
value={VERBOSITY[overrides.verbosity]}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{launchConfig.ask_tags_on_launch && (
|
|
||||||
<Detail
|
|
||||||
fullWidth
|
|
||||||
label={t`Job Tags`}
|
|
||||||
value={
|
|
||||||
<ChipGroup
|
|
||||||
numChips={5}
|
|
||||||
totalChips={
|
|
||||||
!overrides.job_tags || overrides.job_tags === ''
|
|
||||||
? 0
|
|
||||||
: overrides.job_tags.split(',').length
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{overrides.job_tags.length > 0 &&
|
|
||||||
overrides.job_tags.split(',').map((jobTag) => (
|
|
||||||
<Chip key={jobTag} isReadOnly>
|
|
||||||
{jobTag}
|
|
||||||
</Chip>
|
|
||||||
))}
|
))}
|
||||||
</ChipGroup>
|
</ChipGroup>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{launchConfig.ask_skip_tags_on_launch && (
|
{launchConfig.ask_inventory_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
fullWidth
|
label={t`Inventory`}
|
||||||
label={t`Skip Tags`}
|
value={overrides.inventory?.name}
|
||||||
value={
|
/>
|
||||||
<ChipGroup
|
)}
|
||||||
numChips={5}
|
{launchConfig.ask_scm_branch_on_launch && (
|
||||||
totalChips={
|
<Detail
|
||||||
!overrides.skip_tags || overrides.skip_tags === ''
|
label={t`Source Control Branch`}
|
||||||
? 0
|
value={overrides.scm_branch}
|
||||||
: overrides.skip_tags.split(',').length
|
/>
|
||||||
}
|
)}
|
||||||
>
|
{launchConfig.ask_limit_on_launch && (
|
||||||
{overrides.skip_tags.length > 0 &&
|
<Detail label={t`Limit`} value={overrides.limit} />
|
||||||
overrides.skip_tags.split(',').map((skipTag) => (
|
)}
|
||||||
<Chip key={skipTag} isReadOnly>
|
{Object.prototype.hasOwnProperty.call(overrides, 'verbosity') &&
|
||||||
{skipTag}
|
launchConfig.ask_verbosity_on_launch ? (
|
||||||
</Chip>
|
<Detail
|
||||||
))}
|
label={t`Verbosity`}
|
||||||
</ChipGroup>
|
value={VERBOSITY[overrides.verbosity]}
|
||||||
}
|
/>
|
||||||
/>
|
) : null}
|
||||||
)}
|
{launchConfig.ask_tags_on_launch && (
|
||||||
{launchConfig.ask_diff_mode_on_launch && (
|
<Detail
|
||||||
<Detail
|
fullWidth
|
||||||
label={t`Show Changes`}
|
label={t`Job Tags`}
|
||||||
value={overrides.diff_mode === true ? t`On` : t`Off`}
|
value={
|
||||||
/>
|
<ChipGroup
|
||||||
)}
|
numChips={5}
|
||||||
{(launchConfig.survey_enabled ||
|
totalChips={
|
||||||
launchConfig.ask_variables_on_launch) && (
|
!overrides.job_tags || overrides.job_tags === ''
|
||||||
<VariablesDetail
|
? 0
|
||||||
label={t`Variables`}
|
: overrides.job_tags.split(',').length
|
||||||
rows={4}
|
}
|
||||||
value={overrides.extra_vars}
|
>
|
||||||
name="extra_vars"
|
{overrides.job_tags.length > 0 &&
|
||||||
/>
|
overrides.job_tags.split(',').map((jobTag) => (
|
||||||
)}
|
<Chip key={jobTag} isReadOnly>
|
||||||
</PromptDetailList>
|
{jobTag}
|
||||||
</>
|
</Chip>
|
||||||
)}
|
))}
|
||||||
|
</ChipGroup>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{launchConfig.ask_skip_tags_on_launch && (
|
||||||
|
<Detail
|
||||||
|
fullWidth
|
||||||
|
label={t`Skip Tags`}
|
||||||
|
value={
|
||||||
|
<ChipGroup
|
||||||
|
numChips={5}
|
||||||
|
totalChips={
|
||||||
|
!overrides.skip_tags || overrides.skip_tags === ''
|
||||||
|
? 0
|
||||||
|
: overrides.skip_tags.split(',').length
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{overrides.skip_tags.length > 0 &&
|
||||||
|
overrides.skip_tags.split(',').map((skipTag) => (
|
||||||
|
<Chip key={skipTag} isReadOnly>
|
||||||
|
{skipTag}
|
||||||
|
</Chip>
|
||||||
|
))}
|
||||||
|
</ChipGroup>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{launchConfig.ask_diff_mode_on_launch && (
|
||||||
|
<Detail
|
||||||
|
label={t`Show Changes`}
|
||||||
|
value={overrides.diff_mode === true ? t`On` : t`Off`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(launchConfig.survey_enabled ||
|
||||||
|
launchConfig.ask_variables_on_launch) && (
|
||||||
|
<VariablesDetail
|
||||||
|
label={t`Variables`}
|
||||||
|
rows={4}
|
||||||
|
value={overrides.extra_vars}
|
||||||
|
name="extra_vars"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</PromptDetailList>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,11 @@ function NodeViewModal({ readOnly }) {
|
|||||||
if (promptValues) {
|
if (promptValues) {
|
||||||
overrides = promptValues;
|
overrides = promptValues;
|
||||||
|
|
||||||
if (launchConfig.ask_variables_on_launch || launchConfig.survey_enabled) {
|
if (
|
||||||
|
launchConfig.ask_variables_on_launch ||
|
||||||
|
launchConfig.survey_enabled ||
|
||||||
|
fullUnifiedJobTemplate.type === 'system_job_template'
|
||||||
|
) {
|
||||||
overrides.extra_vars = jsonToYaml(
|
overrides.extra_vars = jsonToYaml(
|
||||||
JSON.stringify(promptValues.extra_data)
|
JSON.stringify(promptValues.extra_data)
|
||||||
);
|
);
|
||||||
@@ -150,7 +154,11 @@ function NodeViewModal({ readOnly }) {
|
|||||||
if (launchConfig.ask_scm_branch_on_launch) {
|
if (launchConfig.ask_scm_branch_on_launch) {
|
||||||
overrides.scm_branch = originalNodeObject.scm_branch;
|
overrides.scm_branch = originalNodeObject.scm_branch;
|
||||||
}
|
}
|
||||||
if (launchConfig.ask_variables_on_launch || launchConfig.survey_enabled) {
|
if (
|
||||||
|
launchConfig.ask_variables_on_launch ||
|
||||||
|
launchConfig.survey_enabled ||
|
||||||
|
fullUnifiedJobTemplate.type === 'system_job_template'
|
||||||
|
) {
|
||||||
overrides.extra_vars = jsonToYaml(
|
overrides.extra_vars = jsonToYaml(
|
||||||
JSON.stringify(originalNodeObject.extra_data)
|
JSON.stringify(originalNodeObject.extra_data)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user