Skip to content

Commit 53e61e9

Browse files
codemonkey800czi-github-helper[bot]
andauthored
feat: deposition metadata drawer updates (#1824)
* refactor metadata drawer to use render props * drawer set active tab state * refactor metadata drawer structure + annotation method metadata table * table spacing * tomogram methods metadata table * share mock data + interfaces * acquisition methods metadata table * experimental conditions metadata table * chore: Updated [rdev] values.yaml image tags to sha-030ca2d * use component props * chore: Updated [rdev] values.yaml image tags to sha-ce989df --------- Co-authored-by: czi-github-helper[bot] <+czi-github-helper[bot]@users.noreply.github.com>
1 parent ce4a78a commit 53e61e9

24 files changed

+534
-161
lines changed

.infra/rdev/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ stack:
22
services:
33
frontend:
44
image:
5-
tag: sha-4c4295a
5+
tag: sha-ce989df
66
replicaCount: 1
77
env:
88
- name: API_URL_V2

frontend/packages/data-portal/app/components/Dataset/DatasetMetadataDrawer.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@ export function DatasetMetadataDrawer() {
1818
title={dataset.title}
1919
label={t('datasetDetails')}
2020
idInfo={{ label: 'datasetId', text: `${IdPrefix.Dataset}-${dataset.id}` }}
21-
>
21+
MetadataTabComponent={MetadataTab}
22+
/>
23+
)
24+
}
25+
26+
function MetadataTab() {
27+
const { dataset } = useDatasetById()
28+
29+
return (
30+
<>
2231
<DatasetMetadataTable dataset={dataset} />
2332
<SampleAndExperimentConditionsTable dataset={dataset} />
2433
<DatasetTiltSeriesTable />
25-
</MetadataDrawer>
34+
</>
2635
)
2736
}

