Skip to content

Commit

Permalink
chore(app): remove enableCsvFile feature flag (#15863)
Browse files Browse the repository at this point in the history
remove enableCsvFile feature flag from app
  • Loading branch information
ncdiehl11 authored Aug 2, 2024
1 parent c40a009 commit 8cdf2b7
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 213 deletions.
1 change: 0 additions & 1 deletion app/src/assets/localization/en/app_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"__dev_internal__protocolTimeline": "Protocol Timeline",
"__dev_internal__enableRunNotes": "Display Notes During a Protocol Run",
"__dev_internal__enableQuickTransfer": "Enable Quick Transfer",
"__dev_internal__enableCsvFile": "Enable CSV File",
"__dev_internal__enableLabwareCreator": "Enable App Labware Creator",
"add_folder_button": "Add labware source folder",
"add_ip_button": "Add",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { simpleAnalysisFileFixture } from '@opentrons/api-client'
import { OT2_ROBOT_TYPE } from '@opentrons/shared-data'
import { renderWithProviders } from '../../../__testing-utils__'
import { i18n } from '../../../i18n'
import { useFeatureFlag } from '../../../redux/config'
import { getStoredProtocols } from '../../../redux/protocol-storage'
import { mockConnectableRobot } from '../../../redux/discovery/__fixtures__'
import {
Expand All @@ -19,7 +18,6 @@ import { useCreateRunFromProtocol } from '../../ChooseRobotToRunProtocolSlideout
import { ChooseProtocolSlideout } from '../'
import { useNotifyDataReady } from '../../../resources/useNotifyDataReady'
import type { ProtocolAnalysisOutput } from '@opentrons/shared-data'
import { when } from 'vitest-when'

vi.mock('../../ChooseRobotToRunProtocolSlideout/useCreateRunFromProtocol')
vi.mock('../../../redux/protocol-storage')
Expand Down Expand Up @@ -69,7 +67,6 @@ describe('ChooseProtocolSlideout', () => {
trackCreateProtocolRunEvent: mockTrackCreateProtocolRunEvent,
})
vi.mocked(useNotifyDataReady).mockReturnValue({} as any)
when(vi.mocked(useFeatureFlag)).calledWith('enableCsvFile').thenReturn(true)
})

