Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(protocol-designer): consolidate CheckboxExapandStepFormFieldProps #17843

Draft
wants to merge 1 commit into
base: edge
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,26 @@
} from '@opentrons/components'

import type { ReactNode } from 'react'
import type { FieldProps } from '../../../pages/Designer/ProtocolSteps/types'

interface CheckboxExpandStepFormFieldProps {
title: string
checkboxUpdateValue: (value: unknown) => void
checkboxValue: unknown
isChecked: boolean
fieldProps: FieldProps
tooltipOverride?: string
children?: ReactNode
tooltipText?: string | null
disabled?: boolean
testId?: string
}
export function CheckboxExpandStepFormField(
props: CheckboxExpandStepFormFieldProps
): JSX.Element {
const { children, title, tooltipOverride, testId, fieldProps } = props

Check warning on line 29 in protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx#L29

Added line #L29 was not covered by tests

const {
checkboxUpdateValue,
checkboxValue,
children,
isChecked,
title,
tooltipText,
value,
updateValue,
tooltipContent = tooltipOverride,

Check warning on line 34 in protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx#L32-L34

Added lines #L32 - L34 were not covered by tests
disabled = false,
testId,
} = props
} = fieldProps

Check warning on line 36 in protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx#L36

Added line #L36 was not covered by tests

const [targetProps, tooltipProps] = useHoverTooltip()
return (
Expand All @@ -48,7 +44,7 @@
disabled={disabled}
onClick={() => {
if (!disabled) {
checkboxUpdateValue(!checkboxValue)
updateValue(!value)

Check warning on line 47 in protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx#L47

Added line #L47 was not covered by tests
}
}}
color={disabled ? COLORS.grey40 : COLORS.black90}
Expand All @@ -69,12 +65,12 @@
<Btn
data-testid={testId}
onClick={() => {
checkboxUpdateValue(!checkboxValue)
updateValue(!value)

Check warning on line 68 in protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx#L68

Added line #L68 was not covered by tests
}}
>
<Check
color={COLORS.blue50}
isChecked={isChecked}
isChecked={value === true}

Check warning on line 73 in protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx#L73

Added line #L73 was not covered by tests
disabled={disabled}
/>
</Btn>
Expand All @@ -83,8 +79,8 @@
{children}
</Flex>
</ListButton>
{tooltipText != null ? (
<Tooltip tooltipProps={tooltipProps}>{tooltipText}</Tooltip>
{tooltipContent != null ? (
<Tooltip tooltipProps={tooltipProps}>{tooltipContent}</Tooltip>

Check warning on line 83 in protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/molecules/CheckboxExpandStepFormField/index.tsx#L82-L83

Added lines #L82 - L83 were not covered by tests
) : null}
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@
t('form:step_edit_form.field.delay.label'),
'capitalize'
)}
checkboxValue={propsForFields[`${tab}_delay_checkbox`].value}
isChecked={propsForFields[`${tab}_delay_checkbox`].value === true}
checkboxUpdateValue={
propsForFields[`${tab}_delay_checkbox`].updateValue
}
fieldProps={propsForFields[`${tab}_delay_checkbox`]}

Check warning on line 130 in protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMixTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMixTools.tsx#L130

Added line #L130 was not covered by tests
>
{propsForFields[`${tab}_delay_checkbox`].value === true ? (
<InputStepFormField
Expand All @@ -150,9 +146,7 @@
t('form:step_edit_form.field.blowout.label'),
'capitalize'
)}
checkboxValue={propsForFields.blowout_checkbox.value}
isChecked={propsForFields.blowout_checkbox.value === true}
checkboxUpdateValue={propsForFields.blowout_checkbox.updateValue}
fieldProps={propsForFields.blowout_checkbox}

Check warning on line 149 in protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMixTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMixTools.tsx#L149

Added line #L149 was not covered by tests
>
{propsForFields.blowout_checkbox.value === true ? (
<BlowoutLocationField
Expand All @@ -169,11 +163,7 @@
t('form:step_edit_form.field.touchTip.label'),
'capitalize'
)}
checkboxValue={propsForFields.mix_touchTip_checkbox.value}
isChecked={propsForFields.mix_touchTip_checkbox.value === true}
checkboxUpdateValue={
propsForFields.mix_touchTip_checkbox.updateValue
}
fieldProps={propsForFields.mix_touchTip_checkbox}

Check warning on line 166 in protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMixTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMixTools.tsx#L166

Added line #L166 was not covered by tests
>
{propsForFields.mix_touchTip_checkbox.value === true ? (
<PositionField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,15 @@
t('form:step_edit_form.field.preWetTip.label'),
'capitalize'
)}
checkboxValue={propsForFields.preWetTip.value}
isChecked={propsForFields.preWetTip.value === true}
checkboxUpdateValue={propsForFields.preWetTip.updateValue}
fieldProps={propsForFields.preWetTip}

Check warning on line 128 in protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMoveLiquidTools.tsx#L128

Added line #L128 was not covered by tests
/>
) : null}
<CheckboxExpandStepFormField
title={i18n.format(
t('form:step_edit_form.field.mix.label'),
'capitalize'
)}
checkboxValue={propsForFields[`${tab}_mix_checkbox`].value}
isChecked={propsForFields[`${tab}_mix_checkbox`].value === true}
checkboxUpdateValue={
propsForFields[`${tab}_mix_checkbox`].updateValue
}
fieldProps={propsForFields[`${tab}_mix_checkbox`]}

