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

feat(components): migrate LocationIcon to DeckInfoLabel #15846

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -2,7 +2,7 @@ import * as React from 'react'
import { css } from 'styled-components'

import {
LocationIcon,
DeckInfoLabel,
Flex,
Icon,
COLORS,
Expand All @@ -15,14 +15,14 @@ import {
} from '@opentrons/components'
import { Divider } from '../../../atoms/structure/Divider'

import type { LocationIconProps } from '@opentrons/components'
import type { DeckInfoLabelProps } from '@opentrons/components'

export interface InterventionInfoProps {
type: 'location-arrow-location' | 'location-colon-location' | 'location'
labwareName: string
labwareNickname?: string
currentLocationProps: LocationIconProps
newLocationProps?: LocationIconProps
currentLocationProps: DeckInfoLabelProps
newLocationProps?: DeckInfoLabelProps
}

export function InterventionInfo(props: InterventionInfoProps): JSX.Element {
Expand Down Expand Up @@ -96,9 +96,9 @@ const buildLocArrowLoc = (props: InterventionInfoProps): JSX.Element => {
}
`}
>
<LocationIcon {...currentLocationProps} />
<DeckInfoLabel {...currentLocationProps} />
<Icon name="arrow-right" css={ICON_STYLE} />
<LocationIcon {...newLocationProps} />
<DeckInfoLabel {...newLocationProps} />
</Flex>
)
} else {
Expand All @@ -111,7 +111,7 @@ const buildLoc = ({
}: InterventionInfoProps): JSX.Element => {
return (
<Flex gridGap={SPACING.spacing8}>
<LocationIcon {...currentLocationProps} />
<DeckInfoLabel {...currentLocationProps} />
</Flex>
)
}
Expand All @@ -130,9 +130,9 @@ const buildLocColonLoc = (props: InterventionInfoProps): JSX.Element => {
}
`}
>
<LocationIcon {...currentLocationProps} />
<DeckInfoLabel {...currentLocationProps} />
<Icon name="colon" css={ICON_STYLE} />
<LocationIcon {...newLocationProps} />
<DeckInfoLabel {...newLocationProps} />
</Flex>
)
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/Devices/HistoricalProtocolRunDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
BORDERS,
Box,
COLORS,
DeckInfoLabel,
DIRECTION_COLUMN,
Flex,
Icon,
InfoScreen,
JUSTIFY_FLEX_START,
LegacyStyledText,
Link,
LocationIcon,
OVERFLOW_HIDDEN,
SPACING,
TYPOGRAPHY,
Expand Down Expand Up @@ -272,7 +272,7 @@ export function HistoricalProtocolRunDrawer(
gridGap={SPACING.spacing4}
alignItems={ALIGN_CENTER}
>
<LocationIcon slotName={offset.location.slotName} />
<DeckInfoLabel deckLabel={offset.location.slotName} />
<LegacyStyledText as="p">
{offset.location.moduleModel != null
? getModuleDisplayName(offset.location.moduleModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
ALIGN_CENTER,
BORDERS,
Btn,
LocationIcon,
COLORS,
DeckInfoLabel,
DIRECTION_COLUMN,
DIRECTION_ROW,
DISPLAY_FLEX,
Expand Down Expand Up @@ -272,7 +272,7 @@ export function LabwareListItem(
<LabwareRow>
<Flex alignItems={ALIGN_CENTER} width="80px" gridGap={SPACING.spacing2}>
{slotInfo != null && isFlex ? (
<LocationIcon slotName={slotInfo} />
<DeckInfoLabel deckLabel={slotInfo} />
) : (
<StyledText
css={TYPOGRAPHY.pSemiBold}
Expand All @@ -282,7 +282,7 @@ export function LabwareListItem(
</StyledText>
)}
{nestedLabwareInfo != null || moduleDisplayName != null ? (
<LocationIcon iconName="stacked" />
<DeckInfoLabel iconName="stacked" />
) : null}
</Flex>
<Flex
Expand Down Expand Up @@ -342,7 +342,7 @@ export function LabwareListItem(
>
<Flex gridGap={SPACING.spacing12} alignItems={ALIGN_CENTER}>
{moduleType != null ? (
<LocationIcon
<DeckInfoLabel
iconName={MODULE_ICON_NAME_BY_TYPE[moduleType]}
/>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('LabwareListItem', () => {
})
screen.getByText('Mock Labware Definition')
screen.getByTestId('slot_info_7')
screen.getByTestId('LocationIcon_stacked')
screen.getByTestId('DeckInfoLabel_stacked')
screen.getByText('Magnetic Module GEN1')
const button = screen.getByText('Secure labware instructions')
fireEvent.click(button)
Expand Down Expand Up @@ -207,7 +207,7 @@ describe('LabwareListItem', () => {
})
screen.getByText('Mock Labware Definition')
screen.getByTestId('slot_info_7')
screen.getByTestId('LocationIcon_stacked')
screen.getByTestId('DeckInfoLabel_stacked')
screen.getByText('Temperature Module GEN1')
screen.getByText('nickName')
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function LeftColumnLabwareInfo({
type,
labwareName: failedLabwareName ?? '',
labwareNickname: failedLabwareNickname ?? '',
currentLocationProps: { slotName: buildLabwareLocationSlotName() },
currentLocationProps: { deckLabel: buildLabwareLocationSlotName() },
}}
notificationProps={
bannerText ? { type: 'alert', heading: bannerText } : undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('LeftColumnLabwareInfo', () => {
expect.objectContaining({
type: 'location',
labwareName: 'MOCK_LW_NAME',
currentLocationProps: { slotName: 'A1' },
currentLocationProps: { deckLabel: 'A1' },
}),
{}
)
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('LeftColumnLabwareInfo', () => {

expect(vi.mocked(InterventionInfo)).toHaveBeenCalledWith(
expect.objectContaining({
currentLocationProps: { slotName: '' },
currentLocationProps: { deckLabel: '' },
}),
{}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
BORDERS,
Box,
COLORS,
DeckInfoLabel,
DIRECTION_COLUMN,
DISPLAY_NONE,
Flex,
Icon,
LabwareRender,
LocationIcon,
Module,
MoveLabwareOnDeck,
RESPONSIVENESS,
Expand Down Expand Up @@ -256,11 +256,11 @@ function LabwareDisplayLocation(
let displayLocation: React.ReactNode = ''
if (location === 'offDeck') {
// TODO(BC, 08/28/23): remove this string cast after update i18next to >23 (see https://www.i18next.com/overview/typescript#argument-of-type-defaulttfuncreturn-is-not-assignable-to-parameter-of-type-xyz)
displayLocation = <LocationIcon slotName={String(t('offdeck'))} />
displayLocation = <DeckInfoLabel deckLabel={String(t('offdeck'))} />
} else if ('slotName' in location) {
displayLocation = <LocationIcon slotName={location.slotName} />
displayLocation = <DeckInfoLabel deckLabel={location.slotName} />
} else if ('addressableAreaName' in location) {
displayLocation = <LocationIcon slotName={location.addressableAreaName} />
displayLocation = <DeckInfoLabel deckLabel={location.addressableAreaName} />
} else if ('moduleId' in location) {
const moduleModel = getModuleModelFromRunData(
protocolData,
Expand Down
6 changes: 3 additions & 3 deletions app/src/organisms/LabwarePositionCheck/ResultsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {
ALIGN_FLEX_END,
BORDERS,
COLORS,
DeckInfoLabel,
DIRECTION_COLUMN,
Flex,
Icon,
JUSTIFY_SPACE_BETWEEN,
LocationIcon,
MODULE_ICON_NAME_BY_TYPE,
OVERFLOW_AUTO,
PrimaryButton,
Expand Down Expand Up @@ -373,9 +373,9 @@ export const TerseOffsetTable = (props: OffsetTableProps): JSX.Element => {
return (
<TerseTableRow key={index}>
<TerseTableDatum>
<LocationIcon slotName={location.slotName} />
<DeckInfoLabel deckLabel={location.slotName} />
{location.moduleModel != null ? (
<LocationIcon
<DeckInfoLabel
iconName={
MODULE_ICON_NAME_BY_TYPE[
getModuleType(location.moduleModel)
Expand Down
32 changes: 17 additions & 15 deletions app/src/organisms/ProtocolSetupLabware/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
BORDERS,
Box,
COLORS,
DeckInfoLabel,
DIRECTION_COLUMN,
DIRECTION_ROW,
Flex,
Icon,
JUSTIFY_SPACE_BETWEEN,
JUSTIFY_SPACE_EVENLY,
LabwareRender,
LocationIcon,
MODULE_ICON_NAME_BY_TYPE,
SPACING,
LegacyStyledText,
Expand Down Expand Up @@ -147,14 +147,16 @@ export function ProtocolSetupLabware({
typeof selectedLabware.location === 'object' &&
'slotName' in selectedLabware?.location
) {
location = <LocationIcon slotName={selectedLabware?.location.slotName} />
location = <DeckInfoLabel deckLabel={selectedLabware?.location.slotName} />
} else if (
selectedLabware != null &&
typeof selectedLabware.location === 'object' &&
'addressableAreaName' in selectedLabware?.location
) {
location = (
<LocationIcon slotName={selectedLabware?.location.addressableAreaName} />
<DeckInfoLabel
deckLabel={selectedLabware?.location.addressableAreaName}
/>
)
} else if (
selectedLabware != null &&
Expand All @@ -170,8 +172,8 @@ export function ProtocolSetupLabware({
if (matchedModule != null) {
location = (
<>
<LocationIcon slotName={matchedModule?.slotName} />
<LocationIcon
<DeckInfoLabel deckLabel={matchedModule?.slotName} />
<DeckInfoLabel
iconName={
MODULE_ICON_NAME_BY_TYPE[matchedModule?.moduleDef.moduleType]
}
Expand All @@ -192,16 +194,16 @@ export function ProtocolSetupLabware({
)?.params.location
if (adapterLocation != null && adapterLocation !== 'offDeck') {
if ('slotName' in adapterLocation) {
location = <LocationIcon slotName={adapterLocation.slotName} />
location = <DeckInfoLabel deckLabel={adapterLocation.slotName} />
} else if ('moduleId' in adapterLocation) {
const moduleUnderAdapter = attachedProtocolModuleMatches.find(
module => module.moduleId === adapterLocation.moduleId
)
if (moduleUnderAdapter != null) {
location = (
<>
<LocationIcon slotName={moduleUnderAdapter.slotName} />
<LocationIcon
<DeckInfoLabel deckLabel={moduleUnderAdapter.slotName} />
<DeckInfoLabel
iconName={
MODULE_ICON_NAME_BY_TYPE[
moduleUnderAdapter.moduleDef.moduleType
Expand Down Expand Up @@ -510,16 +512,16 @@ function RowLabware({
location = t('off_deck')
} else if ('slotName' in initialLocation) {
slotName = initialLocation.slotName
location = <LocationIcon slotName={initialLocation.slotName} />
location = <DeckInfoLabel deckLabel={initialLocation.slotName} />
} else if ('addressableAreaName' in initialLocation) {
slotName = initialLocation.addressableAreaName
location = <LocationIcon slotName={initialLocation.addressableAreaName} />
location = <DeckInfoLabel deckLabel={initialLocation.addressableAreaName} />
} else if (matchedModuleType != null && matchedModule?.slotName != null) {
slotName = matchedModule.slotName
location = (
<>
<LocationIcon slotName={matchedModule?.slotName} />
<LocationIcon iconName={MODULE_ICON_NAME_BY_TYPE[matchedModuleType]} />
<DeckInfoLabel deckLabel={matchedModule?.slotName} />
<DeckInfoLabel iconName={MODULE_ICON_NAME_BY_TYPE[matchedModuleType]} />
</>
)
} else if ('labwareId' in initialLocation) {
Expand All @@ -533,7 +535,7 @@ function RowLabware({
if (adapterLocation != null && adapterLocation !== 'offDeck') {
if ('slotName' in adapterLocation) {
slotName = adapterLocation.slotName
location = <LocationIcon slotName={adapterLocation.slotName} />
location = <DeckInfoLabel deckLabel={adapterLocation.slotName} />
} else if ('moduleId' in adapterLocation) {
const moduleUnderAdapter = attachedProtocolModules.find(
module => module.moduleId === adapterLocation.moduleId
Expand All @@ -542,8 +544,8 @@ function RowLabware({
slotName = moduleUnderAdapter.slotName
location = (
<>
<LocationIcon slotName={moduleUnderAdapter.slotName} />
<LocationIcon
<DeckInfoLabel deckLabel={moduleUnderAdapter.slotName} />
<DeckInfoLabel
iconName={
MODULE_ICON_NAME_BY_TYPE[
moduleUnderAdapter.moduleDef.moduleType
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/ProtocolSetupLiquids/LiquidDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { useTranslation } from 'react-i18next'
import {
BORDERS,
COLORS,
DeckInfoLabel,
DIRECTION_ROW,
Flex,
Icon,
LocationIcon,
SPACING,
LegacyStyledText,
TYPOGRAPHY,
Expand Down Expand Up @@ -105,7 +105,7 @@ export function LiquidDetails(props: LiquidDetailsProps): JSX.Element {
>
<TableDatum>
<Flex>
<LocationIcon slotName={slotName} />
<DeckInfoLabel deckLabel={slotName} />
</Flex>
</TableDatum>
<TableDatum>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
BORDERS,
COLORS,
Chip,
DeckInfoLabel,
DIRECTION_ROW,
Flex,
JUSTIFY_SPACE_BETWEEN,
LocationIcon,
SPACING,
LegacyStyledText,
TYPOGRAPHY,
Expand Down Expand Up @@ -219,7 +219,7 @@ function FixtureTableItem({
</LegacyStyledText>
</Flex>
<Flex flex="2 0 0" alignItems={ALIGN_CENTER}>
<LocationIcon slotName={getCutoutDisplayName(cutoutId)} />
<DeckInfoLabel deckLabel={getCutoutDisplayName(cutoutId)} />
</Flex>
<Flex
flex="4 0 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
BORDERS,
COLORS,
Chip,
DeckInfoLabel,
Flex,
JUSTIFY_SPACE_BETWEEN,
LocationIcon,
SPACING,
LegacyStyledText,
TYPOGRAPHY,
Expand Down Expand Up @@ -281,8 +281,8 @@ function ModuleTableItem({
</LegacyStyledText>
</Flex>
<Flex alignItems={ALIGN_CENTER} flex="2 0 0">
<LocationIcon
slotName={
<DeckInfoLabel
deckLabel={
getModuleType(module.moduleDef.model) === THERMOCYCLER_MODULE_TYPE
? TC_MODULE_LOCATION_OT3
: module.slotName
Expand Down
Loading
Loading