-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #467 from ProteinsWebTeam/descriptionFailover
Description failover
- Loading branch information
Showing
24 changed files
with
245 additions
and
105 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
114 changes: 114 additions & 0 deletions
114
src/components/Description/DescriptionFromIntegrated/index.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,114 @@ | ||
import React from 'react'; | ||
import { createSelector } from 'reselect'; | ||
import { format } from 'url'; | ||
|
||
import loadData from 'higherOrder/loadData/ts'; | ||
import descriptionToPath from 'utils/processDescription/descriptionToPath'; | ||
import Literature, { | ||
getLiteratureIdsFromDescription, | ||
splitCitations, | ||
} from 'components/Entry/Literature'; | ||
|
||
import Tooltip from 'components/SimpleCommonComponents/Tooltip'; | ||
import Link from 'components/generic/Link'; | ||
import Loading from 'components/SimpleCommonComponents/Loading'; | ||
import Description from 'components/Description'; | ||
import { Params } from 'src/higherOrder/loadData/extract-params'; | ||
|
||
import cssBinder from 'styles/cssBinder'; | ||
import ipro from 'styles/interpro-vf.css'; | ||
import fonts from 'EBI-Icon-fonts/fonts.css'; | ||
import local from './style.css'; | ||
|
||
const css = cssBinder(ipro, local, fonts); | ||
|
||
type Props = { | ||
integrated: string | null; | ||
}; | ||
|
||
interface IntegratedProps | ||
extends Props, | ||
LoadDataProps<{ metadata: EntryMetadata }> {} | ||
|
||
const DescriptionFromIntegrated = ({ | ||
integrated, | ||
data: { loading, payload }, | ||
}: IntegratedProps) => { | ||
if (!integrated) return null; | ||
if (loading) return <Loading />; | ||
|
||
if (payload?.metadata?.description?.length) { | ||
const citations = getLiteratureIdsFromDescription( | ||
payload.metadata.description | ||
); | ||
const [included, extra] = splitCitations( | ||
payload.metadata.literature, | ||
citations | ||
); | ||
|
||
return ( | ||
<> | ||
<h4> | ||
Description{' '} | ||
<Tooltip | ||
title={`The member database didn't provide a description for this signature. | ||
The description displayed has been imported from ${integrated}, the InterPro entry in which the signature is integrated.`} | ||
> | ||
<span className={css('tag')}> | ||
<sup> | ||
<span | ||
className={css('icon', 'icon-common', 'icon-info', 'small')} | ||
data-icon="" | ||
/>{' '} | ||
</sup> | ||
Imported from{' '} | ||
<Link | ||
to={{ | ||
description: { | ||
main: { key: 'entry' }, | ||
entry: { | ||
db: 'InterPro', | ||
accession: integrated, | ||
}, | ||
}, | ||
}} | ||
> | ||
{integrated} | ||
</Link> | ||
</span> | ||
</Tooltip> | ||
</h4> | ||
<Description | ||
textBlocks={payload.metadata.description} | ||
literature={included} | ||
accession={payload.metadata.accession} | ||
/> | ||
<h4>References</h4> | ||
<Literature included={included} extra={extra} /> | ||
</> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
||
const getUrlFor: GetUrl<Props> = createSelector( | ||
(state: GlobalState) => state.settings.api, | ||
(_state: GlobalState, props?: Props) => props?.integrated || '', | ||
(server: ParsedURLServer, accession: string) => { | ||
if (!accession) return null; | ||
const { protocol, hostname, port, root } = server; | ||
return format({ | ||
protocol, | ||
hostname, | ||
port, | ||
pathname: | ||
root + | ||
descriptionToPath({ | ||
main: { key: 'entry' }, | ||
entry: { db: 'interpro', accession }, | ||
}), | ||
}); | ||
} | ||
); | ||
|
||
export default loadData(getUrlFor as Params)(DescriptionFromIntegrated); |
4 changes: 4 additions & 0 deletions
4
src/components/Description/DescriptionFromIntegrated/style.css
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,4 @@ | ||
h4 span.tag { | ||
background-color: var(--colors-secondary-header); | ||
color: var(--colors-lightgray); | ||
} |
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
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
Oops, something went wrong.