Fixes bug where help icon showed up beneath the form label. I believe the labelIcon prop was added in a recent update of PF and is what we should be using.

This commit is contained in:
mabashian
2020-07-23 10:43:10 -04:00
parent 71d3fd3dbc
commit 45286ebf41
20 changed files with 209 additions and 148 deletions

View File

@@ -31,8 +31,10 @@ function FormField(props) {
isRequired={isRequired} isRequired={isRequired}
validated={isValid ? 'default' : 'error'} validated={isValid ? 'default' : 'error'}
label={label} label={label}
labelIcon={
<FieldTooltip content={tooltip} maxWidth={tooltipMaxWidth} />
}
> >
<FieldTooltip content={tooltip} maxWidth={tooltipMaxWidth} />
<TextArea <TextArea
id={id} id={id}
isRequired={isRequired} isRequired={isRequired}
@@ -53,8 +55,10 @@ function FormField(props) {
isRequired={isRequired} isRequired={isRequired}
validated={isValid ? 'default' : 'error'} validated={isValid ? 'default' : 'error'}
label={label} label={label}
labelIcon={
<FieldTooltip content={tooltip} maxWidth={tooltipMaxWidth} />
}
> >
<FieldTooltip content={tooltip} maxWidth={tooltipMaxWidth} />
<TextInput <TextInput
id={id} id={id}
isRequired={isRequired} isRequired={isRequired}

View File

@@ -25,6 +25,13 @@ const InventoryLookupField = withI18n()(({ i18n, host }) => {
return ( return (
<FormGroup <FormGroup
label={i18n._(t`Inventory`)} label={i18n._(t`Inventory`)}
labelIcon={
<FieldTooltip
content={i18n._(
t`Select the inventory that this host will belong to.`
)}
/>
}
isRequired isRequired
fieldId="inventory-lookup" fieldId="inventory-lookup"
validated={ validated={
@@ -32,9 +39,6 @@ const InventoryLookupField = withI18n()(({ i18n, host }) => {
} }
helperTextInvalid={inventoryMeta.error} helperTextInvalid={inventoryMeta.error}
> >
<FieldTooltip
content={i18n._(t`Select the inventory that this host will belong to.`)}
/>
<InventoryLookup <InventoryLookup
value={inventory} value={inventory}
onBlur={() => inventoryHelpers.setTouched()} onBlur={() => inventoryHelpers.setTouched()}

View File

@@ -101,13 +101,15 @@ function JobTypeField({ i18n }) {
<FormGroup <FormGroup
fieldId="propmt-job-type" fieldId="propmt-job-type"
label={i18n._(t`Job Type`)} label={i18n._(t`Job Type`)}
validated={isValid ? 'default' : 'error'} labelIcon={
> <FieldTooltip
<FieldTooltip content={i18n._(t`For job templates, select run to execute the playbook.
content={i18n._(t`For job templates, select run to execute the playbook.
Select check to only check playbook syntax, test environment setup, Select check to only check playbook syntax, test environment setup,
and report problems without executing the playbook.`)} and report problems without executing the playbook.`)}
/> />
}
validated={isValid ? 'default' : 'error'}
>
<AnsibleSelect <AnsibleSelect
id="prompt-job-type" id="prompt-job-type"
data={options} data={options}
@@ -134,11 +136,13 @@ function VerbosityField({ i18n }) {
fieldId="prompt-verbosity" fieldId="prompt-verbosity"
validated={isValid ? 'default' : 'error'} validated={isValid ? 'default' : 'error'}
label={i18n._(t`Verbosity`)} label={i18n._(t`Verbosity`)}
> labelIcon={
<FieldTooltip <FieldTooltip
content={i18n._(t`Control the level of output ansible content={i18n._(t`Control the level of output ansible
will produce as the playbook executes.`)} will produce as the playbook executes.`)}
/> />
}
>
<AnsibleSelect <AnsibleSelect
id="prompt-verbosity" id="prompt-verbosity"
data={options} data={options}
@@ -180,8 +184,11 @@ function ShowChangesToggle({ i18n }) {
function TagField({ id, name, label, tooltip }) { function TagField({ id, name, label, tooltip }) {
const [field, , helpers] = useField(name); const [field, , helpers] = useField(name);
return ( return (
<FormGroup fieldId={id} label={label}> <FormGroup
<FieldTooltip content={tooltip} /> fieldId={id}
label={label}
labelIcon={<FieldTooltip content={tooltip} />}
>
<TagMultiSelect value={field.value} onChange={helpers.setValue} /> <TagMultiSelect value={field.value} onChange={helpers.setValue} />
</FormGroup> </FormGroup>
); );

View File

@@ -98,8 +98,8 @@ function MultipleChoiceField({ question }) {
isRequired={question.required} isRequired={question.required}
validated={isValid ? 'default' : 'error'} validated={isValid ? 'default' : 'error'}
label={question.question_name} label={question.question_name}
labelIcon={<FieldTooltip content={question.question_description} />}
> >
<FieldTooltip content={question.question_description} />
<AnsibleSelect <AnsibleSelect
id={id} id={id}
isValid={isValid} isValid={isValid}
@@ -126,8 +126,8 @@ function MultiSelectField({ question }) {
isRequired={question.required} isRequired={question.required}
validated={isValid ? 'default' : 'error'} validated={isValid ? 'default' : 'error'}
label={question.question_name} label={question.question_name}
labelIcon={<FieldTooltip content={question.question_description} />}
> >
<FieldTooltip content={question.question_description} />
<Select <Select
variant={SelectVariant.typeaheadMulti} variant={SelectVariant.typeaheadMulti}
id={id} id={id}

View File

@@ -86,9 +86,9 @@ function CredentialLookup({
isRequired={required} isRequired={required}
validated={isValid ? 'default' : 'error'} validated={isValid ? 'default' : 'error'}
label={label} label={label}
labelIcon={tooltip && <FieldTooltip content={tooltip} />}
helperTextInvalid={helperTextInvalid} helperTextInvalid={helperTextInvalid}
> >
{tooltip && <FieldTooltip content={tooltip} />}
<Lookup <Lookup
id="credential" id="credential"
header={label} header={label}

View File

@@ -54,9 +54,9 @@ function InstanceGroupsLookup(props) {
<FormGroup <FormGroup
className={className} className={className}
label={i18n._(t`Instance Groups`)} label={i18n._(t`Instance Groups`)}
labelIcon={tooltip && <FieldTooltip content={tooltip} />}
fieldId="org-instance-groups" fieldId="org-instance-groups"
> >
{tooltip && <FieldTooltip content={tooltip} />}
<Lookup <Lookup
id="org-instance-groups" id="org-instance-groups"
header={i18n._(t`Instance Groups`)} header={i18n._(t`Instance Groups`)}

View File

@@ -65,8 +65,8 @@ function ProjectLookup({
isRequired={required} isRequired={required}
validated={isValid ? 'default' : 'error'} validated={isValid ? 'default' : 'error'}
label={i18n._(t`Project`)} label={i18n._(t`Project`)}
labelIcon={tooltip && <FieldTooltip content={tooltip} />}
> >
{tooltip && <FieldTooltip content={tooltip} />}
<Lookup <Lookup
id="project" id="project"
header={i18n._(t`Project`)} header={i18n._(t`Project`)}

View File

@@ -76,12 +76,14 @@ function ApplicationFormFields({
} }
isRequired isRequired
label={i18n._(t`Authorization grant type`)} label={i18n._(t`Authorization grant type`)}
labelIcon={
<FieldTooltip
content={i18n._(
t`The Grant type the user must use for acquire tokens for this application`
)}
/>
}
> >
<FieldTooltip
content={i18n._(
t`The Grant type the user must use for acquire tokens for this application`
)}
/>
<AnsibleSelect <AnsibleSelect
{...authorizationTypeField} {...authorizationTypeField}
isValid={ isValid={
@@ -118,12 +120,14 @@ function ApplicationFormFields({
} }
isRequired isRequired
label={i18n._(t`Client type`)} label={i18n._(t`Client type`)}
labelIcon={
<FieldTooltip
content={i18n._(
t`Set to Public or Confidential depending on how secure the client device is.`
)}
/>
}
> >
<FieldTooltip
content={i18n._(
t`Set to Public or Confidential depending on how secure the client device is.`
)}
/>
<AnsibleSelect <AnsibleSelect
{...clientTypeField} {...clientTypeField}
isValid={!clientTypeMeta.touched || !clientTypeMeta.error} isValid={!clientTypeMeta.touched || !clientTypeMeta.error}

View File

@@ -35,12 +35,14 @@ function BecomeMethodField({ fieldOptions, isRequired }) {
fieldId={`credential-${fieldOptions.id}`} fieldId={`credential-${fieldOptions.id}`}
helperTextInvalid={meta.error} helperTextInvalid={meta.error}
label={fieldOptions.label} label={fieldOptions.label}
labelIcon={
fieldOptions.help_text && (
<FieldTooltip content={fieldOptions.help_text} />
)
}
isRequired={isRequired} isRequired={isRequired}
isValid={!(meta.touched && meta.error)} isValid={!(meta.touched && meta.error)}
> >
{fieldOptions.help_text && (
<FieldTooltip content={fieldOptions.help_text} />
)}
<Select <Select
maxHeight={200} maxHeight={200}
variant={SelectVariant.typeahead} variant={SelectVariant.typeahead}

View File

@@ -126,12 +126,14 @@ function CredentialField({ credentialType, fieldOptions, i18n }) {
fieldId={`credential-${fieldOptions.id}`} fieldId={`credential-${fieldOptions.id}`}
helperTextInvalid={meta.error} helperTextInvalid={meta.error}
label={fieldOptions.label} label={fieldOptions.label}
labelIcon={
fieldOptions.help_text && (
<FieldTooltip content={fieldOptions.help_text} />
)
}
isRequired={isRequired} isRequired={isRequired}
isValid={isValid} isValid={isValid}
> >
{fieldOptions.help_text && (
<FieldTooltip content={fieldOptions.help_text} />
)}
<CredentialInput <CredentialInput
credentialKind={credentialType.kind} credentialKind={credentialType.kind}
fieldOptions={fieldOptions} fieldOptions={fieldOptions}

View File

@@ -127,10 +127,12 @@ function CredentialPluginField(props) {
isRequired={isRequired} isRequired={isRequired}
isValid={isValid} isValid={isValid}
label={fieldOptions.label} label={fieldOptions.label}
labelIcon={
fieldOptions.help_text && (
<FieldTooltip content={fieldOptions.help_text} />
)
}
> >
{fieldOptions.help_text && (
<FieldTooltip content={fieldOptions.help_text} />
)}
<CredentialPluginInput {...props} /> <CredentialPluginInput {...props} />
</FormGroup> </FormGroup>
)} )}

View File

@@ -143,12 +143,14 @@ const InventorySourceFormFields = ({ sourceOptions, i18n }) => {
<FormGroup <FormGroup
fieldId="custom-virtualenv" fieldId="custom-virtualenv"
label={i18n._(t`Ansible Environment`)} label={i18n._(t`Ansible Environment`)}
> labelIcon={
<FieldTooltip <FieldTooltip
content={i18n._(t`Select the custom content={i18n._(t`Select the custom
Python virtual environment for this Python virtual environment for this
inventory source sync to run on.`)} inventory source sync to run on.`)}
/> />
}
>
<AnsibleSelect <AnsibleSelect
id="custom-virtualenv" id="custom-virtualenv"
data={[ data={[

View File

@@ -91,12 +91,14 @@ const SCMSubForm = ({ i18n }) => {
} }
isRequired isRequired
label={i18n._(t`Inventory file`)} label={i18n._(t`Inventory file`)}
> labelIcon={
<FieldTooltip <FieldTooltip
content={i18n._(t`Select the inventory file content={i18n._(t`Select the inventory file
to be synced by this source. You can select from to be synced by this source. You can select from
the dropdown or enter a file within the input.`)} the dropdown or enter a file within the input.`)}
/> />
}
>
<AnsibleSelect <AnsibleSelect
{...sourcePathField} {...sourcePathField}
id="source_path" id="source_path"

View File

@@ -49,17 +49,19 @@ export const RegionsField = withI18n()(({ i18n, regionOptions }) => {
helperTextInvalid={meta.error} helperTextInvalid={meta.error}
validated="default" validated="default"
label={i18n._(t`Regions`)} label={i18n._(t`Regions`)}
labelIcon={
<FieldTooltip
content={
<Trans>
Click on the regions field to see a list of regions for your cloud
provider. You can select multiple regions, or choose
<em> All</em> to include all regions. Only Hosts associated with
the selected regions will be updated.
</Trans>
}
/>
}
> >
<FieldTooltip
content={
<Trans>
Click on the regions field to see a list of regions for your cloud
provider. You can select multiple regions, or choose
<em> All</em> to include all regions. Only Hosts associated with the
selected regions will be updated.
</Trans>
}
/>
<Select <Select
variant={SelectVariant.typeaheadMulti} variant={SelectVariant.typeaheadMulti}
id="regions" id="regions"
@@ -139,56 +141,58 @@ export const GroupByField = withI18n()(
helperTextInvalid={meta.error} helperTextInvalid={meta.error}
validated="default" validated="default"
label={i18n._(t`Only group by`)} label={i18n._(t`Only group by`)}
labelIcon={
<FieldTooltip
content={
<Trans>
Select which groups to create automatically. AWX will create
group names similar to the following examples based on the
options selected:
<br />
<br />
<ul>
<li>
Availability Zone: <strong>zones &raquo; us-east-1b</strong>
</li>
<li>
Image ID: <strong>images &raquo; ami-b007ab1e</strong>
</li>
<li>
Instance ID: <strong>instances &raquo; i-ca11ab1e </strong>
</li>
<li>
Instance Type: <strong>types &raquo; type_m1_medium</strong>
</li>
<li>
Key Name: <strong>keys &raquo; key_testing</strong>
</li>
<li>
Region: <strong>regions &raquo; us-east-1</strong>
</li>
<li>
Security Group:{' '}
<strong>
security_groups &raquo; security_group_default
</strong>
</li>
<li>
Tags: <strong>tags &raquo; tag_Name_host1</strong>
</li>
<li>
VPC ID: <strong>vpcs &raquo; vpc-5ca1ab1e</strong>
</li>
<li>
Tag None: <strong>tags &raquo; tag_none</strong>
</li>
</ul>
<br />
If blank, all groups above are created except{' '}
<em>Instance ID</em>.
</Trans>
}
/>
}
> >
<FieldTooltip
content={
<Trans>
Select which groups to create automatically. AWX will create group
names similar to the following examples based on the options
selected:
<br />
<br />
<ul>
<li>
Availability Zone: <strong>zones &raquo; us-east-1b</strong>
</li>
<li>
Image ID: <strong>images &raquo; ami-b007ab1e</strong>
</li>
<li>
Instance ID: <strong>instances &raquo; i-ca11ab1e </strong>
</li>
<li>
Instance Type: <strong>types &raquo; type_m1_medium</strong>
</li>
<li>
Key Name: <strong>keys &raquo; key_testing</strong>
</li>
<li>
Region: <strong>regions &raquo; us-east-1</strong>
</li>
<li>
Security Group:{' '}
<strong>
security_groups &raquo; security_group_default
</strong>
</li>
<li>
Tags: <strong>tags &raquo; tag_Name_host1</strong>
</li>
<li>
VPC ID: <strong>vpcs &raquo; vpc-5ca1ab1e</strong>
</li>
<li>
Tag None: <strong>tags &raquo; tag_none</strong>
</li>
</ul>
<br />
If blank, all groups above are created except <em>Instance ID</em>
.
</Trans>
}
/>
<Select <Select
variant={SelectVariant.typeaheadMulti} variant={SelectVariant.typeaheadMulti}
id="group-by" id="group-by"
@@ -231,11 +235,13 @@ export const VerbosityField = withI18n()(({ i18n }) => {
fieldId="verbosity" fieldId="verbosity"
validated={isValid ? 'default' : 'error'} validated={isValid ? 'default' : 'error'}
label={i18n._(t`Verbosity`)} label={i18n._(t`Verbosity`)}
> labelIcon={
<FieldTooltip <FieldTooltip
content={i18n._(t`Control the level of output Ansible content={i18n._(t`Control the level of output Ansible
will produce for inventory source update jobs.`)} will produce for inventory source update jobs.`)}
/> />
}
>
<AnsibleSelect <AnsibleSelect
id="verbosity" id="verbosity"
data={options} data={options}

View File

@@ -259,11 +259,13 @@ function ProjectFormFields({
<FormGroup <FormGroup
fieldId="project-custom-virtualenv" fieldId="project-custom-virtualenv"
label={i18n._(t`Ansible Environment`)} label={i18n._(t`Ansible Environment`)}
> labelIcon={
<FieldTooltip <FieldTooltip
content={i18n._(t`Select the playbook to be executed by content={i18n._(t`Select the playbook to be executed by
this job.`)} this job.`)}
/> />
}
>
<AnsibleSelect <AnsibleSelect
id="project-custom-virtualenv" id="project-custom-virtualenv"
data={[ data={[

View File

@@ -83,12 +83,14 @@ const ManualSubForm = ({
isRequired isRequired
validated={!pathMeta.touched || !pathMeta.error ? 'default' : 'error'} validated={!pathMeta.touched || !pathMeta.error ? 'default' : 'error'}
label={i18n._(t`Playbook Directory`)} label={i18n._(t`Playbook Directory`)}
> labelIcon={
<FieldTooltip <FieldTooltip
content={i18n._(t`Select from the list of directories found in content={i18n._(t`Select from the list of directories found in
the Project Base Path. Together the base path and the playbook the Project Base Path. Together the base path and the playbook
directory provide the full path used to locate playbooks.`)} directory provide the full path used to locate playbooks.`)}
/> />
}
>
<AnsibleSelect <AnsibleSelect
{...pathField} {...pathField}
id="local_path" id="local_path"

View File

@@ -29,16 +29,18 @@ function AnswerTypeField({ i18n }) {
return ( return (
<FormGroup <FormGroup
label={i18n._(t`Answer Type`)} label={i18n._(t`Answer Type`)}
labelIcon={
<FieldTooltip
content={i18n._(
t`Choose an answer type or format you want as the prompt for the user.
Refer to the Ansible Tower Documentation for more additional
information about each option.`
)}
/>
}
isRequired isRequired
fieldId="question-answer-type" fieldId="question-answer-type"
> >
<FieldTooltip
content={i18n._(
t`Choose an answer type or format you want as the prompt for the user.
Refer to the Ansible Tower Documentation for more additional
information about each option.`
)}
/>
<AnsibleSelect <AnsibleSelect
id="question-type" id="question-type"
{...field} {...field}

View File

@@ -298,10 +298,14 @@ function JobTemplateForm({
} }
isRequired isRequired
label={i18n._(t`Playbook`)} label={i18n._(t`Playbook`)}
labelIcon={
<FieldTooltip
content={i18n._(
t`Select the playbook to be executed by this job.`
)}
/>
}
> >
<FieldTooltip
content={i18n._(t`Select the playbook to be executed by this job.`)}
/>
<PlaybookSelect <PlaybookSelect
projectId={projectField.value?.id} projectId={projectField.value?.id}
isValid={!playbookMeta.touched || !playbookMeta.error} isValid={!playbookMeta.touched || !playbookMeta.error}
@@ -330,12 +334,17 @@ function JobTemplateForm({
onError={setContentError} onError={setContentError}
/> />
</FieldWithPrompt> </FieldWithPrompt>
<FormGroup label={i18n._(t`Labels`)} fieldId="template-labels"> <FormGroup
<FieldTooltip label={i18n._(t`Labels`)}
content={i18n._(t`Optional labels that describe this job template, labelIcon={
<FieldTooltip
content={i18n._(t`Optional labels that describe this job template,
such as 'dev' or 'test'. Labels can be used to group and filter such as 'dev' or 'test'. Labels can be used to group and filter
job templates and completed jobs.`)} job templates and completed jobs.`)}
/> />
}
fieldId="template-labels"
>
<LabelSelect <LabelSelect
value={labelsField.value} value={labelsField.value}
onChange={labels => labelsHelpers.setValue(labels)} onChange={labels => labelsHelpers.setValue(labels)}

View File

@@ -126,8 +126,10 @@ function WebhookSubForm({ i18n, templateType }) {
fieldId="webhook_service" fieldId="webhook_service"
helperTextInvalid={webhookServiceMeta.error} helperTextInvalid={webhookServiceMeta.error}
label={i18n._(t`Webhook Service`)} label={i18n._(t`Webhook Service`)}
labelIcon={
<FieldTooltip content={i18n._(t`Select a webhook service.`)} />
}
> >
<FieldTooltip content={i18n._(t`Select a webhook service.`)} />
<AnsibleSelect <AnsibleSelect
{...webhookServiceField} {...webhookServiceField}
id="webhook_service" id="webhook_service"
@@ -162,13 +164,15 @@ function WebhookSubForm({ i18n, templateType }) {
type="text" type="text"
fieldId="jt-webhookURL" fieldId="jt-webhookURL"
label={i18n._(t`Webhook URL`)} label={i18n._(t`Webhook URL`)}
labelIcon={
<FieldTooltip
content={i18n._(
t`Webhook services can launch jobs with this workflow job template by making a POST request to this URL.`
)}
/>
}
name="webhook_url" name="webhook_url"
> >
<FieldTooltip
content={i18n._(
t`Webhook services can launch jobs with this workflow job template by making a POST request to this URL.`
)}
/>
<TextInput <TextInput
id="t-webhookURL" id="t-webhookURL"
aria-label={i18n._(t`Webhook URL`)} aria-label={i18n._(t`Webhook URL`)}
@@ -178,13 +182,15 @@ function WebhookSubForm({ i18n, templateType }) {
</FormGroup> </FormGroup>
<FormGroup <FormGroup
label={i18n._(t`Webhook Key`)} label={i18n._(t`Webhook Key`)}
labelIcon={
<FieldTooltip
content={i18n._(
t`Webhook services can use this as a shared secret.`
)}
/>
}
fieldId="template-webhook_key" fieldId="template-webhook_key"
> >
<FieldTooltip
content={i18n._(
t`Webhook services can use this as a shared secret.`
)}
/>
<InputGroup> <InputGroup>
<TextInput <TextInput
id="template-webhook_key" id="template-webhook_key"

View File

@@ -157,12 +157,17 @@ function WorkflowJobTemplateForm({
</FieldWithPrompt> </FieldWithPrompt>
</FormColumnLayout> </FormColumnLayout>
<FormFullWidthLayout> <FormFullWidthLayout>
<FormGroup label={i18n._(t`Labels`)} fieldId="template-labels"> <FormGroup
<FieldTooltip label={i18n._(t`Labels`)}
content={i18n._(t`Optional labels that describe this job template, labelIcon={
<FieldTooltip
content={i18n._(t`Optional labels that describe this job template,
such as 'dev' or 'test'. Labels can be used to group and filter such as 'dev' or 'test'. Labels can be used to group and filter
job templates and completed jobs.`)} job templates and completed jobs.`)}
/> />
}
fieldId="template-labels"
>
<LabelSelect <LabelSelect
value={labelsField.value} value={labelsField.value}
onChange={labels => labelsHelpers.setValue(labels)} onChange={labels => labelsHelpers.setValue(labels)}