Skip to content

Commit 32e643e

Browse files
feat: dataset metadata drawer updates (#1819)
* dataset metadata drawer updates * show minus icon when showing all
1 parent 5a1ecd1 commit 32e643e

File tree

1 file changed

+57
-31
lines changed

1 file changed

+57
-31
lines changed

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

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Icon } from '@czi-sds/components'
1+
import { Button, Icon } from '@czi-sds/components'
2+
import { type ReactNode, useState } from 'react'
23

34
import { AccordionMetadataTable } from 'app/components/AccordionMetadataTable'
45
import { AuthorLegend } from 'app/components/AuthorLegend'
@@ -11,6 +12,29 @@ import { Dataset } from 'app/types/gql/genericTypes'
1112
import { isDefined } from 'app/utils/nullish'
1213
import { getTableData } from 'app/utils/table'
1314

15+
function DatasetDescription({ children }: { children: ReactNode }) {
16+
const [showAll, setShowAll] = useState(false)
17+
const { t } = useI18n()
18+
19+
return (
20+
<>
21+
<span className={showAll ? '' : 'text-ellipsis line-clamp-3'}>
22+
{children}
23+
</span>
24+
25+
<Button
26+
startIcon={<Icon sdsIcon={showAll ? 'Minus' : 'Plus'} sdsSize="xs" />}
27+
sdsStyle="minimal"
28+
onClick={() => setShowAll((prev) => !prev)}
29+
>
30+
<span className="text-light-sds-color-primitive-blue-500">
31+
{t(showAll ? 'showLess' : 'showMore')}
32+
</span>
33+
</Button>
34+
</>
35+
)
36+
}
37+
1438
export function DatasetMetadataTable({
1539
dataset,
1640
showAllFields,
@@ -52,37 +76,55 @@ export function DatasetMetadataTable({
5276
values: [dataset.id ? `${IdPrefix.Dataset}-${dataset.id}` : '--'],
5377
},
5478

55-
!!showAllFields && {
79+
{
80+
label: authors.length === 1 ? t('author') : t('authors'),
81+
labelExtra: <AuthorLegend inline />,
82+
renderValue: () => {
83+
return <AuthorList authors={authors} large vertical />
84+
},
85+
values: [],
86+
className: 'leading-sds-body-s',
87+
},
88+
89+
{
90+
label: t('publications'),
91+
values: [dataset.datasetPublications ?? ''],
92+
renderValue: (value: string) => {
93+
return <DatabaseEntryList entries={value} />
94+
},
95+
},
96+
97+
{
98+
label: t('relatedDatabases'),
99+
values: [dataset.relatedDatabaseEntries ?? ''],
100+
renderValue: (value: string) => {
101+
return <DatabaseEntryList entries={value} />
102+
},
103+
},
104+
105+
{
56106
label: t('description'),
57107
values: [dataset.description ?? ''],
58-
className: 'text-ellipsis line-clamp-3',
108+
renderValue: (value: string) => {
109+
return <DatasetDescription>{value}</DatasetDescription>
110+
},
59111
},
60112

61113
{
62114
label: t('depositionDate'),
63115
values: [dataset.depositionDate?.split('T')[0] ?? ''],
64116
},
65117

66-
!!showAllFields && {
118+
{
67119
label: t('releaseDate'),
68120
values: [dataset.releaseDate?.split('T')[0] ?? ''],
69121
},
70122

71-
!!showAllFields && {
123+
{
72124
label: t('lastModifiedDate'),
73125
values: [dataset.lastModifiedDate?.split('T')[0] ?? ''],
74126
},
75127

76-
!!showAllFields && {
77-
label: authors.length === 1 ? t('author') : t('authors'),
78-
labelExtra: <AuthorLegend inline />,
79-
renderValue: () => {
80-
return <AuthorList authors={authors} large vertical />
81-
},
82-
values: [],
83-
className: 'leading-sds-body-s',
84-
},
85-
86128
{
87129
label: t('grantID'),
88130
values: Array.from(
@@ -104,22 +146,6 @@ export function DatasetMetadataTable({
104146
),
105147
),
106148
},
107-
108-
{
109-
label: t('relatedDatabases'),
110-
values: [dataset.relatedDatabaseEntries ?? ''],
111-
renderValue: (value: string) => {
112-
return <DatabaseEntryList entries={value} />
113-
},
114-
},
115-
116-
!!showAllFields && {
117-
label: t('publications'),
118-
values: [dataset.relatedDatabaseEntries ?? ''],
119-
renderValue: (value: string) => {
120-
return <DatabaseEntryList entries={value} />
121-
},
122-
},
123149
)
124150

125151
return (

0 commit comments

Comments
 (0)