Skip to content

Commit

Permalink
fix all the lint/tsc checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Oct 18, 2024
1 parent 04b6ad3 commit d350e0d
Show file tree
Hide file tree
Showing 89 changed files with 312 additions and 260 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type {
RobotType,
LabwareDefinition2,
} from '@opentrons/shared-data'
import type { CommandTextData } from '../../types'
import type { GetDirectTranslationCommandText } from './utils/getDirectTranslationCommandText'
import type {
TCProfileStepText,
TCProfileCycleText,
} from './utils/getTCRunExtendedProfileCommandText'
import type { CommandTextData } from '/app/local-resources/commands/types'

export interface UseCommandTextStringParams {
command: RunTimeCommand | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type {
MoveToAddressableAreaParams,
} from '@opentrons/shared-data'
import type { TFunction } from 'i18next'
import type { CommandTextData } from '../types'

import type { CommandTextData } from '/app/local-resources/commands'

export function getAddressableAreaDisplayName(
commandTextData: CommandTextData,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Liquid } from '@opentrons/shared-data'

export function getLiquidDisplayName(
liquids: Liquid[],
liquidId: string
): string {
const liquidDisplayName = liquids.find(liquid => liquid.id === liquidId)
?.displayName
return liquidDisplayName ?? ''
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import {
getFinalLabwareLocation,
getLabwareDisplayLocation,
getLabwareName,
} from '../../../utils'
getLabwareDisplayLocation,
} from '/app/local-resources/labware'
import { getFinalLabwareLocation } from './getFinalLabwareLocation'

import type {
LiquidProbeRunTimeCommand,
RunTimeCommand,
TryLiquidProbeRunTimeCommand,
} from '@opentrons/shared-data'
import type { HandlesCommands } from './types'
import type { TFunction } from 'i18next'

type LiquidProbeRunTimeCommands =
| LiquidProbeRunTimeCommand
Expand Down Expand Up @@ -38,20 +37,22 @@ export function getLiquidProbeCommandText({
)
: null

const displayLocation =
labwareLocation != null && commandTextData != null
? getLabwareDisplayLocation(
commandTextData,
allRunDefs,
labwareLocation,
t as TFunction,
robotType
)
: ''
const displayLocation = getLabwareDisplayLocation({
loadedLabwares: commandTextData?.labware ?? [],
location: labwareLocation,
robotType,
allRunDefs,
loadedModules: commandTextData?.modules ?? [],
t,
})

const labware =
commandTextData != null
? getLabwareName(commandTextData, labwareId as string)
? getLabwareName({
loadedLabwares: commandTextData?.labware ?? [],
labwareId,
allRunDefs,
})
: null

return t('detect_liquid_presence', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
getPipetteSpecsV2,
} from '@opentrons/shared-data'

import { getPipetteNameOnMount } from './getPipetteNameOnMount'
import { getLiquidDisplayName } from './getLiquidDisplayName'

import { getLabwareName } from '/app/local-resources/labware'
import {
getLabwareName,
getPipetteNameOnMount,
getModuleModel,
getModuleDisplayLocation,
getLiquidDisplayName,
} from '../../../utils'
} from '/app/local-resources/modules'

import type { LoadLabwareRunTimeCommand } from '@opentrons/shared-data'
import type { GetCommandText } from '..'
Expand All @@ -21,12 +22,16 @@ export const getLoadCommandText = ({
commandTextData,
robotType,
t,
allRunDefs,
}: GetCommandText): string => {
switch (command?.commandType) {
case 'loadPipette': {
const pipetteModel =
commandTextData != null
? getPipetteNameOnMount(commandTextData, command.params.mount)
? getPipetteNameOnMount(
commandTextData.pipettes,
command.params.mount
)
: null
return t('load_pipette_protocol_setup', {
pipette_name:
Expand Down Expand Up @@ -54,7 +59,10 @@ export const getLoadCommandText = ({
) {
const moduleModel =
commandTextData != null
? getModuleModel(commandTextData, command.params.location.moduleId)
? getModuleModel(
commandTextData.modules ?? [],
command.params.location.moduleId
)
: null
const moduleName =
moduleModel != null ? getModuleDisplayName(moduleModel) : ''
Expand All @@ -71,7 +79,7 @@ export const getLoadCommandText = ({
slot_name:
commandTextData != null
? getModuleDisplayLocation(
commandTextData,
commandTextData.modules ?? [],
command.params.location.moduleId
)
: null,
Expand Down Expand Up @@ -105,7 +113,10 @@ export const getLoadCommandText = ({
} else if (adapterLoc != null && 'moduleId' in adapterLoc) {
const moduleModel =
commandTextData != null
? getModuleModel(commandTextData, adapterLoc?.moduleId ?? '')
? getModuleModel(
commandTextData.modules ?? [],
adapterLoc?.moduleId ?? ''
)
: null
const moduleName =
moduleModel != null ? getModuleDisplayName(moduleModel) : ''
Expand All @@ -116,7 +127,7 @@ export const getLoadCommandText = ({
slot_name:
commandTextData != null
? getModuleDisplayLocation(
commandTextData,
commandTextData.modules ?? [],
adapterLoc?.moduleId ?? ''
)
: null,
Expand Down Expand Up @@ -144,7 +155,11 @@ export const getLoadCommandText = ({
const { labwareId } = command.params
const labware =
commandTextData != null
? getLabwareName(commandTextData, labwareId)
? getLabwareName({
loadedLabwares: commandTextData?.labware ?? [],
labwareId,
allRunDefs,
})
: null
return t('reloading_labware', { labware })
}
Expand All @@ -153,11 +168,15 @@ export const getLoadCommandText = ({
return t('load_liquids_info_protocol_setup', {
liquid:
commandTextData != null
? getLiquidDisplayName(commandTextData, liquidId)
? getLiquidDisplayName(commandTextData.liquids ?? [], liquidId)
: null,
labware:
commandTextData != null
? getLabwareName(commandTextData, labwareId)
? getLabwareName({
loadedLabwares: commandTextData?.labware ?? [],
labwareId,
allRunDefs,
})
: null,
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { GRIPPER_WASTE_CHUTE_ADDRESSABLE_AREA } from '@opentrons/shared-data'

import { getFinalLabwareLocation } from './getFinalLabwareLocation'
import {
getLabwareName,
getLabwareDisplayLocation,
getFinalLabwareLocation,
} from '../../../utils'
} from '/app/local-resources/labware'

import type { MoveLabwareRunTimeCommand } from '@opentrons/shared-data'
import type { HandlesCommands } from './types'
Expand All @@ -26,16 +26,23 @@ export function getMoveLabwareCommandText({
allPreviousCommands != null
? getFinalLabwareLocation(labwareId, allPreviousCommands)
: null
const newDisplayLocation =
commandTextData != null
? getLabwareDisplayLocation(
commandTextData,
allRunDefs,
newLocation,
t,
robotType
)
: null

const oldDisplayLocation = getLabwareDisplayLocation({
location: oldLocation,
robotType,
allRunDefs,
loadedLabwares: commandTextData?.labware ?? [],
loadedModules: commandTextData?.modules ?? [],
t,
})
const newDisplayLocation = getLabwareDisplayLocation({
location: newLocation,
robotType,
allRunDefs,
loadedLabwares: commandTextData?.labware ?? [],
loadedModules: commandTextData?.modules ?? [],
t,
})

const location = newDisplayLocation?.includes(
GRIPPER_WASTE_CHUTE_ADDRESSABLE_AREA
Expand All @@ -47,35 +54,25 @@ export function getMoveLabwareCommandText({
? t('move_labware_using_gripper', {
labware:
commandTextData != null
? getLabwareName(commandTextData, labwareId)
: null,
old_location:
oldLocation != null && commandTextData != null
? getLabwareDisplayLocation(
commandTextData,
? getLabwareName({
allRunDefs,
oldLocation,
t,
robotType
)
: '',
loadedLabwares: commandTextData.labware ?? [],
labwareId,
})
: null,
old_location: oldDisplayLocation,
new_location: location,
})
: t('move_labware_manually', {
labware:
commandTextData != null
? getLabwareName(commandTextData, labwareId)
: null,
old_location:
oldLocation != null && commandTextData != null
? getLabwareDisplayLocation(
commandTextData,
? getLabwareName({
allRunDefs,
oldLocation,
t,
robotType
)
: '',
loadedLabwares: commandTextData.labware ?? [],
labwareId,
})
: null,
old_location: oldDisplayLocation,
new_location: location,
})
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getAddressableAreaDisplayName } from '../../../utils'
import { getAddressableAreaDisplayName } from './getAddressableAreaDisplayName'

import type { MoveToAddressableAreaForDropTipRunTimeCommand } from '@opentrons/shared-data/command'
import type { HandlesCommands } from './types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getAddressableAreaDisplayName } from '../../../utils'
import { getAddressableAreaDisplayName } from './getAddressableAreaDisplayName'

import type { MoveToAddressableAreaRunTimeCommand } from '@opentrons/shared-data/command'
import type { HandlesCommands } from './types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
getFinalLabwareLocation,
getLabwareDisplayLocation,
getLabwareName,
} from '../../../utils'
getLabwareDisplayLocation,
} from '/app/local-resources/labware'

import { getFinalLabwareLocation } from './getFinalLabwareLocation'

import type { TFunction } from 'i18next'
import type { MoveToWellRunTimeCommand } from '@opentrons/shared-data/command'
import type { HandlesCommands } from './types'

Expand All @@ -24,22 +24,25 @@ export function getMoveToWellCommandText({
allPreviousCommands != null
? getFinalLabwareLocation(labwareId, allPreviousCommands)
: null
const displayLocation =
labwareLocation != null && commandTextData != null
? getLabwareDisplayLocation(
commandTextData,
allRunDefs,
labwareLocation,
t as TFunction,
robotType
)
: ''

const displayLocation = getLabwareDisplayLocation({
location: labwareLocation,
robotType,
allRunDefs,
loadedLabwares: commandTextData?.labware ?? [],
loadedModules: commandTextData?.modules ?? [],
t,
})

return t('move_to_well', {
well_name: wellName,
labware:
commandTextData != null
? getLabwareName(commandTextData, labwareId)
? getLabwareName({
loadedLabwares: commandTextData.labware ?? [],
labwareId,
allRunDefs,
})
: null,
labware_location: displayLocation,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { getLoadedPipette } from '/app/local-resources/instruments'

import type { PipetteName } from '@opentrons/shared-data'
import type { LoadedPipettes } from '/app/local-resources/instruments/types'

export function getPipetteNameOnMount(
loadedPipettes: LoadedPipettes,
mount: string
): PipetteName | null {
const loadedPipette = getLoadedPipette(loadedPipettes, mount)
return loadedPipette != null ? loadedPipette.pipetteName : null
}
Loading

0 comments on commit d350e0d

Please sign in to comment.