-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add single run metadata table (#124)
Implemented as in #40. Contains a few refactoring changes for tables. https://github.com/chanzuckerberg/cryoet-data-portal/assets/29165011/c26ad83d-bfef-4631-9af1-7ab44e8b1d14
- Loading branch information
Showing
30 changed files
with
1,109 additions
and
357 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
frontend/packages/data-portal/app/components/AccordionMetadataTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ComponentProps } from 'react' | ||
|
||
import { Accordion } from 'app/components/Accordion' | ||
import { MetadataTable } from 'app/components/Table' | ||
|
||
type AccordionProps = Pick< | ||
ComponentProps<typeof Accordion>, | ||
'id' | 'header' | 'initialOpen' | ||
> | ||
type MetadataTableProps = Pick< | ||
ComponentProps<typeof MetadataTable>, | ||
'data' | 'tableCellProps' | 'tableHeaderProps' | ||
> | ||
|
||
export function AccordionMetadataTable({ | ||
data, | ||
header, | ||
id, | ||
initialOpen = true, | ||
tableCellProps, | ||
tableHeaderProps, | ||
}: AccordionProps & MetadataTableProps) { | ||
return ( | ||
<Accordion id={id} header={header} initialOpen={initialOpen}> | ||
<MetadataTable | ||
data={data} | ||
tableHeaderProps={{ | ||
renderLoadingSkeleton: false, | ||
...tableHeaderProps, | ||
}} | ||
tableCellProps={{ | ||
renderLoadingSkeleton: false, | ||
...tableCellProps, | ||
}} | ||
/> | ||
</Accordion> | ||
) | ||
} |
51 changes: 51 additions & 0 deletions
51
frontend/packages/data-portal/app/components/DatabaseEntry.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Link } from 'app/components/Link' | ||
import { | ||
DatabaseType, | ||
LABEL_MAP, | ||
REGEX_MAP, | ||
URL_MAP, | ||
} from 'app/constants/external-dbs' | ||
import { cns } from 'app/utils/cns' | ||
|
||
interface DatabaseEntryProps { | ||
entry: string | ||
inline?: boolean | ||
} | ||
|
||
export function DatabaseEntry(props: DatabaseEntryProps) { | ||
const { entry, inline } = props | ||
let dbtype: DatabaseType | undefined | ||
let id: string = '' | ||
|
||
for (const [dbt, pattern] of REGEX_MAP) { | ||
const match = pattern.exec(entry) | ||
if (match !== null) { | ||
dbtype = dbt | ||
// eslint-disable-next-line prefer-destructuring | ||
id = match[1] | ||
break | ||
} | ||
} | ||
|
||
if (dbtype === undefined) { | ||
return <p>{entry}</p> | ||
} | ||
|
||
return ( | ||
<p className="flex flex-row gap-sds-xs"> | ||
{(!inline || dbtype === DatabaseType.DOI) && ( | ||
<span | ||
className={cns('text-sds-gray-black', !inline && 'font-semibold')} | ||
> | ||
{LABEL_MAP.get(dbtype)}: | ||
</span> | ||
)} | ||
<Link | ||
className={cns('text-sds-info-400', inline && 'truncate')} | ||
to={URL_MAP.get(dbtype) + id} | ||
> | ||
{entry} | ||
</Link> | ||
</p> | ||
) | ||
} |
24 changes: 0 additions & 24 deletions
24
frontend/packages/data-portal/app/components/Dataset/AccordionMetadataTable.tsx
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
frontend/packages/data-portal/app/components/Dataset/DatasetAuthors.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Dataset_Authors } from 'app/__generated__/graphql' | ||
import { EnvelopeIcon } from 'app/components/icons' | ||
import { Link } from 'app/components/Link' | ||
|
||
export type AuthorInfo = Pick< | ||
Dataset_Authors, | ||
'name' | 'primary_author_status' | 'corresponding_author_status' | 'email' | ||
> | ||
|
||
export function DatasetAuthors({ | ||
authors, | ||
className, | ||
}: { | ||
authors: AuthorInfo[] | ||
className?: string | ||
}) { | ||
// TODO: make the below grouping more efficient and/or use GraphQL ordering | ||
const authorsPrimary = authors.filter( | ||
(author) => author.primary_author_status, | ||
) | ||
const authorsCorresponding = authors.filter( | ||
(author) => author.corresponding_author_status, | ||
) | ||
const authorsOther = authors.filter( | ||
(author) => | ||
!(author.primary_author_status || author.corresponding_author_status), | ||
) | ||
|
||
const envelopeIcon = ( | ||
<EnvelopeIcon className="text-sds-gray-400 mx-sds-xxxs align-top inline-block h-sds-icon-xs w-sds-icon-xs" /> | ||
) | ||
|
||
// TODO: let's find a better way of doing this | ||
return ( | ||
<p className={className}> | ||
<span className="font-semibold"> | ||
{authorsPrimary.map((author, i, arr) => ( | ||
<> | ||
{author.name} | ||
{!( | ||
authorsOther.length + authorsCorresponding.length === 0 && | ||
arr.length - 1 === i | ||
) && '; '} | ||
</> | ||
))} | ||
</span> | ||
<span className="text-sds-gray-600"> | ||
{authorsOther.map((author, i, arr) => ( | ||
<> | ||
{author.name} | ||
{!(authorsCorresponding.length === 0 && arr.length - 1 === i) && | ||
'; '} | ||
</> | ||
))} | ||
{authorsCorresponding.map((author, i, arr) => ( | ||
<> | ||
{author.name} | ||
{author.email ? ( | ||
<Link to={`mailto:${author.email}`}>{envelopeIcon}</Link> | ||
) : ( | ||
envelopeIcon | ||
)} | ||
{!(arr.length - 1 === i) && '; '} | ||
</> | ||
))} | ||
</span> | ||
</p> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.