Skip to content

Commit

Permalink
chore: Remove Multiple Tomograms flag (#1434)
Browse files Browse the repository at this point in the history
* delete file

* lint

* tests
  • Loading branch information
bchu1 authored Jan 3, 2025
1 parent f7754e4 commit 531ece1
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 846 deletions.
Original file line number Diff line number Diff line change
@@ -1,86 +1,42 @@
import { Callout, CalloutTitle } from '@czi-sds/components'
import RadioGroup from '@mui/material/RadioGroup'
import { useCallback, useMemo } from 'react'
import { useCallback } from 'react'
import { match } from 'ts-pattern'

import { CopyBox } from 'app/components/CopyBox'
import { I18n } from 'app/components/I18n'
import { Radio } from 'app/components/Radio'
import { Select, SelectOption } from 'app/components/Select'
import { useDownloadModalContext } from 'app/context/DownloadModal.context'
import { useDownloadModalQueryParamState } from 'app/hooks/useDownloadModalQueryParamState'
import { useI18n } from 'app/hooks/useI18n'
import { useLogPlausibleCopyEvent } from 'app/hooks/useLogPlausibleCopyEvent'
import { DownloadConfig } from 'app/types/download'
import { useFeatureFlag } from 'app/utils/featureFlags'

import { FileFormatDropdown } from './FileFormatDropdown'
import { TomogramSelector } from './Tomogram/TomogramSelector'

const TOMOGRAM_FILE_FORMATS = ['mrc', 'zarr']

export function ConfigureTomogramDownloadContent() {
const multipleTomogramsEnabled = useFeatureFlag('multipleTomograms')

const { t } = useI18n()

const {
downloadConfig,
tomogramProcessing,
tomogramSampling,
setAllAnnotationsConfig,
setTomogramConfigDeprecated,
setTomogramConfig,
setTomogramProcessing,
setTomogramSampling,
setTomogramId,
} = useDownloadModalQueryParamState()

const {
tomogramToDownload,
allAnnotationFiles = [],
allTomograms = [],
allTomogramProcessing = [],
runId,
} = useDownloadModalContext()

const tomogramSamplingOptions = useMemo<SelectOption[]>(
() =>
allTomograms.map((tomogram) => ({
key: t('unitAngstrom', { value: tomogram.voxelSpacing }),
value: `(${tomogram.sizeX}, ${tomogram.sizeY}, ${tomogram.sizeZ})px`,
})),
[allTomograms, t],
)

const tomogramProcessingOptions = useMemo<SelectOption[]>(
() =>
allTomogramProcessing.map((processing) => ({
key: processing,
value: processing,
})),
[allTomogramProcessing],
)

const setTomogramConfigWithInitialValues = useCallback(() => {
if (multipleTomogramsEnabled) {
setTomogramConfig(allTomograms[0]?.id.toString())
return
}

const tomogram = allTomograms.at(0)
const processing = allTomogramProcessing.at(0)

if (tomogram && processing) {
setTomogramConfigDeprecated(`${tomogram.voxelSpacing}`, processing)
}
}, [
allTomogramProcessing,
allTomograms,
setTomogramConfigDeprecated,
setTomogramConfig,
multipleTomogramsEnabled,
])
setTomogramConfig(allTomograms[0]?.id.toString())
}, [allTomograms, setTomogramConfig])

const { logPlausibleCopyEvent } = useLogPlausibleCopyEvent()

