Skip to content

Commit

Permalink
refactor(protocol-designer): use useTranslation hook for all i18n ins…
Browse files Browse the repository at this point in the history
…tances

closes RAUT-542
  • Loading branch information
jerader committed Jan 17, 2024
1 parent 979a2c1 commit 8e59572
Show file tree
Hide file tree
Showing 31 changed files with 1,271 additions and 1,862 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe('makeBatchEditFieldProps', () => {
const result = makeBatchEditFieldProps(
fieldValues,
disabledFields,
handleChangeFormInput
handleChangeFormInput,
[]
)

expect(result).toEqual({
Expand Down Expand Up @@ -76,7 +77,8 @@ describe('makeBatchEditFieldProps', () => {
const result = makeBatchEditFieldProps(
fieldValues,
disabledFields,
handleChangeFormInput
handleChangeFormInput,
[]
)

expect(result.aspirate_flowRate.disabled).toBe(true)
Expand All @@ -99,7 +101,8 @@ describe('makeBatchEditFieldProps', () => {
const result = makeBatchEditFieldProps(
fieldValues,
disabledFields,
handleChangeFormInput
handleChangeFormInput,
[]
)

expect(result.aspirate_flowRate.isIndeterminate).toBe(true)
Expand All @@ -119,7 +122,8 @@ describe('makeBatchEditFieldProps', () => {
const result = makeBatchEditFieldProps(
fieldValues,
disabledFields,
handleChangeFormInput
handleChangeFormInput,
[]
)

expect(result.preWetTip.isIndeterminate).toBe(true)
Expand All @@ -144,7 +148,8 @@ describe('makeBatchEditFieldProps', () => {
const result = makeBatchEditFieldProps(
fieldValues,
disabledFields,
handleChangeFormInput
handleChangeFormInput,
[]
)

expect(result.preWetTip.isIndeterminate).toBe(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import assert from 'assert'
import { useTranslation } from 'react-i18next'
import * as React from 'react'
import { DropTarget, DropTargetConnector, DropTargetMonitor } from 'react-dnd'
import cx from 'classnames'
Expand Down Expand Up @@ -76,7 +75,6 @@ export const AdapterControlsComponents = (
onDeck,
allLabware,
} = props
const { t } = useTranslation('deck')
if (
selectedTerminalItemId !== START_TERMINAL_ITEM_ID ||
(itemType !== DND_TYPES.LABWARE && itemType !== null)
Expand Down Expand Up @@ -128,11 +126,11 @@ export const AdapterControlsComponents = (
>
<a className={styles.overlay_button} onClick={addLabware}>
{!isOver && <Icon className={styles.overlay_icon} name="plus" />}
{t(`overlay.slot.${isOver ? 'place_here' : 'add_labware'}`)}
{isOver ? 'Place Here' : 'Add Labware'}
</a>
<a className={styles.overlay_button} onClick={deleteLabware}>
{!isOver && <Icon className={styles.overlay_icon} name="close" />}
{t('overlay.edit.delete')}
{'Delete'}
</a>
</RobotCoordsForeignDiv>
)}
Expand All @@ -150,16 +148,14 @@ const mapDispatchToProps = (dispatch: ThunkDispatch<any>, ownProps: OP): DP => {
const adapterName =
ownProps.allLabware.find(labware => labware.id === ownProps.labwareId)?.def
.metadata.displayName ?? ''
const { t } = useTranslation('deck')
return {
addLabware: () =>
dispatch(openAddLabwareModal({ slot: ownProps.labwareId })),
moveDeckItem: (sourceSlot, destSlot) =>
dispatch(moveDeckItem(sourceSlot, destSlot)),
deleteLabware: () => {
window.confirm(
t('warning.cancelForSure', { adapterName: adapterName })
) && dispatch(deleteContainer({ labwareId: ownProps.labwareId }))
window.confirm(`"Are you sure you want to remove this ${adapterName}?`) &&
dispatch(deleteContainer({ labwareId: ownProps.labwareId }))
},
}
}
Expand Down
Loading

0 comments on commit 8e59572

Please sign in to comment.