it('renders slideout if showSlideout true', () => {
Expand Down
24 changes: 7 additions & 17 deletions app/src/organisms/ChooseProtocolSlideout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
import { sortRuntimeParameters } from '@opentrons/shared-data'

import { useLogger } from '../../logger'
import { useFeatureFlag } from '../../redux/config'
import { OPENTRONS_USB } from '../../redux/discovery'
import { getStoredProtocols } from '../../redux/protocol-storage'
import { appShellRequestor } from '../../redux/shell/remote'
Expand Down Expand Up @@ -117,7 +116,6 @@ export function ChooseProtocolSlideoutComponent(
) ?? false
)
const [isInputFocused, setIsInputFocused] = React.useState<boolean>(false)
const enableCsvFile = useFeatureFlag('enableCsvFile')

React.useEffect(() => {
setRunTimeParametersOverrides(
Expand Down Expand Up @@ -239,20 +237,12 @@ export function ChooseProtocolSlideoutComponent(
runTimeParametersOverrides,
mappedResolvedCsvVariableToFileId
)
if (enableCsvFile) {
createRunFromProtocolSource({
files: srcFileObjects,
protocolKey: selectedProtocol.protocolKey,
runTimeParameterValues,
runTimeParameterFiles,
})
} else {
createRunFromProtocolSource({
files: srcFileObjects,
protocolKey: selectedProtocol.protocolKey,
runTimeParameterValues,
})
}
createRunFromProtocolSource({
files: srcFileObjects,
protocolKey: selectedProtocol.protocolKey,
runTimeParameterValues,
runTimeParameterFiles,
})
})
} else {
logger.warn('failed to create protocol, no protocol selected')
Expand Down Expand Up @@ -441,7 +431,7 @@ export function ChooseProtocolSlideoutComponent(
if (error != null) {
errors.push(error as string)
}
return !enableCsvFile ? null : (
return (
<Flex
flexDirection={DIRECTION_COLUMN}
alignItems={ALIGN_CENTER}
Expand Down
5 changes: 2 additions & 3 deletions app/src/organisms/ChooseRobotSlideout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
OT2_ROBOT_TYPE,
sortRuntimeParameters,
} from '@opentrons/shared-data'
import { useFeatureFlag } from '../../redux/config'
import {
getConnectableRobots,
getReachableRobots,
Expand Down Expand Up @@ -153,7 +152,6 @@ export function ChooseRobotSlideout(
resetRunTimeParameters,
setHasMissingFileParam,
} = props
const enableCsvFile = useFeatureFlag('enableCsvFile')

const dispatch = useDispatch<Dispatch>()
const isScanning = useSelector((state: State) => getScanning(state))
Expand Down Expand Up @@ -530,8 +528,9 @@ export function ChooseRobotSlideout(
if (error != null) {
errors.push(error as string)
}
return !enableCsvFile ? null : (
return (
<Flex
key={runtimeParam.variableName}
flexDirection={DIRECTION_COLUMN}
alignItems={ALIGN_CENTER}
gridgap={SPACING.spacing8}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { i18n } from '../../../i18n'
import { useTrackCreateProtocolRunEvent } from '../../../organisms/Devices/hooks'
import { useCloseCurrentRun } from '../../../organisms/ProtocolUpload/hooks'
import { useCurrentRunStatus } from '../../../organisms/RunTimeControl/hooks'
import { useFeatureFlag } from '../../../redux/config'
import {
getConnectableRobots,
getReachableRobots,
Expand Down Expand Up @@ -192,7 +191,6 @@ describe('ChooseRobotToRunProtocolSlideout', () => {
{ ...mockConnectableRobot, name: 'otherRobot', ip: 'otherIp' },
mockConnectableRobot,
])
vi.mocked(useFeatureFlag).mockReturnValue(true)

provideNullCurrentRunIdFor('otherIp')
render({
Expand Down Expand Up @@ -267,6 +265,7 @@ describe('ChooseRobotToRunProtocolSlideout', () => {
files: [expect.any(File)],
protocolKey: storedProtocolDataFixture.protocolKey,
runTimeParameterValues: expect.any(Object),
runTimeParameterFiles: expect.any(Object),
})
)
expect(mockTrackCreateProtocolRunEvent).toHaveBeenCalled()
Expand Down Expand Up @@ -300,6 +299,7 @@ describe('ChooseRobotToRunProtocolSlideout', () => {
files: [expect.any(File)],
protocolKey: storedProtocolDataFixture.protocolKey,
runTimeParameterValues: expect.any(Object),
runTimeParameterFiles: expect.any(Object),
})
)
expect(mockTrackCreateProtocolRunEvent).toHaveBeenCalled()
Expand Down Expand Up @@ -353,6 +353,7 @@ describe('ChooseRobotToRunProtocolSlideout', () => {
files: [expect.any(File)],
protocolKey: storedProtocolDataFixture.protocolKey,
runTimeParameterValues: expect.any(Object),
runTimeParameterFiles: expect.any(Object),
})
})
})
Expand Down
66 changes: 26 additions & 40 deletions app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { useUploadCsvFileMutation } from '@opentrons/react-api-client'

import { Tooltip } from '../../atoms/Tooltip'
import { getRobotUpdateDisplayInfo } from '../../redux/robot-update'
import { useFeatureFlag } from '../../redux/config'
import { OPENTRONS_USB } from '../../redux/discovery'
import { appShellRequestor } from '../../redux/shell/remote'
import { useTrackCreateProtocolRunEvent } from '../Devices/hooks'
Expand Down Expand Up @@ -96,8 +95,6 @@ export function ChooseRobotToRunProtocolSlideoutComponent(
: null
)

const enableCsvFile = useFeatureFlag('enableCsvFile')

const {
createRunFromProtocolSource,
runCreationError,
Expand Down Expand Up @@ -139,52 +136,41 @@ export function ChooseRobotToRunProtocolSlideoutComponent(
)
const handleProceed: React.MouseEventHandler<HTMLButtonElement> = () => {
trackCreateProtocolRunEvent({ name: 'createProtocolRecordRequest' })
if (enableCsvFile) {
const dataFilesForProtocolMap = runTimeParametersOverrides.reduce<
Record<string, File>
>(
(acc, parameter) =>
parameter.type === 'csv_file' && parameter.file?.file != null
? { ...acc, [parameter.variableName]: parameter.file.file }
: acc,
{}
)
Promise.all(
Object.entries(dataFilesForProtocolMap).map(([key, file]) => {
const fileResponse = uploadCsvFile(file)
const varName = Promise.resolve(key)
return Promise.all([fileResponse, varName])
})
).then(responseTuples => {
const mappedResolvedCsvVariableToFileId = responseTuples.reduce<
Record<string, string>
>((acc, [uploadedFileResponse, variableName]) => {
return { ...acc, [variableName]: uploadedFileResponse.data.id }
}, {})
const runTimeParameterValues = getRunTimeParameterValuesForRun(
runTimeParametersOverrides
)
const runTimeParameterFiles = getRunTimeParameterFilesForRun(
runTimeParametersOverrides,
mappedResolvedCsvVariableToFileId
)
createRunFromProtocolSource({
files: srcFileObjects,
protocolKey,
runTimeParameterValues,
runTimeParameterFiles,
})
const dataFilesForProtocolMap = runTimeParametersOverrides.reduce<
Record<string, File>
>(
(acc, parameter) =>
parameter.type === 'csv_file' && parameter.file?.file != null
? { ...acc, [parameter.variableName]: parameter.file.file }
: acc,
{}
)
Promise.all(
Object.entries(dataFilesForProtocolMap).map(([key, file]) => {
const fileResponse = uploadCsvFile(file)
const varName = Promise.resolve(key)
return Promise.all([fileResponse, varName])
})
} else {
).then(responseTuples => {
const mappedResolvedCsvVariableToFileId = responseTuples.reduce<
Record<string, string>
>((acc, [uploadedFileResponse, variableName]) => {
return { ...acc, [variableName]: uploadedFileResponse.data.id }
}, {})
const runTimeParameterValues = getRunTimeParameterValuesForRun(
runTimeParametersOverrides
)
const runTimeParameterFiles = getRunTimeParameterFilesForRun(
runTimeParametersOverrides,
mappedResolvedCsvVariableToFileId
)
createRunFromProtocolSource({
files: srcFileObjects,
protocolKey,
runTimeParameterValues,
runTimeParameterFiles,
})
}
})
}

const { autoUpdateAction } = useSelector((state: State) =>
Expand Down
18 changes: 7 additions & 11 deletions app/src/organisms/Devices/HistoricalProtocolRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
LegacyStyledText,
} from '@opentrons/components'
import { useAllCsvFilesQuery } from '@opentrons/react-api-client'
import { useFeatureFlag } from '../../redux/config'
import { formatInterval } from '../RunTimeControl/utils'
import { formatTimestamp } from './utils'
import { EMPTY_TIMESTAMP } from './constants'
Expand Down Expand Up @@ -55,7 +54,6 @@ export function HistoricalProtocolRun(
duration = formatInterval(run.startedAt, new Date().toString())
}
}
const enableCsvFile = useFeatureFlag('enableCsvFile')

return (
<>
Expand Down Expand Up @@ -89,15 +87,13 @@ export function HistoricalProtocolRun(
>
{protocolName}
</LegacyStyledText>
{enableCsvFile ? (
<LegacyStyledText
as="p"
width="5%"
data-testid={`RecentProtocolRuns_Files_${protocolKey}`}
>
{allProtocolDataFiles.length}
</LegacyStyledText>
) : null}
<LegacyStyledText
as="p"
width="5%"
data-testid={`RecentProtocolRuns_Files_${protocolKey}`}
>
{allProtocolDataFiles.length}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="14%"
Expand Down
4 changes: 1 addition & 3 deletions app/src/organisms/Devices/HistoricalProtocolRunDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
} from '@opentrons/shared-data'
import { useAllCsvFilesQuery } from '@opentrons/react-api-client'
import { DownloadCsvFileLink } from './DownloadCsvFileLink'
import { useFeatureFlag } from '../../redux/config'
import { Banner } from '../../atoms/Banner'
import { useMostRecentCompletedAnalysis } from '../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useDeckCalibrationData } from './hooks'
Expand Down Expand Up @@ -68,7 +67,6 @@ export function HistoricalProtocolRunDrawer(
? deckCalibrationData.lastModified
: null
const protocolDetails = useMostRecentCompletedAnalysis(run.id)
const enableCsvFile = useFeatureFlag('enableCsvFile')

const isOutOfDate =
typeof lastModifiedDeckCal === 'string' &&
Expand Down Expand Up @@ -290,7 +288,7 @@ export function HistoricalProtocolRunDrawer(
width="100%"
padding={SPACING.spacing16}
>
{enableCsvFile ? protocolFilesData : null}
{protocolFilesData}
{labwareOffsets}
</Flex>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { i18n } from '../../../../i18n'
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useRunStatus } from '../../../RunTimeControl/hooks'
import { useNotifyRunQuery } from '../../../../resources/runs'
import { useFeatureFlag } from '../../../../redux/config'
import { mockSucceededRun } from '../../../RunTimeControl/__fixtures__'
import { ProtocolRunRuntimeParameters } from '../ProtocolRunRunTimeParameters'

Expand Down Expand Up @@ -122,9 +121,6 @@ describe('ProtocolRunRuntimeParameters', () => {
vi.mocked(useNotifyRunQuery).mockReturnValue(({
data: { data: mockSucceededRun },
} as unknown) as UseQueryResult<Run>)
when(vi.mocked(useFeatureFlag))
.calledWith('enableCsvFile')
.thenReturn(false)
})

afterEach(() => {
Expand Down Expand Up @@ -189,7 +185,6 @@ describe('ProtocolRunRuntimeParameters', () => {
})

it('should render csv row if a protocol requires a csv', () => {
when(vi.mocked(useFeatureFlag)).calledWith('enableCsvFile').thenReturn(true)
vi.mocked(useMostRecentCompletedAnalysis).mockReturnValue({
runTimeParameters: [...mockRunTimeParameterData, mockCsvRtp],
} as CompletedProtocolAnalysis)
Expand Down
18 changes: 7 additions & 11 deletions app/src/organisms/Devices/RecentProtocolRuns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import { HistoricalProtocolRun } from './HistoricalProtocolRun'
import { useIsRobotViewable, useRunStatuses } from './hooks'
import { useNotifyAllRunsQuery, useCurrentRunId } from '../../resources/runs'
import { useFeatureFlag } from '../../redux/config'

interface RecentProtocolRunsProps {
robotName: string
Expand All @@ -36,7 +35,6 @@ export function RecentProtocolRuns({
const currentRunId = useCurrentRunId()
const { isRunTerminal } = useRunStatuses()
const robotIsBusy = currentRunId != null ? !isRunTerminal : false
const enableCsvFile = useFeatureFlag('enableCsvFile')

return (
<Flex
Expand Down Expand Up @@ -90,15 +88,13 @@ export function RecentProtocolRuns({
>
{t('protocol')}
</LegacyStyledText>
{enableCsvFile ? (
<LegacyStyledText
as="p"
width="5%"
data-testid="RecentProtocolRuns_FilesTitle"
>
{t('files')}
</LegacyStyledText>
) : null}
<LegacyStyledText
as="p"
width="5%"
data-testid="RecentProtocolRuns_FilesTitle"
>
{t('files')}
</LegacyStyledText>
<LegacyStyledText
as="p"
width="14%"
Expand Down
Loading

0 comments on commit 8cdf2b7

Please sign in to comment.