frontend/packages/data-portal/app/components/Deposition/DepositionMetadataDrawer.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { ACQUISITION_METHOD_MOCK_DATA } from 'app/components/Deposition/mock'
2+
import { useI18n } from 'app/hooks/useI18n'
3+
import { getTableData } from 'app/utils/table'
4+
5+
import { MethodTableList } from './MethodTableList'
6+
7+
export function AcquisitionMethodsMetadataTable() {
8+
const { t } = useI18n()
9+
10+
return (
11+
<MethodTableList
12+
accordionId="acquisition-methods-table"
13+
data={ACQUISITION_METHOD_MOCK_DATA}
14+
header="acquisitionMethods"
15+
getTableData={(data) =>
16+
getTableData(
17+
{
18+
label: t('microscope'),
19+
values: [data.microscope],
20+
},
21+
{
22+
label: t('camera'),
23+
values: [data.camera],
24+
},
25+
{
26+
label: t('tiltingScheme'),
27+
values: [data.tiltingScheme],
28+
},
29+
{
30+
label: t('pixelSize'),
31+
values: [data.pixelSize],
32+
},
33+
{
34+
label: t('electronOptics'),
35+
values: [data.electronOptics],
36+
},
37+
{
38+
label: t('phasePlate'),
39+
values: [data.phasePlate],
40+
},
41+
)
42+
}
43+
/>
44+
)
45+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {
2+
Annotation_Method_Link_Type_Enum,
3+
Annotation_Method_Type_Enum,
4+
} from 'app/__generated_v2__/graphql'
5+
import type { AnnotationMethodMetadata } from 'app/hooks/useDepositionById'
6+
import { useI18n } from 'app/hooks/useI18n'
7+
import { getTableData } from 'app/utils/table'
8+
9+
import { MethodLinkList } from '../MethodLinks/MethodLinkList'
10+
import { MethodTableList } from './MethodTableList'
11+
12+
const MOCK_DATA: AnnotationMethodMetadata[] = Array(2)
13+
.fill(null)
14+
.map(() => ({
15+
annotationMethod: 'Lorem ipsum dolor sit amet',
16+
count: 30,
17+
annotationSoftware: '',
18+
methodType: Annotation_Method_Type_Enum.Hybrid,
19+
methodLinks: [
20+
{
21+
name: 'Link 1',
22+
linkType: Annotation_Method_Link_Type_Enum.Website,
23+
link: 'https://example.com',
24+
},
25+
{
26+
name: 'Link 2',
27+
linkType: Annotation_Method_Link_Type_Enum.ModelsWeights,
28+
link: 'https://example.com',
29+
},
30+
{
31+
name: 'Link 3',
32+
linkType: Annotation_Method_Link_Type_Enum.Documentation,
33+
link: 'https://example.com',
34+
},
35+
],
36+
}))
37+
38+
export function AnnotationsMethodsMetadataTable() {
39+
const { t } = useI18n()
40+
41+
return (
42+
<MethodTableList
43+
accordionId="annotation-methods-table"
44+
data={MOCK_DATA}
45+
header="annotationMethods"
46+
getTableData={(data) =>
47+
getTableData(
48+
{
49+
label: t('annotations'),
50+
values: [data.count],
51+
},
52+
{
53+
label: t('methodType'),
54+
values: [data.methodType ?? ''],
55+
},
56+
{
57+
label: t('methodDetails'),
58+
values: [data.annotationMethod],
59+
},
60+
{
61+
label: t('methodLinks'),
62+
values: [],
63+
renderValues: () => (
64+
<MethodLinkList
65+
annotationMethod={data.annotationMethod}
66+
methodLinks={data.methodLinks}
67+
/>
68+
),
69+
},
70+
)
71+
}
72+
/>
73+
)
74+
}

frontend/packages/data-portal/app/components/Deposition/AnnotationsSummaryMetadataTable.tsx renamed to frontend/packages/data-portal/app/components/Deposition/DepositionMetadataDrawer/AnnotationsSummaryMetadataTable.tsx

File renamed without changes.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { MethodLinksMetadataTable } from 'app/components/Deposition/MethodLinks/MethodLinksMetadataTable'
2+
import { MetadataDrawer } from 'app/components/MetadataDrawer'
3+
import { IdPrefix } from 'app/constants/idPrefixes'
4+
import { useDepositionById } from 'app/hooks/useDepositionById'
5+
import { useI18n } from 'app/hooks/useI18n'
6+
import { MetadataDrawerId } from 'app/hooks/useMetadataDrawer'
7+
import { useFeatureFlag } from 'app/utils/featureFlags'
8+
9+
import { AcquisitionMethodsMetadataTable } from './AcquisitionMethodsMetadataTable'
10+
import { AnnotationsMethodsMetadataTable } from './AnnotationsMethodsMetadataTable'
11+
import { AnnotationsSummaryMetadataTable } from './AnnotationsSummaryMetadataTable'
12+
import { DepositionMetadataTable } from './DepositionMetadataTable'
13+
import { ExperimentalConditionsMetadataTable } from './ExperimentalConditionsMetadataTable'
14+
import { TomogramMethodsMetadataTable } from './TomogramMethodsMetadataTable'
15+
16+
export function DepositionMetadataDrawer() {
17+
const { t } = useI18n()
18+
const { deposition } = useDepositionById()
19+
const isExpandDepositions = useFeatureFlag('expandDepositions')
20+
21+
return (
22+
<MetadataDrawer
23+
drawerId={MetadataDrawerId.Deposition}
24+
title={deposition?.title ?? ''}
25+
label={t('depositionDetails')}
26+
idInfo={{
27+
label: 'depositionId',
28+
text: `${IdPrefix.Deposition}-${deposition?.id}`,
29+
}}
30+
MetadataTabComponent={MetadataTab}
31+
HowToCiteTabComponent={isExpandDepositions ? HowToCiteTab : undefined}
32+
/>
33+
)
34+
}
35+
36+
function MetadataTab() {
37+
const { deposition } = useDepositionById()
38+
const isExpandDepositions = useFeatureFlag('expandDepositions')
39+
40+
return (
41+
<>
42+
<DepositionMetadataTable deposition={deposition} />
43+
<AnnotationsSummaryMetadataTable />
44+
45+
{!isExpandDepositions && <MethodLinksMetadataTable />}
46+
</>
47+
)
48+
}
49+
50+
function HowToCiteTab() {
51+
return (
52+
<>
53+
<AnnotationsMethodsMetadataTable />
54+
<TomogramMethodsMetadataTable />
55+
<AcquisitionMethodsMetadataTable />
56+
<ExperimentalConditionsMetadataTable />
57+
</>
58+
)
59+
}

frontend/packages/data-portal/app/components/Deposition/DepositionMetadataTable.tsx renamed to frontend/packages/data-portal/app/components/Deposition/DepositionMetadataDrawer/DepositionMetadataTable.tsx

File renamed without changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { EXPERIMENTAL_CONDITIONS_MOCK_DATA } from 'app/components/Deposition/mock'
2+
import { useI18n } from 'app/hooks/useI18n'
3+
import { getTableData } from 'app/utils/table'
4+
5+
import { MethodTableList } from './MethodTableList'
6+
7+
export function ExperimentalConditionsMetadataTable() {
8+
const { t } = useI18n()
9+
10+
return (
11+
<MethodTableList
12+
accordionId="experimental-conditions-table"
13+
data={EXPERIMENTAL_CONDITIONS_MOCK_DATA}
14+
header="experimentalConditions"
15+
getTableData={(data) =>
16+
getTableData(
17+
{
18+
label: t('sampleType'),
19+
values: [data.sampleType],
20+
},
21+
{
22+
label: t('samplePreparation'),
23+
values: [data.samplePreparation],
24+
},
25+
{
26+
label: t('pixelSize'),
27+
values: [data.pixelSize],
28+
},
29+
{
30+
label: t('gridPreparation'),
31+
values: [data.gridPreparation],
32+
},
33+
{
34+
label: t('runs'),
35+
values: [data.runs],
36+
},
37+
)
38+
}
39+
/>
40+
)
41+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Accordion } from 'app/components/Accordion'
2+
import { MetadataTable } from 'app/components/Table'
3+
import { useI18n } from 'app/hooks/useI18n'
4+
import type { I18nKeys } from 'app/types/i18n'
5+
import type { TableData } from 'app/types/table'
6+
import { cns } from 'app/utils/cns'
7+
8+
export function MethodTableList<T>({
9+
data,
10+
getTableData,
11+
accordionId,
12+
header,
13+
}: {
14+
accordionId: string
15+
data: T[]
16+
header: I18nKeys
17+
getTableData(data: T): TableData[]
18+
}) {
19+
const { t } = useI18n()
20+
21+
return (
22+
<Accordion header={t(header)} id={accordionId} initialOpen>
23+
<div className="flex flex-col gap-3.5">
24+
{data.map((d, index) => {
25+
const tableData = getTableData(d)
26+
27+
return (
28+
// safe to use index as key since list never changes
29+
// eslint-disable-next-line react/no-array-index-key
30+
<div key={`method-table-${index}`}>
31+
<div className="flex items-center gap-[10px]">
32+
<p
33+
className={cns(
34+
'uppercase !text-sds-caps-xxxs-600-wide leading-sds-caps-xxxs',
35+
'font-semibold text-light-sds-color-primitive-gray-600',
36+
)}
37+
>
38+
{t('methodCount', { value: index + 1 })}
39+
</p>
40+
<div className="flex-grow h-[1px] bg-light-sds-color-primitive-gray-300" />
41+
</div>
42+
43+
<MetadataTable data={tableData} invertRowColor />
44+
</div>
45+
)
46+
})}
47+
</div>
48+
</Accordion>
49+
)
50+
}

0 commit comments

Comments
 (0)