Skip to content

Commit

Permalink
Merge pull request #519 from ProteinsWebTeam/removed-entries
Browse files Browse the repository at this point in the history
Removed signatures
  • Loading branch information
matthiasblum authored Oct 4, 2023
2 parents b6c62ee + 99124fa commit 233da1f
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 89 deletions.
55 changes: 39 additions & 16 deletions src/components/Entry/RemovedEntrySummary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,47 @@ import ebiGlobalStyles from 'ebi-framework/css/ebi-global.css';

const f = foundationPartial(ebiGlobalStyles, fonts);

const RemovedEntrySummary = ({ detail, accession, date, history, dbInfo }) => {
const RemovedEntrySummary = ({
accession,
source_database,
type,
name,
short_name,
deletion_date,
history,
dbInfo,
}) => {
const allNames = (history?.names || []).concat(history?.short_names || []);
const formerNames = allNames.filter((n) => n !== name && n !== short_name);
const listWrap = (n) => `<li>${n}</li>`;
const metadata = {
accession: accession.toUpperCase(),
name: { name: history?.names?.[0] || '???' },
source_database: 'Removed',
type: 'unknown',
name: {
name: name,
short: short_name,
},
source_database: source_database,
type: type,
member_databases: history?.signatures,
description: [
`<b>Removed</b>: ${date}`,
'<b>Used names</b>:',
...(history?.names || []).map((n) => ` * ${n}`),
],
description:
formerNames.length !== 0
? [`<ul>${formerNames.map(listWrap).join('')}</ul>`]
: [],
is_removed: true,
};
const regex = /ipr[0-9]{6}/gi;
const detailF = (detail || '').replace(regex, accession.toUpperCase());
const date = new Date(deletion_date).toLocaleDateString('en-GB', {
month: 'long',
year: 'numeric',
});
const message = `${metadata.accession} is obsolete since ${date}.`;
return (
<div className={f('row')}>
<div className={f('medium-12', 'large-12', 'columns')}>
<EdgeCase text={detailF} status={410} shouldRedirect={false} />
<EdgeCase text={message} status={410} shouldRedirect={false} />
<Title metadata={metadata} mainType="entry" />
<SummaryEntry
data={{ metadata: { ...metadata, source_database: 'interpro' } }}
data={{ metadata: metadata }}
headerText={'Former names'}
loading={false}
dbInfo={dbInfo}
/>
Expand All @@ -42,12 +61,16 @@ const RemovedEntrySummary = ({ detail, accession, date, history, dbInfo }) => {
};

RemovedEntrySummary.propTypes = {
detail: T.string,
accession: T.string,
date: T.string,
source_database: T.string,
type: T.string,
name: T.string,
short_name: T.string,
deletion_date: T.string,
history: T.shape({
signatures: T.arrayOf(T.object),
names: T.arrayOf(T.string),
short_names: T.arrayOf(T.string),
signatures: T.object,
}),
dbInfo: T.object,
};
Expand Down
137 changes: 72 additions & 65 deletions src/components/Entry/Summary/SidePanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,80 +96,87 @@ const SidePanel = ({
{['interpro', 'pfam'].includes(
// Only receiving new annotations for pfam and interpro
metadata.source_database.toLowerCase()
) && (
<div>
<Tooltip
title={
'You may suggest updates to the annotation of this entry using this form. Suggestions will be sent to ' +
'our curators for review and, if acceptable, will be included in the next public release of InterPro. It is ' +
'helpful if you can include literature references supporting your annotation suggestion.'
}
>
<DropDownButton
label="Add your annotation"
icon="&#xf303;"
extraClasses={css('annotation')}
) &&
!metadata.is_removed && (
<div>
<Tooltip
title={
'You may suggest updates to the annotation of this entry using this form. Suggestions will be sent to ' +
'our curators for review and, if acceptable, will be included in the next public release of InterPro. It is ' +
'helpful if you can include literature references supporting your annotation suggestion.'
}
>
<form
onSubmit={handleSubmit}
className={css('vf-stack', 'vf-stack--200')}
<DropDownButton
label="Add your annotation"
icon="&#xf303;"
extraClasses={css('annotation')}
>
<label
className={css('vf-form__label', 'vf-form__label--required')}
htmlFor="message"
>
Your annotation
</label>
<textarea
id="message"
name="message"
value={message}
onChange={handleFields}
className={css('vf-form__textarea')}
rows={5}
required
/>
<label
className={css('vf-form__label', 'vf-form__label--required')}
htmlFor="from_email"
<form
onSubmit={handleSubmit}
className={css('vf-stack', 'vf-stack--200')}
>
Email address
</label>
<input
id="from_email"
name="from_email"
type="email"
value={email}
onChange={handleFields}
className={css('vf-form__input')}
required
/>
<div className={css('flex-space-evenly')}>
<button
<label
className={css(
'vf-button',
'vf-button--primary',
'vf-button--sm'
'vf-form__label',
'vf-form__label--required'
)}
htmlFor="message"
>
Submit
</button>
<button
Your annotation
</label>
<textarea
id="message"
name="message"
value={message}
onChange={handleFields}
className={css('vf-form__textarea')}
rows={5}
required
/>
<label
className={css(
'vf-button',
'vf-button--secondary',
'vf-button--sm'
'vf-form__label',
'vf-form__label--required'
)}
onClick={clearFields}
htmlFor="from_email"
>
Clear
</button>
</div>
</form>
</DropDownButton>
</Tooltip>
</div>
)}
Email address
</label>
<input
id="from_email"
name="from_email"
type="email"
value={email}
onChange={handleFields}
className={css('vf-form__input')}
required
/>
<div className={css('flex-space-evenly')}>
<button
className={css(
'vf-button',
'vf-button--primary',
'vf-button--sm'
)}
>
Submit
</button>
<button
className={css(
'vf-button',
'vf-button--secondary',
'vf-button--sm'
)}
onClick={clearFields}
>
Clear
</button>
</div>
</form>
</DropDownButton>
</Tooltip>
</div>
)}
{metadata.integrated && <Integration intr={metadata.integrated} />}
{!['interpro', 'pfam', 'antifam'].includes(
metadata.source_database.toLowerCase()
Expand Down
4 changes: 3 additions & 1 deletion src/components/Entry/Summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ type SummaryEntryProps = {
data: {
metadata: EntryMetadata;
};
headerText?: string;
loading: boolean;
dbInfo: DBInfo;
};

const SummaryEntry = ({
data: { metadata },
headerText = 'Description',
dbInfo,
loading,
}: SummaryEntryProps) => {
Expand Down Expand Up @@ -113,7 +115,7 @@ const SummaryEntry = ({
// doesn't work for some HAMAP as they have enpty <P> tag
(metadata.description || []).length ? (
<>
<h4>Description</h4>
<h4>{headerText}</h4>
<Description
textBlocks={metadata.description}
literature={included as Array<[string, Reference]>}
Expand Down
1 change: 1 addition & 0 deletions src/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ interface EntryMetadata extends Metadata {
accession: string;
name: string;
};
is_removed?: boolean;
}

type SourceOrganism = {
Expand Down
22 changes: 15 additions & 7 deletions src/pages/endpoint-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class Summary extends PureComponent {
render() {
const {
data: { status, loading, payload },
// dataOrganism: { loading: loadingOrg, payload: payloadOrg },
dataBase,
dataBase: { payload: payloadDB, loading: loadingDB },
customLocation,
subPagesForEndpoint,
} = this.props;
Expand All @@ -114,15 +113,24 @@ class Summary extends PureComponent {
main: { key: endpoint },
},
} = customLocation;
const databases = dataBase?.payload?.databases;

if (loading || (!locationhasDetailOrFilter(customLocation) && !payload)) {
return <Loading />;
}

const db =
(!loadingDB &&
payloadDB &&
payloadDB.databases &&
payloadDB.databases[customLocation.description.entry.db]) ||
{};

if (status === STATUS_GONE) {
return <RemovedEntrySummary {...payload} dbInfo={databases} />;
return <RemovedEntrySummary {...payload} dbInfo={db} />;
}
const edgeCaseText = edgeCases.get(status);
if (edgeCaseText) return <EdgeCase text={edgeCaseText} status={status} />;
if (loading || (!locationhasDetailOrFilter(customLocation) && !payload)) {
return <Loading />;
}

return (
<>
{payload?.metadata?.accession && (
Expand Down

0 comments on commit 233da1f

Please sign in to comment.