Skip to content

Commit b576b9c

Browse files
kojiCarlos-fernandez
authored andcommitted
fix(app,components): fix module controls no module connected case (#14784)
* fix(app,components): fix module controls no module connected case
1 parent 1537e73 commit b576b9c

File tree

8 files changed

+81
-62
lines changed

8 files changed

+81
-62
lines changed

app/src/organisms/Devices/ProtocolRun/ProtocolRunModuleControls.tsx

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import * as React from 'react'
2-
import { useTranslation } from 'react-i18next'
32
import { useInstrumentsQuery } from '@opentrons/react-api-client'
43
import {
54
COLORS,
65
DIRECTION_COLUMN,
76
Flex,
87
JUSTIFY_CENTER,
8+
InfoScreen,
99
SPACING,
10-
StyledText,
1110
} from '@opentrons/components'
1211
import { ModuleCard } from '../../ModuleCard'
1312
import { useModuleRenderInfoForProtocolById } from '../hooks'
@@ -73,8 +72,6 @@ export const ProtocolRunModuleControls = ({
7372
robotName,
7473
runId,
7574
}: ProtocolRunModuleControlsProps): JSX.Element => {
76-
const { t } = useTranslation('protocol_details')
77-
7875
const {
7976
attachPipetteRequired,
8077
calibratePipetteRequired,
@@ -97,18 +94,15 @@ export const ProtocolRunModuleControls = ({
9794
const rightColumnModules = attachedModules?.slice(halfAttachedModulesSize)
9895

9996
return attachedModules.length === 0 ? (
100-
<Flex justifyContent={JUSTIFY_CENTER}>
101-
<StyledText as="p" color={COLORS.grey50} marginY={SPACING.spacing16}>
102-
{t('connect_modules_to_see_controls')}
103-
</StyledText>
104-
</Flex>
105-
) : (
10697
<Flex
107-
gridGap={SPACING.spacing8}
108-
paddingTop={SPACING.spacing16}
109-
paddingBottom={SPACING.spacing8}
110-
paddingX={SPACING.spacing16}
98+
justifyContent={JUSTIFY_CENTER}
99+
padding={SPACING.spacing16}
100+
backgroundColor={COLORS.white}
111101
>
102+
<InfoScreen contentType="moduleControls" />
103+
</Flex>
104+
) : (
105+
<Flex gridGap={SPACING.spacing8} padding={SPACING.spacing16}>
112106
<Flex
113107
flexDirection={DIRECTION_COLUMN}
114108
flex="50%"

app/src/organisms/Devices/ProtocolRun/ProtocolRunRunTimeParameters.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import {
1010
DIRECTION_COLUMN,
1111
DIRECTION_ROW,
1212
Flex,
13+
Icon,
14+
InfoScreen,
1315
SPACING,
1416
StyledText,
1517
TYPOGRAPHY,
16-
NoParameters,
1718
useHoverTooltip,
18-
Icon,
1919
} from '@opentrons/components'
2020

2121
import { Banner } from '../../../atoms/Banner'
@@ -78,7 +78,7 @@ export function ProtocolRunRuntimeParameters({
7878
</Flex>
7979
{!hasParameter ? (
8080
<Flex padding={SPACING.spacing16}>
81-
<NoParameters />
81+
<InfoScreen contentType="parameters" />
8282
</Flex>
8383
) : (
8484
<>

app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunRuntimeParameters.test.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { describe, it, vi, beforeEach, afterEach, expect } from 'vitest'
33
import { screen } from '@testing-library/react'
44
import { when } from 'vitest-when'
55

6-
import { NoParameters } from '@opentrons/components'
6+
import { InfoScreen } from '@opentrons/components'
77
import { renderWithProviders } from '../../../../__testing-utils__'
88
import { i18n } from '../../../../i18n'
99
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
@@ -16,10 +16,10 @@ import type {
1616
} from '@opentrons/shared-data'
1717

1818
vi.mock('@opentrons/components', async importOriginal => {
19-
const actual = await importOriginal<typeof NoParameters>()
19+
const actual = await importOriginal<typeof InfoScreen>()
2020
return {
2121
...actual,
22-
NoParameters: vi.fn(),
22+
InfoScreen: vi.fn(),
2323
}
2424
})
2525
vi.mock('../../../LabwarePositionCheck/useMostRecentCompletedAnalysis')
@@ -94,7 +94,7 @@ describe('ProtocolRunRuntimeParameters', () => {
9494
props = {
9595
runId: RUN_ID,
9696
}
97-
vi.mocked(NoParameters).mockReturnValue(<div>mock NoParameter</div>)
97+
vi.mocked(InfoScreen).mockReturnValue(<div>mock InfoScreen</div>)
9898
when(vi.mocked(useMostRecentCompletedAnalysis))
9999
.calledWith(RUN_ID)
100100
.thenReturn({
@@ -151,7 +151,7 @@ describe('ProtocolRunRuntimeParameters', () => {
151151
screen.getByText('No offsets')
152152
})
153153

154-
it('should render mock NoParameter component when RunTimeParameters are empty', () => {
154+
it('should render mock InfoScreen component when RunTimeParameters are empty', () => {
155155
when(vi.mocked(useMostRecentCompletedAnalysis))
156156
.calledWith(RUN_ID)
157157
.thenReturn({
@@ -160,7 +160,7 @@ describe('ProtocolRunRuntimeParameters', () => {
160160
render(props)
161161
screen.getByText('Parameters')
162162
expect(screen.queryByText('Default values')).not.toBeInTheDocument()
163-
screen.getByText('mock NoParameter')
163+
screen.getByText('mock InfoScreen')
164164
})
165165

166166
// ToDo Additional test will be implemented when chip component is added

app/src/organisms/ProtocolDetails/ProtocolParameters/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { useTranslation } from 'react-i18next'
44
import {
55
DIRECTION_COLUMN,
66
Flex,
7+
InfoScreen,
8+
ParametersTable,
79
SPACING,
810
StyledText,
911
TYPOGRAPHY,
10-
ParametersTable,
11-
NoParameters,
1212
} from '@opentrons/components'
1313
import { Banner } from '../../../atoms/Banner'
1414

@@ -48,7 +48,7 @@ export function ProtocolParameters({
4848
<ParametersTable runTimeParameters={runTimeParameters} t={t} />
4949
</Flex>
5050
) : (
51-
<NoParameters />
51+
<InfoScreen contentType="parameters" />
5252
)}
5353
</Flex>
5454
)

components/src/molecules/ParametersTable/NoParameters.tsx components/src/molecules/ParametersTable/InfoScreen.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ import { Icon } from '../../icons'
77
import { Flex } from '../../primitives'
88
import { ALIGN_CENTER, DIRECTION_COLUMN } from '../../styles'
99

10-
export function NoParameters(): JSX.Element {
10+
interface InfoScreenProps {
11+
contentType: 'parameters' | 'moduleControls'
12+
}
13+
14+
export function InfoScreen({ contentType }: InfoScreenProps): JSX.Element {
15+
const bodyText =
16+
contentType === 'parameters'
17+
? 'No parameters specified in this protocol'
18+
: 'Connect modules to see controls'
1119
return (
1220
<Flex
1321
alignItems={ALIGN_CENTER}
@@ -17,7 +25,7 @@ export function NoParameters(): JSX.Element {
1725
backgroundColor={COLORS.grey30}
1826
borderRadius={BORDERS.borderRadius8}
1927
padding={`${SPACING.spacing40} ${SPACING.spacing16}`}
20-
data-testid="NoRunTimeParameter"
28+
data-testid={`InfoScreen_${contentType}`}
2129
>
2230
<Icon
2331
name="ot-alert"
@@ -26,7 +34,7 @@ export function NoParameters(): JSX.Element {
2634
aria-label="alert"
2735
/>
2836
<StyledText as="p" fontWeight={TYPOGRAPHY.fontWeightSemiBold}>
29-
No parameters specified in this protocol
37+
{bodyText}
3038
</StyledText>
3139
</Flex>
3240
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import * as React from 'react'
2+
import { screen } from '@testing-library/react'
3+
import { describe, it, expect, beforeEach } from 'vitest'
4+
5+
import { renderWithProviders } from '../../../testing/utils'
6+
import { BORDERS, COLORS } from '../../../helix-design-system'
7+
import { InfoScreen } from '../InfoScreen'
8+
9+
const render = (props: React.ComponentProps<typeof InfoScreen>) => {
10+
return renderWithProviders(<InfoScreen {...props} />)
11+
}
12+
13+
describe('InfoScreen', () => {
14+
let props: React.ComponentProps<typeof InfoScreen>
15+
16+
beforeEach(() => {
17+
props = {
18+
contentType: 'parameters',
19+
}
20+
})
21+
22+
it('should render text and icon with proper color - parameters', () => {
23+
render(props)
24+
screen.getByLabelText('alert')
25+
screen.getByText('No parameters specified in this protocol')
26+
})
27+
28+
it('should render text and icon with proper color - module controls', () => {
29+
props = {
30+
contentType: 'moduleControls',
31+
}
32+
render(props)
33+
screen.getByLabelText('alert')
34+
screen.getByText('Connect modules to see controls')
35+
})
36+
37+
it('should have proper styles', () => {
38+
render(props)
39+
expect(screen.getByTestId('InfoScreen_parameters')).toHaveStyle(
40+
`background-color: ${COLORS.grey30}`
41+
)
42+
expect(screen.getByTestId('InfoScreen_parameters')).toHaveStyle(
43+
`border-radius: ${BORDERS.borderRadius8}`
44+
)
45+
expect(screen.getByLabelText('alert')).toHaveStyle(
46+
`color: ${COLORS.grey60}`
47+
)
48+
})
49+
})

components/src/molecules/ParametersTable/__tests__/NoParameters.test.tsx

-32
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from './LocationIcon'
22
export * from './RoundTab'
33
export * from './ParametersTable'
4-
export * from './ParametersTable/NoParameters'
4+
export * from './ParametersTable/InfoScreen'

0 commit comments

Comments
 (0)