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
commit b771929b6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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