Check warning on line 136 in protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMoveLiquidTools.tsx#L136

Added line #L136 was not covered by tests
>
{propsForFields[`${tab}_mix_checkbox`].value === true ? (
<Flex
Expand Down Expand Up @@ -169,11 +163,7 @@
t('form:step_edit_form.field.delay.label'),
'capitalize'
)}
checkboxValue={propsForFields[`${tab}_delay_checkbox`].value}
isChecked={propsForFields[`${tab}_delay_checkbox`].value === true}
checkboxUpdateValue={
propsForFields[`${tab}_delay_checkbox`].updateValue
}
fieldProps={propsForFields[`${tab}_delay_checkbox`]}

Check warning on line 166 in protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMoveLiquidTools.tsx#L166

Added line #L166 was not covered by tests
>
{propsForFields[`${tab}_delay_checkbox`].value === true ? (
<Flex
Expand Down Expand Up @@ -205,9 +195,7 @@
t('form:step_edit_form.field.blowout.label'),
'capitalize'
)}
checkboxValue={propsForFields.blowout_checkbox.value}
isChecked={propsForFields.blowout_checkbox.value === true}
checkboxUpdateValue={propsForFields.blowout_checkbox.updateValue}
fieldProps={propsForFields.blowout_checkbox}

Check warning on line 198 in protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/BatchEditToolbox/BatchEditMoveLiquidTools.tsx#L198

Added line #L198 was not covered by tests
>
{propsForFields.blowout_checkbox.value === true ? (
<Flex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,11 @@
})
: ''

const { value, updateValue } = propsForFields.disposalVolume_checkbox
const { value } = propsForFields.disposalVolume_checkbox

Check warning on line 73 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/PipetteFields/DisposalField.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/PipetteFields/DisposalField.tsx#L73

Added line #L73 was not covered by tests
return (
<CheckboxExpandStepFormField
title={t('protocol_steps:multi_dispense_options')}
checkboxValue={value}
isChecked={value === true}
checkboxUpdateValue={updateValue}
fieldProps={propsForFields.disposalVolume_checkbox}

Check warning on line 77 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/PipetteFields/DisposalField.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/PipetteFields/DisposalField.tsx#L77

Added line #L77 was not covered by tests
>
{value ? (
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing6}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,7 @@
'capitalize'
)}
testId="delay_checkbox"
checkboxValue={propsForFields[`${tab}_delay_checkbox`].value}
isChecked={propsForFields[`${tab}_delay_checkbox`].value === true}
checkboxUpdateValue={
propsForFields[`${tab}_delay_checkbox`].updateValue
}
tooltipText={
propsForFields[`${tab}_delay_checkbox`].tooltipContent ?? null
}
fieldProps={propsForFields[`${tab}_delay_checkbox`]}

Check warning on line 259 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MixTools/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MixTools/index.tsx#L259

Added line #L259 was not covered by tests
>
{formData[`${tab}_delay_checkbox`] === true ? (
<InputStepFormField
Expand All @@ -287,12 +280,7 @@
'capitalize'
)}
testId="blowout_checkbox"
checkboxValue={propsForFields.blowout_checkbox.value}
isChecked={propsForFields.blowout_checkbox.value === true}
checkboxUpdateValue={propsForFields.blowout_checkbox.updateValue}
tooltipText={
propsForFields.blowout_checkbox.tooltipContent ?? null
}
fieldProps={propsForFields.blowout_checkbox}

Check warning on line 283 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MixTools/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MixTools/index.tsx#L283

Added line #L283 was not covered by tests
>
{formData.blowout_checkbox === true ? (
<Flex
Expand Down Expand Up @@ -333,14 +321,7 @@
'capitalize'
)}
testId="touchTip_checkbox"
checkboxValue={propsForFields.mix_touchTip_checkbox.value}
isChecked={propsForFields.mix_touchTip_checkbox.value === true}
checkboxUpdateValue={
propsForFields.mix_touchTip_checkbox.updateValue
}
tooltipText={
propsForFields.mix_touchTip_checkbox.tooltipContent ?? null
}
fieldProps={propsForFields.mix_touchTip_checkbox}

Check warning on line 324 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MixTools/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MixTools/index.tsx#L324

