Merge pull request #10195 from nixocio/ui_issue_9377

Fix null issue for limit

Fix null issue for limit.
See: #9377

Reviewed-by: Jake McDermott <yo@jakemcdermott.me>
This commit is contained in:
softwarefactory-project-zuul[bot]
2021-05-20 21:33:48 +00:00
committed by GitHub
6 changed files with 12 additions and 6 deletions

View File

@@ -19,7 +19,6 @@ const StyledCheckboxField = styled(CheckboxField)`
function FieldWithPrompt({ function FieldWithPrompt({
children, children,
fieldId, fieldId,
isRequired, isRequired,
label, label,
promptId, promptId,

View File

@@ -118,7 +118,7 @@ function getInitialValues(launchConfig, resource) {
initialValues.job_type = resource?.job_type || ''; initialValues.job_type = resource?.job_type || '';
} }
if (launchConfig.ask_limit_on_launch) { if (launchConfig.ask_limit_on_launch) {
initialValues.limit = resource?.limit || ''; initialValues.limit = resource?.limit || null;
} }
if (launchConfig.ask_verbosity_on_launch) { if (launchConfig.ask_verbosity_on_launch) {
initialValues.verbosity = resource?.verbosity || 0; initialValues.verbosity = resource?.verbosity || 0;

View File

@@ -126,7 +126,7 @@ describe('<WorkflowJobTemplateAdd/>', () => {
description: '', description: '',
extra_vars: '---', extra_vars: '---',
inventory: undefined, inventory: undefined,
limit: '', limit: null,
organization: undefined, organization: undefined,
scm_branch: '', scm_branch: '',
webhook_credential: undefined, webhook_credential: undefined,

View File

@@ -45,6 +45,7 @@ function WorkflowJobTemplateDetail({ template }) {
webhook_credential, webhook_credential,
webhook_key, webhook_key,
scm_branch: scmBranch, scm_branch: scmBranch,
limit,
} = template; } = template;
const urlOrigin = window.location.origin; const urlOrigin = window.location.origin;
@@ -160,6 +161,7 @@ function WorkflowJobTemplateDetail({ template }) {
)} )}
/> />
)} )}
<Detail dataCy="limit" label={t`Limit`} value={limit} />
<Detail <Detail
label={t`Webhook Service`} label={t`Webhook Service`}
value={toTitleCase(template.webhook_service)} value={toTitleCase(template.webhook_service)}

View File

@@ -51,6 +51,7 @@ describe('<WorkflowJobTemplateDetail/>', () => {
webhook_key: 'Foo webhook key', webhook_key: 'Foo webhook key',
execution_environment: 4, execution_environment: 4,
scm_branch: 'main', scm_branch: 'main',
limit: 'servers',
}; };
beforeEach(async () => { beforeEach(async () => {
@@ -115,6 +116,11 @@ describe('<WorkflowJobTemplateDetail/>', () => {
prop: 'value', prop: 'value',
value: 'main', value: 'main',
}, },
{
element: 'Detail[label="Limit"]',
prop: 'value',
value: 'servers',
},
{ {
element: "Detail[label='Webhook Service']", element: "Detail[label='Webhook Service']",
prop: 'value', prop: 'value',

View File

@@ -40,7 +40,6 @@ function WorkflowJobTemplateForm({
template, template,
handleSubmit, handleSubmit,
handleCancel, handleCancel,
submitError, submitError,
isOrgAdmin, isOrgAdmin,
}) { }) {
@@ -167,7 +166,7 @@ function WorkflowJobTemplateForm({
> >
<TextInput <TextInput
id="wfjt-limit" id="wfjt-limit"
{...limitField} value={limitField.value}
validated={ validated={
!limitMeta.touched || !limitMeta.error ? 'default' : 'error' !limitMeta.touched || !limitMeta.error ? 'default' : 'error'
} }
@@ -306,7 +305,7 @@ const FormikApp = withFormik({
organization: template?.summary_fields?.organization || null, organization: template?.summary_fields?.organization || null,
labels: template.summary_fields?.labels?.results || [], labels: template.summary_fields?.labels?.results || [],
extra_vars: template.extra_vars || '---', extra_vars: template.extra_vars || '---',
limit: template.limit || '', limit: template.limit || null,
scm_branch: template.scm_branch || '', scm_branch: template.scm_branch || '',
allow_simultaneous: template.allow_simultaneous || false, allow_simultaneous: template.allow_simultaneous || false,
webhook_credential: template?.summary_fields?.webhook_credential || null, webhook_credential: template?.summary_fields?.webhook_credential || null,