diff --git a/app/src/organisms/Devices/ProtocolRun/ProtocolRunRunTimeParameters.tsx b/app/src/organisms/Devices/ProtocolRun/ProtocolRunRunTimeParameters.tsx
index e3153e39a851..7c16be9446c4 100644
--- a/app/src/organisms/Devices/ProtocolRun/ProtocolRunRunTimeParameters.tsx
+++ b/app/src/organisms/Devices/ProtocolRun/ProtocolRunRunTimeParameters.tsx
@@ -2,7 +2,7 @@ import * as React from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
-import { formatRunTimeParameterValue } from '@opentrons/shared-data'
+import { formatRunTimeParameterDefaultValue } from '@opentrons/shared-data'
import {
ALIGN_CENTER,
BORDERS,
@@ -255,7 +255,7 @@ export function ProtocolRunRuntimeParameters({
gridGap={SPACING.spacing16}
>
- {formatRunTimeParameterValue(parameter, t)}
+ {formatRunTimeParameterDefaultValue(parameter, t)}
{/* ToDo (kk:03/19/2024) need to implement a logic when be is ready */}
{index % 2 === 0 ? (
diff --git a/app/src/organisms/ProtocolSetupParameters/ViewOnlyParameters.tsx b/app/src/organisms/ProtocolSetupParameters/ViewOnlyParameters.tsx
index e8aca7d8c9c0..09dcaf26c473 100644
--- a/app/src/organisms/ProtocolSetupParameters/ViewOnlyParameters.tsx
+++ b/app/src/organisms/ProtocolSetupParameters/ViewOnlyParameters.tsx
@@ -1,6 +1,6 @@
import * as React from 'react'
import { useTranslation } from 'react-i18next'
-import { formatRunTimeParameterValue } from '@opentrons/shared-data'
+import { formatRunTimeParameterDefaultValue } from '@opentrons/shared-data'
import {
ALIGN_CENTER,
BORDERS,
@@ -94,7 +94,7 @@ export function ViewOnlyParameters({
gridGap={SPACING.spacing8}
>
- {formatRunTimeParameterValue(parameter, t)}
+ {formatRunTimeParameterDefaultValue(parameter, t)}
{hasCustomValue ? (
(
false
)
- const parameters = runTimeParameters ?? []
+ const parameters = mockData
const [newRunTimeParameters, setNewRunTimeParameters] = React.useState<
RunTimeParameter[]
@@ -248,6 +248,10 @@ export function ProtocolSetupParameters({
paddingX={SPACING.spacing8}
>
{newRunTimeParameters.map((parameter, index) => {
+ console.log(
+ 'parameter',
+ parameter.type === 'boolean' ? parameter : undefined
+ )
return (
{
- {formatRunTimeParameterValue(parameter, t)}
+ {formatRunTimeParameterDefaultValue(parameter, t)}
diff --git a/components/src/molecules/ParametersTable/index.tsx b/components/src/molecules/ParametersTable/index.tsx
index 4ff5cdeeb18a..cce17fcf59a8 100644
--- a/components/src/molecules/ParametersTable/index.tsx
+++ b/components/src/molecules/ParametersTable/index.tsx
@@ -1,6 +1,6 @@
import * as React from 'react'
import styled from 'styled-components'
-import { formatRunTimeParameterValue } from '@opentrons/shared-data'
+import { formatRunTimeParameterDefaultValue } from '@opentrons/shared-data'
import { BORDERS } from '../../helix-design-system'
import { SPACING, TYPOGRAPHY } from '../../ui-style-constants/index'
import { StyledText } from '../../atoms/StyledText'
@@ -69,7 +69,7 @@ export function ParametersTable({
- {formatRunTimeParameterValue(parameter, t)}
+ {formatRunTimeParameterDefaultValue(parameter, t)}
diff --git a/shared-data/js/helpers/__tests__/formatRunTimeParameterValue.test.ts b/shared-data/js/helpers/__tests__/formatRunTimeParameterValue.test.ts
index bfdad4939137..2ee21daa4014 100644
--- a/shared-data/js/helpers/__tests__/formatRunTimeParameterValue.test.ts
+++ b/shared-data/js/helpers/__tests__/formatRunTimeParameterValue.test.ts
@@ -1,5 +1,5 @@
import { describe, it, expect, vi } from 'vitest'
-import { formatRunTimeParameterValue } from '../formatRunTimeParameterValue'
+import { formatRunTimeParameterDefaultValue } from '../formatRunTimeParameterDefaultValue'
import type { RunTimeParameter } from '../../types'
@@ -9,7 +9,7 @@ const capitalizeFirstLetter = (str: string): string => {
const mockTFunction = vi.fn(str => capitalizeFirstLetter(str))
-describe('utils-formatRunTimeParameterValue', () => {
+describe('utils-formatRunTimeParameterDefaultValue', () => {
it('should return value with suffix when type is int', () => {
const mockData = {
value: 6,
@@ -21,7 +21,7 @@ describe('utils-formatRunTimeParameterValue', () => {
max: 10,
default: 6,
} as RunTimeParameter
- const result = formatRunTimeParameterValue(mockData, mockTFunction)
+ const result = formatRunTimeParameterDefaultValue(mockData, mockTFunction)
expect(result).toEqual('6')
})
@@ -37,7 +37,7 @@ describe('utils-formatRunTimeParameterValue', () => {
max: 10.0,
default: 6.5,
} as RunTimeParameter
- const result = formatRunTimeParameterValue(mockData, mockTFunction)
+ const result = formatRunTimeParameterDefaultValue(mockData, mockTFunction)
expect(result).toEqual('6.5 mL')
})
@@ -60,7 +60,7 @@ describe('utils-formatRunTimeParameterValue', () => {
],
default: 'left',
} as RunTimeParameter
- const result = formatRunTimeParameterValue(mockData, mockTFunction)
+ const result = formatRunTimeParameterDefaultValue(mockData, mockTFunction)
expect(result).toEqual('Left')
})
@@ -73,7 +73,7 @@ describe('utils-formatRunTimeParameterValue', () => {
type: 'boolean',
default: true,
} as RunTimeParameter
- const result = formatRunTimeParameterValue(mockData, mockTFunction)
+ const result = formatRunTimeParameterDefaultValue(mockData, mockTFunction)
expect(result).toEqual('On')
})
@@ -86,7 +86,7 @@ describe('utils-formatRunTimeParameterValue', () => {
type: 'boolean',
default: false,
} as RunTimeParameter
- const result = formatRunTimeParameterValue(mockData, mockTFunction)
+ const result = formatRunTimeParameterDefaultValue(mockData, mockTFunction)
expect(result).toEqual('Off')
})
})
diff --git a/shared-data/js/helpers/formatRunTimeParameterDefaultValue.ts b/shared-data/js/helpers/formatRunTimeParameterDefaultValue.ts
new file mode 100644
index 000000000000..fa2a1180e139
--- /dev/null
+++ b/shared-data/js/helpers/formatRunTimeParameterDefaultValue.ts
@@ -0,0 +1,36 @@
+import type { RunTimeParameter } from '../types'
+
+export const formatRunTimeParameterDefaultValue = (
+ runTimeParameter: RunTimeParameter,
+ t?: any
+): string => {
+ const { type, default: defaultValue } = runTimeParameter
+ const suffix =
+ 'suffix' in runTimeParameter && runTimeParameter.suffix != null
+ ? runTimeParameter.suffix
+ : null
+ switch (type) {
+ case 'int':
+ case 'float':
+ return suffix !== null
+ ? `${defaultValue.toString()} ${suffix}`
+ : defaultValue.toString()
+ case 'boolean':
+ if (t != null) {
+ return Boolean(defaultValue) ? t('on') : t('off')
+ } else {
+ return Boolean(defaultValue) ? 'On' : 'Off'
+ }
+ case 'str':
+ if ('choices' in runTimeParameter && runTimeParameter.choices != null) {
+ const choice = runTimeParameter.choices.find(
+ choice => choice.value === defaultValue
+ )
+ if (choice != null) {
+ return choice.displayName
+ }
+ }
+ break
+ }
+ return ''
+}
diff --git a/shared-data/js/helpers/formatRunTimeParameterValue.ts b/shared-data/js/helpers/formatRunTimeParameterValue.ts
index ffbab087849f..afaeb061ec84 100644
--- a/shared-data/js/helpers/formatRunTimeParameterValue.ts
+++ b/shared-data/js/helpers/formatRunTimeParameterValue.ts
@@ -1,10 +1,10 @@
-import { RunTimeParameter } from '../types'
+import type { RunTimeParameter } from '../types'
export const formatRunTimeParameterValue = (
runTimeParameter: RunTimeParameter,
- t?: any
+ t: any
): string => {
- const { type, default: defaultValue } = runTimeParameter
+ const { type, value } = runTimeParameter
const suffix =
'suffix' in runTimeParameter && runTimeParameter.suffix != null
? runTimeParameter.suffix
@@ -13,18 +13,15 @@ export const formatRunTimeParameterValue = (
case 'int':
case 'float':
return suffix !== null
- ? `${defaultValue.toString()} ${suffix}`
- : defaultValue.toString()
- case 'boolean':
- if (t != null) {
- return Boolean(defaultValue) ? t('on') : t('off')
- } else {
- return Boolean(defaultValue) ? 'On' : 'Off'
- }
+ ? `${value.toString()} ${suffix}`
+ : value.toString()
+ case 'boolean': {
+ return Boolean(value) ? t('on') : t('off')
+ }
case 'str':
if ('choices' in runTimeParameter && runTimeParameter.choices != null) {
const choice = runTimeParameter.choices.find(
- choice => choice.value === defaultValue
+ choice => choice.value === value
)
if (choice != null) {
return choice.displayName
diff --git a/shared-data/js/helpers/index.ts b/shared-data/js/helpers/index.ts
index 2d78f16ca1f0..a65a83085ded 100644
--- a/shared-data/js/helpers/index.ts
+++ b/shared-data/js/helpers/index.ts
@@ -28,6 +28,7 @@ export * from './getOccludedSlotCountForModule'
export * from './labwareInference'
export * from './getAddressableAreasInProtocol'
export * from './getSimplestFlexDeckConfig'
+export * from './formatRunTimeParameterDefaultValue'
export * from './formatRunTimeParameterValue'
export const getLabwareDefIsStandard = (def: LabwareDefinition2): boolean =>