Added line #L324 was not covered by tests
>
{formData.mix_touchTip_checkbox === true ? (
<PositionField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,9 @@
t('form:step_edit_form.field.mix.label'),
'capitalize'
)}
checkboxValue={propsForFields[`${tab}_mix_checkbox`].value}
isChecked={propsForFields[`${tab}_mix_checkbox`].value === true}
checkboxUpdateValue={
propsForFields[`${tab}_mix_checkbox`].updateValue
}
tooltipText={
tab === 'dispense'
? dispenseMixDisabledTooltipText
: propsForFields.aspirate_mix_checkbox.tooltipContent
}
disabled={
tab === 'dispense'
? isDestinationTrash || formData.path === 'multiDispense'
: formData.path === 'multiAspirate'
fieldProps={propsForFields[`${tab}_mix_checkbox`]}
tooltipOverride={
tab === 'dispense' ? dispenseMixDisabledTooltipText : null

Check warning on line 282 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx#L280-L282

Added lines #L280 - L282 were not covered by tests
}
>
{formData[`${tab}_mix_checkbox`] === true ? (
Expand Down Expand Up @@ -330,10 +319,7 @@
t('form:step_edit_form.field.pushOut.title'),
'capitalize'
)}
checkboxValue={propsForFields.pushOut_checkbox.value}
isChecked={propsForFields.pushOut_checkbox.value === true}
checkboxUpdateValue={propsForFields.pushOut_checkbox.updateValue}
tooltipText={propsForFields.pushOut_checkbox.tooltipContent}
fieldProps={propsForFields.pushOut_checkbox}

Check warning on line 322 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx#L322

Added line #L322 was not covered by tests
>
{formData.pushOut_checkbox === true ? (
<InputStepFormField
Expand Down Expand Up @@ -361,12 +347,7 @@
t('form:step_edit_form.field.delay.label'),
'capitalize'
)}
checkboxValue={propsForFields[`${tab}_delay_checkbox`].value}
isChecked={propsForFields[`${tab}_delay_checkbox`].value === true}
checkboxUpdateValue={
propsForFields[`${tab}_delay_checkbox`].updateValue
}
tooltipText={propsForFields[`${tab}_delay_checkbox`].tooltipContent}
fieldProps={propsForFields[`${tab}_delay_checkbox`]}

Check warning on line 350 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx#L350

Added line #L350 was not covered by tests
>
{formData[`${tab}_delay_checkbox`] === true ? (
<Flex
Expand Down Expand Up @@ -394,14 +375,7 @@
t('form:step_edit_form.field.blowout.label'),
'capitalize'
)}
checkboxValue={propsForFields.blowout_checkbox.value}
isChecked={propsForFields.blowout_checkbox.value === true}
checkboxUpdateValue={propsForFields.blowout_checkbox.updateValue}
tooltipText={propsForFields.blowout_checkbox.tooltipContent}
disabled={
formData.path === 'multiDispense' &&
formData.disposalVolume_checkbox
}
fieldProps={propsForFields.blowout_checkbox}

Check warning on line 378 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx#L378

Added line #L378 was not covered by tests
>
{formData.blowout_checkbox === true ? (
<Flex
Expand Down Expand Up @@ -441,15 +415,7 @@
t('form:step_edit_form.field.touchTip.label'),
'capitalize'
)}
checkboxValue={propsForFields[`${tab}_touchTip_checkbox`].value}
isChecked={propsForFields[`${tab}_touchTip_checkbox`].value === true}
checkboxUpdateValue={
propsForFields[`${tab}_touchTip_checkbox`].updateValue
}
tooltipText={
propsForFields[`${tab}_touchTip_checkbox`].tooltipContent
}
disabled={propsForFields[`${tab}_touchTip_checkbox`].disabled}
fieldProps={propsForFields[`${tab}_touchTip_checkbox`]}

Check warning on line 418 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx#L418

Added line #L418 was not covered by tests
>
{formData[`${tab}_touchTip_checkbox`] === true ? (
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing10}>
Expand Down Expand Up @@ -505,12 +471,7 @@
t('form:step_edit_form.field.airGap.label'),
'capitalize'
)}
checkboxValue={propsForFields[`${tab}_airGap_checkbox`].value}
isChecked={propsForFields[`${tab}_airGap_checkbox`].value === true}
checkboxUpdateValue={
propsForFields[`${tab}_airGap_checkbox`].updateValue
}
tooltipText={propsForFields[`${tab}_airGap_checkbox`].tooltipContent}
fieldProps={propsForFields[`${tab}_airGap_checkbox`]}

Check warning on line 474 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/SecondStepsMoveLiquidTools.tsx#L474

Added line #L474 was not covered by tests
>
{formData[`${tab}_airGap_checkbox`] === true ? (
<InputStepFormField
Expand Down
Loading