Adds Variables detail to node view when node is a system job template

This commit is contained in:
mabashian
2021-07-01 11:17:46 -04:00
parent d7521efc91
commit 034c665c83
2 changed files with 137 additions and 119 deletions

View File

@@ -1,18 +1,15 @@
import 'styled-components/macro';
import React from 'react';
import { shape } from 'prop-types';
import { t, Trans } from '@lingui/macro';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
import { Chip, Divider, Title } from '@patternfly/react-core';
import { toTitleCase } from 'util/strings';
import CredentialChip from '../CredentialChip';
import ChipGroup from '../ChipGroup';
import { DetailList, Detail, UserDateDetail } from '../DetailList';
import { VariablesDetail } from '../CodeEditor';
import PromptProjectDetail from './PromptProjectDetail';
import PromptInventorySourceDetail from './PromptInventorySourceDetail';
import PromptJobTemplateDetail from './PromptJobTemplateDetail';
@@ -139,9 +136,19 @@ function PromptDetail({ resource, launchConfig = {}, overrides = {} }) {
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>
{hasPromptData(launchConfig) && hasOverrides && (
{details?.type !== 'system_job_template' &&
hasPromptData(launchConfig) &&
hasOverrides && (
<>
<PromptTitle headingLevel="h2">{t`Prompted Values`}</PromptTitle>
<PromptDivider />
@@ -174,7 +181,10 @@ function PromptDetail({ resource, launchConfig = {}, overrides = {} }) {
/>
)}
{launchConfig.ask_inventory_on_launch && (
<Detail label={t`Inventory`} value={overrides.inventory?.name} />
<Detail
label={t`Inventory`}
value={overrides.inventory?.name}
/>
)}
{launchConfig.ask_scm_branch_on_launch && (
<Detail

View File

@@ -136,7 +136,11 @@ function NodeViewModal({ readOnly }) {
if (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(
JSON.stringify(promptValues.extra_data)
);
@@ -150,7 +154,11 @@ function NodeViewModal({ readOnly }) {
if (launchConfig.ask_scm_branch_on_launch) {
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(
JSON.stringify(originalNodeObject.extra_data)
);