Skip to content

Commit

Permalink
fix(app): support special cased slot name copy (#16823)
Browse files Browse the repository at this point in the history
Closes RQA-3585
  • Loading branch information
mjhuff authored Nov 14, 2024
1 parent 7cbee8e commit 59814e6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/src/assets/localization/en/protocol_command_text.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"tc_starting_extended_profile_cycle": "{{repetitions}} repetitions of the following steps:",
"tc_starting_profile": "Running thermocycler profile with {{stepCount}} steps:",
"touch_tip": "Touching tip",
"trash_bin": "Trash Bin",
"trash_bin_in_slot": "Trash Bin in {{slot_name}}",
"turning_rail_lights_off": "Turning rail lights off",
"turning_rail_lights_on": "Turning rail lights on",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ describe('getLabwareDisplayLocation with translations', () => {
screen.getByText('Slot C1')
})

it('should special case the slotName if it contains "waste chute"', () => {
render({
location: { slotName: 'gripperWasteChute' },
params: { ...defaultParams, detailLevel: 'slot-only' },
})

screen.getByText('Waste Chute')
})

it('should special case the slotName if it contains "trash bin"', () => {
render({
location: { slotName: 'trashBin' },
params: { ...defaultParams, detailLevel: 'slot-only' },
})

screen.getByText('Trash Bin')
})

it('should handle an adapter on module location when the detail level is full', () => {
const mockLoadedLabwares = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
getOccludedSlotCountForModule,
THERMOCYCLER_MODULE_V1,
THERMOCYCLER_MODULE_V2,
TRASH_BIN_FIXTURE,
WASTE_CHUTE_ADDRESSABLE_AREAS,
} from '@opentrons/shared-data'
import { getLabwareLocation } from './getLabwareLocation'

Expand All @@ -12,6 +14,7 @@ import type {
LocationSlotOnlyParams,
LocationFullParams,
} from './getLabwareLocation'
import type { AddressableAreaName } from '@opentrons/shared-data'

export interface DisplayLocationSlotOnlyParams extends LocationSlotOnlyParams {
t: TFunction
Expand Down Expand Up @@ -47,7 +50,8 @@ export function getLabwareDisplayLocation(
}
// Simple slot location
else if (moduleModel == null && adapterName == null) {
return isOnDevice ? slotName : t('slot', { slot_name: slotName })
const validatedSlotCopy = handleSpecialSlotNames(slotName, t)
return isOnDevice ? validatedSlotCopy.odd : validatedSlotCopy.desktop
}
// Module location without adapter
else if (moduleModel != null && adapterName == null) {
Expand Down Expand Up @@ -91,3 +95,20 @@ export function getLabwareDisplayLocation(
return ''
}
}

// Sometimes we don't want to show the actual slotName, so we special case the text here.
function handleSpecialSlotNames(
slotName: string,
t: TFunction
): { odd: string; desktop: string } {
if (WASTE_CHUTE_ADDRESSABLE_AREAS.includes(slotName as AddressableAreaName)) {
return { odd: t('waste_chute'), desktop: t('waste_chute') }
} else if (slotName === TRASH_BIN_FIXTURE) {
return { odd: t('trash_bin'), desktop: t('trash_bin') }
} else {
return {
odd: slotName,
desktop: t('slot', { slot_name: slotName }),
}
}
}
1 change: 1 addition & 0 deletions shared-data/js/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ export const SINGLE_RIGHT_SLOT_FIXTURE: 'singleRightSlot' = 'singleRightSlot'
export const STAGING_AREA_RIGHT_SLOT_FIXTURE: 'stagingAreaRightSlot' =
'stagingAreaRightSlot'

export const TRASH_BIN_FIXTURE: 'trashBin' = 'trashBin'
export const TRASH_BIN_ADAPTER_FIXTURE: 'trashBinAdapter' = 'trashBinAdapter'

export const WASTE_CHUTE_RIGHT_ADAPTER_COVERED_FIXTURE: 'wasteChuteRightAdapterCovered' =
Expand Down

0 comments on commit 59814e6

Please sign in to comment.