mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 03:30:02 -03:30
Use FieldTooltip instead of Tooltip component. Remove promptValidate prop from FieldWithPrompt. This checkbox shouldn't ever need a custom validator function.
This commit is contained in:
@@ -1,16 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { bool, func, node, string } from 'prop-types';
|
import { bool, node, string } from 'prop-types';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Tooltip } from '@patternfly/react-core';
|
import { CheckboxField, FieldTooltip } from '@components/FormField';
|
||||||
import { CheckboxField } from '@components/FormField';
|
|
||||||
import { QuestionCircleIcon as PFQuestionCircleIcon } from '@patternfly/react-icons';
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const QuestionCircleIcon = styled(PFQuestionCircleIcon)`
|
|
||||||
margin-left: 10px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const FieldHeader = styled.div`
|
const FieldHeader = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -33,9 +27,7 @@ function FieldWithPrompt({
|
|||||||
label,
|
label,
|
||||||
promptId,
|
promptId,
|
||||||
promptName,
|
promptName,
|
||||||
promptValidate,
|
|
||||||
tooltip,
|
tooltip,
|
||||||
tooltipMaxWidth,
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="pf-c-form__group">
|
<div className="pf-c-form__group">
|
||||||
@@ -49,21 +41,12 @@ function FieldWithPrompt({
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</label>
|
</label>
|
||||||
{tooltip && (
|
{tooltip && <FieldTooltip content={tooltip} />}
|
||||||
<Tooltip
|
|
||||||
content={tooltip}
|
|
||||||
maxWidth={tooltipMaxWidth}
|
|
||||||
position="right"
|
|
||||||
>
|
|
||||||
<QuestionCircleIcon />
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<StyledCheckboxField
|
<StyledCheckboxField
|
||||||
id={promptId}
|
id={promptId}
|
||||||
label={i18n._(t`Prompt On Launch`)}
|
label={i18n._(t`Prompt On Launch`)}
|
||||||
name={promptName}
|
name={promptName}
|
||||||
validate={promptValidate}
|
|
||||||
/>
|
/>
|
||||||
</FieldHeader>
|
</FieldHeader>
|
||||||
{children}
|
{children}
|
||||||
@@ -77,16 +60,12 @@ FieldWithPrompt.propTypes = {
|
|||||||
label: string.isRequired,
|
label: string.isRequired,
|
||||||
promptId: string.isRequired,
|
promptId: string.isRequired,
|
||||||
promptName: string.isRequired,
|
promptName: string.isRequired,
|
||||||
promptValidate: func,
|
|
||||||
tooltip: node,
|
tooltip: node,
|
||||||
tooltipMaxWidth: string,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FieldWithPrompt.defaultProps = {
|
FieldWithPrompt.defaultProps = {
|
||||||
isRequired: false,
|
isRequired: false,
|
||||||
promptValidate: () => {},
|
|
||||||
tooltip: null,
|
tooltip: null,
|
||||||
tooltipMaxWidth: '',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withI18n()(FieldWithPrompt);
|
export default withI18n()(FieldWithPrompt);
|
||||||
|
|||||||
Reference in New Issue
Block a user