Expand All @@ -106,64 +62,21 @@ export function ConfigureTomogramDownloadContent() {
>
<div className="flex flex-col gap-sds-l">
<div className="flex items-center gap-sds-l pt-sds-m">
{multipleTomogramsEnabled ? (
<TomogramSelector
title={t('selectTomogram')}
selectedTomogram={tomogramToDownload}
allTomograms={allTomograms}
onSelectTomogramId={setTomogramId}
className="max-w-[450px]"
/>
) : (
<>
<Select
activeKey={
tomogramSampling
? t('unitAngstrom', { value: tomogramSampling })
: null
}
className="flex-grow"
label={
tomogramToDownload
? `${t('unitAngstrom', {
value: tomogramToDownload.voxelSpacing,
})}`
: '--'
}
onChange={(value) =>
setTomogramSampling(value ? value.replace('Å', '') : null)
}
options={tomogramSamplingOptions}
title={t('tomogramSampling')}
/>

<Select
activeKey={tomogramProcessing}
className="flex-grow"
label={tomogramProcessing ?? '--'}
onChange={setTomogramProcessing}
options={tomogramProcessingOptions}
showActiveValue={false}
showDetails={false}
title={t('tomogramProcessing')}
/>
</>
)}
<TomogramSelector
title={t('selectTomogram')}
selectedTomogram={tomogramToDownload}
allTomograms={allTomograms}
onSelectTomogramId={setTomogramId}
className="max-w-[450px]"
/>
</div>

<FileFormatDropdown
className={
!multipleTomogramsEnabled ? 'max-w-[228px]' : undefined
}
fileFormats={TOMOGRAM_FILE_FORMATS}
selectDropdownClasses={
multipleTomogramsEnabled
? {
root: 'w-[436px]',
listbox: '!pr-0',
}
: undefined
}
selectDropdownClasses={{
root: 'w-[436px]',
listbox: '!pr-0',
}}
/>
</div>
</Radio>
Expand Down Expand Up @@ -206,11 +119,9 @@ export function ConfigureTomogramDownloadContent() {
</Callout>
)}

{multipleTomogramsEnabled && (
<Callout intent="notice" className="!w-full !mt-0">
<I18n i18nKey="annotationsMayRequireTransformation" />
</Callout>
)}
<Callout intent="notice" className="!w-full !mt-0">
<I18n i18nKey="annotationsMayRequireTransformation" />
</Callout>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { useDownloadModalQueryParamState } from 'app/hooks/useDownloadModalQuery
import { useI18n } from 'app/hooks/useI18n'
import { DownloadConfig, DownloadTab } from 'app/types/download'
import { checkExhaustive } from 'app/types/utils'
import { useFeatureFlag } from 'app/utils/featureFlags'
import { getTomogramName } from 'app/utils/tomograms'

import { I18n } from '../I18n'
Expand All @@ -35,13 +34,11 @@ const DOWNLOAD_TAB_MAP: Record<DownloadTab, ComponentType> = {
}

