Skip to content

Commit

Permalink
fix(app): filter qt out of recent runs to show empty run state (#16167)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored Aug 29, 2024
1 parent f05d1e5 commit f0d3ab3
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 87 deletions.
178 changes: 93 additions & 85 deletions app/src/organisms/Devices/RecentProtocolRuns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export function RecentProtocolRuns({
const currentRunId = useCurrentRunId()
const { isRunTerminal } = useRunStatuses()
const robotIsBusy = currentRunId != null ? !isRunTerminal : false
const nonQuickTransferRuns = runs?.filter(run => {
const protocol = protocols?.data?.data.find(
protocol => protocol.id === run.protocolId
)
return protocol?.protocolKind !== 'quick-transfer'
})

return (
<Flex
Expand Down Expand Up @@ -64,83 +70,83 @@ export function RecentProtocolRuns({
paddingX={SPACING.spacing16}
width="100%"
>
{isRobotViewable && runs && runs.length > 0 && (
<>
<Flex
justifyContent={JUSTIFY_FLEX_START}
padding={SPACING.spacing8}
width="88%"
marginRight="12%"
gridGap={SPACING.spacing20}
color={COLORS.grey60}
>
<LegacyStyledText
as="p"
width="25%"
data-testid="RecentProtocolRuns_RunTitle"
>
{t('run')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="27%"
data-testid="RecentProtocolRuns_ProtocolTitle"
>
{t('protocol')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="5%"
data-testid="RecentProtocolRuns_FilesTitle"
>
{t('files')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="14%"
data-testid="RecentProtocolRuns_StatusTitle"
{isRobotViewable &&
nonQuickTransferRuns &&
nonQuickTransferRuns?.length > 0 && (
<>
<Flex
justifyContent={JUSTIFY_FLEX_START}
padding={SPACING.spacing8}
width="88%"
marginRight="12%"
gridGap={SPACING.spacing20}
color={COLORS.grey60}
>
{t('status')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="14%"
data-testid="RecentProtocolRuns_DurationTitle"
>
{t('run_duration')}
</LegacyStyledText>
</Flex>
{runs
.sort(
(a, b) =>
new Date(b.createdAt).getTime() -
new Date(a.createdAt).getTime()
)
.map((run, index) => {
const protocol = protocols?.data?.data.find(
protocol => protocol.id === run.protocolId
<LegacyStyledText
as="p"
width="25%"
data-testid="RecentProtocolRuns_RunTitle"
>
{t('run')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="27%"
data-testid="RecentProtocolRuns_ProtocolTitle"
>
{t('protocol')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="5%"
data-testid="RecentProtocolRuns_FilesTitle"
>
{t('files')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="14%"
data-testid="RecentProtocolRuns_StatusTitle"
>
{t('status')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="14%"
data-testid="RecentProtocolRuns_DurationTitle"
>
{t('run_duration')}
</LegacyStyledText>
</Flex>
{nonQuickTransferRuns
.sort(
(a, b) =>
new Date(b.createdAt).getTime() -
new Date(a.createdAt).getTime()
)
const isQuickTransfer =
protocol?.protocolKind === 'quick-transfer'
const protocolName =
protocol?.metadata.protocolName ??
protocol?.files[0].name ??
t('shared:loading') ??
''
.map((run, index) => {
const protocol = protocols?.data?.data.find(
protocol => protocol.id === run.protocolId
)
const protocolName =
protocol?.metadata.protocolName ??
protocol?.files[0].name ??
t('shared:loading') ??
''

return !isQuickTransfer ? (
<HistoricalProtocolRun
run={run}
protocolName={protocolName}
protocolKey={protocol?.key}
robotName={robotName}
robotIsBusy={robotIsBusy}
key={index}
/>
) : null
})}
</>
)}
return (
<HistoricalProtocolRun
run={run}
protocolName={protocolName}
protocolKey={protocol?.key}
robotName={robotName}
robotIsBusy={robotIsBusy}
key={index}
/>
)
})}
</>
)}
{!isRobotViewable && (
<LegacyStyledText
as="p"
Expand All @@ -153,17 +159,19 @@ export function RecentProtocolRuns({
{t('offline_recent_protocol_runs')}
</LegacyStyledText>
)}
{isRobotViewable && (runs == null || runs.length === 0) && (
<LegacyStyledText
as="p"
alignItems={ALIGN_CENTER}
display={DISPLAY_FLEX}
flex="1 0"
id="RecentProtocolRuns_no_runs"
>
{t('no_protocol_runs')}
</LegacyStyledText>
)}
{isRobotViewable &&
(nonQuickTransferRuns == null ||
nonQuickTransferRuns.length === 0) && (
<LegacyStyledText
as="p"
alignItems={ALIGN_CENTER}
display={DISPLAY_FLEX}
flex="1 0"
id="RecentProtocolRuns_no_runs"
>
{t('no_protocol_runs')}
</LegacyStyledText>
)}
</Flex>
</Flex>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export function RecentRunProtocolCard({
const { data, isLoading } = useProtocolQuery(runData.protocolId ?? null)
const protocolData = data?.data ?? null
const isProtocolFetching = isLoading
return protocolData == null ||
protocolData.protocolKind === 'quick-transfer' ? null : (
return protocolData == null ? null : (
<ProtocolWithLastRun
protocolData={protocolData}
runData={runData}
Expand Down
7 changes: 7 additions & 0 deletions app/src/pages/RobotDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LegacyStyledText,
TYPOGRAPHY,
} from '@opentrons/components'
import { useAllProtocolsQuery } from '@opentrons/react-api-client'

import { Navigation } from '../../organisms/Navigation'
import {
Expand All @@ -30,6 +31,7 @@ export function RobotDashboard(): JSX.Element {
data: allRunsQueryData,
error: allRunsQueryError,
} = useNotifyAllRunsQuery()
const protocols = useAllProtocolsQuery()

const { unfinishedUnboxingFlowRoute } = useSelector(
getOnDeviceDisplaySettings
Expand All @@ -45,6 +47,11 @@ export function RobotDashboard(): JSX.Element {
acc.some(collectedRun => collectedRun.protocolId === run.protocolId)
) {
return acc
} else if (
protocols?.data?.data.find(protocol => protocol.id === run.protocolId)
?.protocolKind === 'quick-transfer'
) {
return acc
} else {
return [...acc, run]
}
Expand Down

0 comments on commit f0d3ab3

Please sign in to comment.