-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a separate publication tab to the explore page
- Loading branch information
Showing
5 changed files
with
246 additions
and
26 deletions.
There are no files selected for viewing
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
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
164 changes: 164 additions & 0 deletions
164
packages/data-portal-explore/src/components/PublicationTable.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,164 @@ | ||
import _ from 'lodash'; | ||
import React from 'react'; | ||
import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { | ||
AtlasDescription, | ||
getPublicationAuthors, | ||
getPublicationDate, | ||
getPublicationDOI, | ||
getPublicationJournal, | ||
getPublicationPubMedID, | ||
getPublicationTitle, | ||
getPublicationUid, | ||
PublicationContentType, | ||
PublicationManifest, | ||
PublicationSummary, | ||
} from '@htan/data-portal-commons'; | ||
import { | ||
EnhancedDataTable, | ||
getDefaultDataTableStyle, | ||
} from '@htan/data-portal-table'; | ||
import { truncatedTableCell } from '@htan/data-portal-explore'; | ||
|
||
interface IPublicationTableProps { | ||
publicationManifestByUid: { [uid: string]: PublicationManifest }; | ||
publicationSummaryByPubMedID?: { [pubMedId: string]: PublicationSummary }; | ||
} | ||
|
||
export const PublicationTable: React.FunctionComponent<IPublicationTableProps> = ( | ||
props | ||
) => { | ||
const getSummary = (manifest: PublicationManifest) => | ||
props.publicationSummaryByPubMedID?.[getPublicationPubMedID(manifest)]; | ||
|
||
const columns = [ | ||
{ | ||
name: 'Title', | ||
selector: (manifest: PublicationManifest) => | ||
getPublicationTitle(getSummary(manifest), manifest), | ||
cell: (manifest: PublicationManifest) => ( | ||
<a | ||
href={`//${ | ||
window.location.host | ||
}/publications/${getPublicationUid(manifest)}`} | ||
> | ||
{getPublicationTitle(getSummary(manifest), manifest)} | ||
</a> | ||
), | ||
wrap: true, | ||
sortable: true, | ||
}, | ||
{ | ||
name: 'Atlas', | ||
selector: (manifest: PublicationManifest) => manifest.atlas_name, | ||
cell: (manifest: PublicationManifest) => ( | ||
<AtlasDescription | ||
atlasMeta={manifest.AtlasMeta} | ||
atlasName={manifest.AtlasMeta.lead_institutions} | ||
/> | ||
), | ||
wrap: true, | ||
sortable: true, | ||
}, | ||
{ | ||
name: 'Authors', | ||
selector: (manifest: PublicationManifest) => | ||
getPublicationAuthors(getSummary(manifest), manifest).join( | ||
', ' | ||
), | ||
cell: truncatedTableCell, | ||
wrap: true, | ||
sortable: true, | ||
}, | ||
{ | ||
name: 'Journal', | ||
selector: (manifest: PublicationManifest) => | ||
getPublicationJournal(getSummary(manifest), manifest), | ||
wrap: true, | ||
sortable: true, | ||
}, | ||
{ | ||
name: 'DOI', | ||
selector: (manifest: PublicationManifest) => | ||
getPublicationDOI(getSummary(manifest), manifest), | ||
cell: (manifest: PublicationManifest) => { | ||
const doi = getPublicationDOI(getSummary(manifest), manifest); | ||
return doi ? ( | ||
<a href={`https://doi.org/${doi}`}> | ||
{doi} <FontAwesomeIcon icon={faExternalLinkAlt} /> | ||
</a> | ||
) : undefined; | ||
}, | ||
wrap: true, | ||
sortable: true, | ||
}, | ||
{ | ||
name: 'PubMed', | ||
selector: (manifest: PublicationManifest) => | ||
getPublicationPubMedID(manifest), | ||
cell: (manifest: PublicationManifest) => { | ||
const pubmedId = getPublicationPubMedID(manifest); | ||
return pubmedId ? ( | ||
<a href={`https://pubmed.ncbi.nlm.nih.gov/${pubmedId}`}> | ||
{pubmedId} <FontAwesomeIcon icon={faExternalLinkAlt} /> | ||
</a> | ||
) : undefined; | ||
}, | ||
wrap: true, | ||
sortable: true, | ||
}, | ||
{ | ||
name: 'Content Type', | ||
selector: (manifest: PublicationManifest) => | ||
manifest.PublicationContentType, | ||
cell: (manifest: PublicationManifest) => { | ||
if ( | ||
manifest.PublicationContentType?.toLowerCase() === | ||
PublicationContentType.Prepublication | ||
) { | ||
return <span className="text-danger">In Review</span>; | ||
} else if ( | ||
manifest.PublicationContentType?.toLowerCase() === | ||
PublicationContentType.Preprint | ||
) { | ||
return <span>Preprint</span>; | ||
} else if ( | ||
manifest.PublicationContentType?.toLowerCase() === | ||
PublicationContentType.Published | ||
) { | ||
return <span>Published</span>; | ||
} else { | ||
return manifest.PublicationContentType; | ||
} | ||
}, | ||
wrap: true, | ||
sortable: true, | ||
}, | ||
{ | ||
name: 'Publication Date', | ||
selector: (manifest: PublicationManifest) => | ||
getPublicationDate(getSummary(manifest), manifest), | ||
wrap: true, | ||
sortable: true, | ||
}, | ||
]; | ||
|
||
return ( | ||
<EnhancedDataTable | ||
columns={columns} | ||
data={_.values(props.publicationManifestByUid)} | ||
defaultSortField="YearofPublication" | ||
defaultSortAsc={false} | ||
striped={true} | ||
dense={false} | ||
noHeader={true} | ||
pagination={true} | ||
paginationPerPage={50} | ||
paginationRowsPerPageOptions={[10, 20, 50, 100, 500]} | ||
customStyles={getDefaultDataTableStyle()} | ||
/> | ||
); | ||
}; | ||
|
||
export default PublicationTable; |
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