export function DownloadOptionsContent() {
const multipleTomogramsEnabled = useFeatureFlag('multipleTomograms')
const { t } = useI18n()
const {
downloadTab,
setDownloadTab,
downloadConfig,
tomogramProcessing,
tomogramSampling,
annotationId,
referenceTomogramId,
Expand Down Expand Up @@ -74,7 +71,7 @@ export function DownloadOptionsContent() {
<>
<ModalSubtitle label={t('datasetName')} value={datasetTitle} />
{runName && <ModalSubtitle label={t('runName')} value={runName} />}
{multipleTomogramsEnabled && tomogramToDownload !== undefined && (
{tomogramToDownload !== undefined && (
<>
<ModalSubtitle
label={t('tomogramName')}
Expand Down Expand Up @@ -112,34 +109,18 @@ export function DownloadOptionsContent() {
{objectShapeType && (
<ModalSubtitle label={t('objectShapeType')} value={objectShapeType} />
)}
{multipleTomogramsEnabled && referenceTomogram !== undefined && (
{referenceTomogram !== undefined && (
<ModalSubtitle
label={t('referenceTomogram')}
value={getTomogramName(referenceTomogram)}
/>
)}
{!multipleTomogramsEnabled && tomogramSampling && tomogramToDownload && (
{annotationToDownload && tomogramToDownload?.alignment && (
<ModalSubtitle
label={t('tomogramSampling')}
value={`${t('unitAngstrom', { value: tomogramSampling })}, (${
tomogramToDownload.sizeX
}, ${tomogramToDownload.sizeY}, ${tomogramToDownload.sizeZ})px`}
/>
)}
{!multipleTomogramsEnabled && tomogramProcessing && (
<ModalSubtitle
label={t('tomogramProcessing')}
value={tomogramProcessing}
label={t('alignmentId')}
value={tomogramToDownload.alignment.id}
/>
)}
{multipleTomogramsEnabled &&
annotationToDownload &&
tomogramToDownload?.alignment && (
<ModalSubtitle
label={t('alignmentId')}
value={tomogramToDownload.alignment.id}
/>
)}
{annotationToDownload && (
<ModalSubtitle
label={t('alignmentId')}
Expand Down Expand Up @@ -182,9 +163,7 @@ export function DownloadOptionsContent() {

<DownloadTabContent />

{multipleTomogramsEnabled &&
annotationToDownload !== undefined &&
tomogramToDownload?.alignment ? (
{annotationToDownload !== undefined && tomogramToDownload?.alignment ? (
<AnnotationAlignmentCallout
alignmentId={tomogramToDownload.alignment.id}
initialState="closed"
Expand Down
9 changes: 1 addition & 8 deletions frontend/packages/data-portal/app/components/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createElement, MouseEvent, ReactNode } from 'react'
import { useDownloadModalQueryParamState } from 'app/hooks/useDownloadModalQueryParamState'
import { DownloadConfig } from 'app/types/download'
import { cns } from 'app/utils/cns'
import { useFeatureFlag } from 'app/utils/featureFlags'

import { Tooltip } from '../Tooltip'

Expand All @@ -25,7 +24,6 @@ export function Radio({
onClick?(): void
value: DownloadConfig
}) {
const multipleTomogramsEnabled = useFeatureFlag('multipleTomograms')
const { downloadConfig } = useDownloadModalQueryParamState()
const isActive = downloadConfig === value

Expand Down Expand Up @@ -54,12 +52,7 @@ export function Radio({
<InputRadio value={value} disabled={disabled} />
</div>

<div
className={cns(
'flex flex-col gap-sds-xxxs !tracking-[0.3px]',
multipleTomogramsEnabled && 'grow',
)}
>
<div className={cns('flex flex-col gap-sds-xxxs !tracking-[0.3px] grow')}>
<span
className={cns(
'text-sds-header-s leading-sds-header-s font-semibold',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function AnnotationOverviewTable() {
const { activeAnnotation: annotation } = useAnnotation()
const { t } = useI18n()
const isDepositionsEnabled = useFeatureFlag('depositions')
const multipleTomogramsEnabled = useFeatureFlag('multipleTomograms')

const methodLinks = useMemo(
() =>
Expand Down Expand Up @@ -97,30 +96,26 @@ export function AnnotationOverviewTable() {
label: t('lastModifiedDate'),
values: [annotation.last_modified_date ?? '--'],
},
...(multipleTomogramsEnabled
? [
{
label: t('alignmentId'),
labelExtra: (
<Tooltip
tooltip={<I18n i18nKey="alignmentIdTooltip" />}
placement="top"
>
<Icon
sdsIcon="InfoCircle"
sdsSize="s"
className="!fill-sds-color-primitive-gray-500"
sdsType="button"
/>
</Tooltip>
),
values: [
v2AnnotationShape?.annotationFiles.edges.at(0)?.node
.alignmentId ?? '--',
],
},
]
: []),
{
label: t('alignmentId'),
labelExtra: (
<Tooltip
tooltip={<I18n i18nKey="alignmentIdTooltip" />}
placement="top"
>
<Icon
sdsIcon="InfoCircle"
sdsSize="s"
className="!fill-sds-color-primitive-gray-500"
sdsType="button"
/>
</Tooltip>
),
values: [
v2AnnotationShape?.annotationFiles.edges.at(0)?.node.alignmentId ??
'--',
],
},
{
label: t('methodType'),
values: [annotation.method_type ?? '--'],
Expand Down
Loading

0 comments on commit 531ece1

Please sign in to comment.