Skip to content

Commit

Permalink
Merge branch 'chore_release-pd-8.2.0' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader committed Dec 11, 2024
2 parents c932ab3 + 5c411b6 commit b0c8e69
Show file tree
Hide file tree
Showing 21 changed files with 366 additions and 90 deletions.
56 changes: 25 additions & 31 deletions components/src/molecules/DropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ import { Tooltip } from '../../atoms/Tooltip'
import { StyledText } from '../../atoms/StyledText'
import { LiquidIcon } from '../LiquidIcon'

/** this is the max height to display 10 items */
const MAX_HEIGHT = 316

/** this is for adjustment variable for the case that the space of the bottom and the space of the top are very close */
const HEIGHT_ADJUSTMENT = 100

export interface DropdownOption {
name: string
value: string
Expand Down Expand Up @@ -115,34 +109,34 @@ export function DropdownMenu(props: DropdownMenuProps): JSX.Element {

const handlePositionCalculation = (): void => {
const dropdownRect = dropDownMenuWrapperRef.current?.getBoundingClientRect()
if (dropdownRect != null) {
const parentElement = dropDownMenuWrapperRef?.current?.parentElement
const grandParentElement = parentElement?.parentElement?.parentElement
let availableHeight = window.innerHeight
let scrollOffset = 0
if (!dropdownRect) return

const parentElement = dropDownMenuWrapperRef.current?.parentElement
const grandParentElement = parentElement?.parentElement?.parentElement

let availableHeight = window.innerHeight
let scrollOffset = 0

if (grandParentElement) {
const grandParentRect = grandParentElement.getBoundingClientRect()
availableHeight = grandParentRect.bottom - grandParentRect.top
scrollOffset = grandParentRect.top
} else if (parentElement) {
const parentRect = parentElement.getBoundingClientRect()
availableHeight = parentRect.bottom - parentRect.top
scrollOffset = parentRect.top
}

if (grandParentElement != null) {
const grandParentRect = grandParentElement.getBoundingClientRect()
availableHeight = grandParentRect.bottom - grandParentRect.top
scrollOffset = grandParentRect.top
} else if (parentElement != null) {
const parentRect = parentElement.getBoundingClientRect()
availableHeight = parentRect.bottom - parentRect.top
scrollOffset = parentRect.top
}
const dropdownHeight = filterOptions.length * 34 + 10 // note (kk:2024/12/06) need to modify the value since design uses different height in desktop and pd
const dropdownBottom = dropdownRect.bottom + dropdownHeight - scrollOffset

const downSpace =
filterOptions.length + 1 > 10
? MAX_HEIGHT
: (filterOptions.length + 1) * 34
const dropdownBottom = dropdownRect.bottom + downSpace - scrollOffset
const fitsBelow = dropdownBottom <= availableHeight
const fitsAbove = dropdownRect.top - dropdownHeight >= scrollOffset

setDropdownPosition(
dropdownBottom > availableHeight &&
Math.abs(dropdownBottom - availableHeight) > HEIGHT_ADJUSTMENT
? 'top'
: 'bottom'
)
if (menuPlacement === 'auto') {
setDropdownPosition(fitsBelow ? 'bottom' : fitsAbove ? 'top' : 'bottom')
} else {
setDropdownPosition(menuPlacement)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"pauseAction": "untilTime",
"pauseMessage": "",
"pauseTemperature": null,
"pauseTime": "0:1:2",
"pauseTime": "00:01:02",
"id": "5db07ad0-75c7-11ea-b42f-4b64e50f43e5",
"stepType": "pause",
"stepName": "pause",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"pauseAction": "untilTime",
"pauseMessage": "",
"pauseTemperature": null,
"pauseTime": "0:1:2",
"pauseTime": "00:01:02",
"id": "5db07ad0-75c7-11ea-b42f-4b64e50f43e5",
"stepType": "pause",
"stepName": "pause",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"pauseAction": "untilTime",
"pauseMessage": "",
"pauseTemperature": null,
"pauseTime": "0:1:0",
"pauseTime": "00:01:00",
"id": "e3989707-210d-457f-a9bb-a85b3ef9b59c",
"stepType": "pause",
"stepName": "pause",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
"pauseAction": "untilTime",
"pauseMessage": "Delay plz",
"pauseTemperature": null,
"pauseTime": "1:2:3",
"pauseTime": "01:02:03",
"id": "2e622080-92a6-11e9-ac62-1b173f839d9e",
"stepType": "pause",
"stepName": "pause",
Expand Down
1 change: 1 addition & 0 deletions protocol-designer/src/assets/localization/en/shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"destination_well": "Destination Well",
"developer_ff": "Developer Feature Flags",
"done": "Done",
"download_protocol": "Download protocol",
"edit_existing": "Edit existing protocol",
"edit_instruments": "Edit Instruments",
"edit_pipette": "Edit Pipette",
Expand Down
7 changes: 5 additions & 2 deletions protocol-designer/src/load-file/migration/8_2_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ const getTimeFromIndividualUnits = (
minutes: any,
hours?: any
): string => {
const hoursString = hours !== undefined ? `${hours ?? 0}:` : ''
return `${hoursString}${minutes ?? 0}:${seconds ?? 0}`
const pad = (num: number): string => String(num).padStart(2, '0')
const hoursString = hours !== undefined ? `${pad(Number(hours) ?? 0)}:` : ''
return `${hoursString}${pad(Number(minutes) ?? 0)}:${pad(
Number(seconds) ?? 0
)}`
}

export const migrateFile = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,36 @@ export function ToggleExpandStepFormField(
toggleValue,
caption,
toggleElement = 'toggle',
name,
...restProps
} = props

const resetFieldValue = (): void => {
restProps.updateValue(null)
}

// TODO: refactor this, it is messy
const onToggleUpdateValue = (): void => {
if (typeof toggleValue === 'boolean') {
if (toggleValue === 'engage' || toggleValue === 'disengage') {
const newValue = toggleValue === 'engage' ? 'disengage' : 'engage'
toggleUpdateValue(newValue)
} else if (toggleValue === 'true' || toggleValue === 'false') {
const newValue = toggleValue === 'true' ? 'false' : 'true'
toggleUpdateValue(newValue)
if (newValue === 'true') {
resetFieldValue()
}
} else if (toggleValue == null) {
toggleUpdateValue(
name === 'targetTemperature' || name === 'heaterShakerTimer'
? 'true'
: true
)
} else {
toggleUpdateValue(!toggleValue)
if (toggleValue) {
resetFieldValue()
}
} else if (toggleValue === 'engage' || toggleValue === 'disengage') {
const newToggleValue = toggleValue === 'engage' ? 'disengage' : 'engage'
toggleUpdateValue(newToggleValue)
} else if (toggleValue == null) {
toggleUpdateValue(true)
}
}

Expand Down Expand Up @@ -99,6 +111,7 @@ export function ToggleExpandStepFormField(
{isSelected ? (
<InputStepFormField
{...restProps}
name={name}
padding="0"
showTooltip={false}
title={fieldTitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,13 @@ export function DeckSetupTools(props: DeckSetupToolsProps): JSX.Element | null {
)
}
if (
selectedModuleModel == null &&
selectedLabwareDefUri != null &&
(createdLabwareForSlot?.labwareDefURI !== selectedLabwareDefUri ||
(selectedNestedLabwareDefUri != null &&
selectedNestedLabwareDefUri !==
createdNestedLabwareForSlot?.labwareDefURI))
(slot === 'offDeck' && selectedLabwareDefUri != null) ||
(selectedModuleModel == null &&
selectedLabwareDefUri != null &&
(createdLabwareForSlot?.labwareDefURI !== selectedLabwareDefUri ||
(selectedNestedLabwareDefUri != null &&
selectedNestedLabwareDefUri !==
createdNestedLabwareForSlot?.labwareDefURI)))
) {
// create adapter + labware on deck
dispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ export function BatchEditMixTools(props: BatchEditMixToolsProps): JSX.Element {
propsForFields.mix_wellOrder_second.updateValue
}
firstValue={
(propsForFields.mix_wellOrder_first.name ??
(propsForFields.mix_wellOrder_first?.value ??
't2b') as WellOrderOption
}
secondValue={
(propsForFields.mix_wellOrder_second.name ??
(propsForFields.mix_wellOrder_second?.value ??
'l2r') as WellOrderOption
}
firstName="mix_wellOrder_first"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ export function BatchEditMoveLiquidTools(
propsForFields[addFieldNamePrefix('wellOrder_second')].updateValue
}
firstValue={
(propsForFields.wellOrder_first.name ?? 't2b') as WellOrderOption
(propsForFields.wellOrder_first?.value ?? 't2b') as WellOrderOption
}
secondValue={
(propsForFields.wellOrder_second.name ?? 'l2r') as WellOrderOption
(propsForFields.wellOrder_second?.value ?? 'l2r') as WellOrderOption
}
firstName={addFieldNamePrefix('wellOrder_first')}
secondName={addFieldNamePrefix('wellOrder_second')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function HeaterShakerTools(props: StepFormProps): JSX.Element {
'form:step_edit_form.field.heaterShaker.timer.heaterShakerSetTimer'
)}
fieldTitle={t('form:step_edit_form.field.heaterShaker.duration')}
isSelected={formData.heaterShakerSetTimer === true}
isSelected={formData.heaterShakerSetTimer === 'true'}
units={t('application:units.time')}
toggleElement="checkbox"
formLevelError={getFormLevelError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function TemperatureTools(props: StepFormProps): JSX.Element {
title={t('form:step_edit_form.moduleState')}
fieldTitle={t('form:step_edit_form.field.temperature.setTemperature')}
units={t('units.degrees')}
isSelected={formData.setTemperature === true}
isSelected={formData.setTemperature === 'true'}
onLabel={t('form:step_edit_form.field.temperature.toggleOn')}
offLabel={t('form:step_edit_form.field.temperature.toggleOff')}
formLevelError={getFormLevelError(
Expand Down
22 changes: 16 additions & 6 deletions protocol-designer/src/resources/ProtocolDesignerAppFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,33 @@ import { useTranslation } from 'react-i18next'

import type { FallbackProps } from 'react-error-boundary'

import { actions } from '../load-file'
import {
AlertPrimaryButton,
ALIGN_FLEX_END,
DIRECTION_COLUMN,
Flex,
Modal,
SecondaryButton,
SPACING,
StyledText,
} from '@opentrons/components'
import { useDispatch } from 'react-redux'
import type { ThunkDispatch } from '../types'

export function ProtocolDesignerAppFallback({
error,
resetErrorBoundary,
}: FallbackProps): JSX.Element {
const { t } = useTranslation('shared')

const dispatch: ThunkDispatch<any> = useDispatch()
const handleReloadClick = (): void => {
resetErrorBoundary()
}
const handleDownloadProtocol = (): void => {
dispatch(actions.saveProtocolFile())
}

return (
<Modal type="warning" title={t('error_boundary_title')} marginLeft="0">
Expand All @@ -35,12 +43,14 @@ export function ProtocolDesignerAppFallback({
{error.message}
</StyledText>
</Flex>
<AlertPrimaryButton
alignSelf={ALIGN_FLEX_END}
onClick={handleReloadClick}
>
{t('reload_app')}
</AlertPrimaryButton>
<Flex alignSelf={ALIGN_FLEX_END} gridGap={SPACING.spacing8}>
<SecondaryButton onClick={handleDownloadProtocol}>
{t('download_protocol')}
</SecondaryButton>
<AlertPrimaryButton onClick={handleReloadClick}>
{t('reload_app')}
</AlertPrimaryButton>
</Flex>
</Flex>
</Modal>
)
Expand Down
Loading

0 comments on commit b0c8e69

Please sign in to comment.