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

fix(app): support special cased slot name copy #16823

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -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 @@ -47,7 +47,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 +92,22 @@ 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 } {
const nameLc = slotName.toLowerCase()

if (nameLc.includes('wastechute')) {
return { odd: t('waste_chute'), desktop: t('waste_chute') }
} else if (nameLc.includes('trashbin')) {
return { odd: t('trash_bin'), desktop: t('trash_bin') }
} else {
return {
odd: slotName,
desktop: t('slot', { slot_name: slotName }),
}
}
}
Loading