Skip to content

Commit

Permalink
Add mutation badges in a container to check e2e tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-parker committed Apr 26, 2024
1 parent f5d7e2c commit fd978c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
23 changes: 4 additions & 19 deletions website/src/components/SequenceDetailsPage/DataTable.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { DataUseTermsHistoryModal } from './DataUseTermsHistoryModal';
import { NucSubBadge, AaSubBadge } from './MutationBadge';
import { SubstitutionsContainer } from './MutationBadge';
import { toHeaderMap, type TableDataEntry } from './getTableData';
import { type DataUseTermsHistoryEntry } from '../../types/backend';
Expand Down Expand Up @@ -28,24 +28,9 @@ const headerMap = toHeaderMap(tableData);
<div class='flex items-center gap-3 whitespace-wrap'>
{customDisplay === undefined && value}
{customDisplay !== undefined &&
customDisplay.type === 'badge' &&
customDisplay.value?.map(
({ mutationFrom, mutationTo, position, sequenceName }) =>
sequenceName === undefined ? (
<NucSubBadge
mutationFrom={mutationFrom}
pos={position}
mutationTo={mutationTo}
/>
) : (
<AaSubBadge
gene={sequenceName}
mutationFrom={mutationFrom}
pos={position}
mutationTo={mutationTo}
/>
),
)}
customDisplay.type === 'badge' &&
(customDisplay.value === undefined ? '' : <SubstitutionsContainer values={customDisplay.value}/>)
}
{customDisplay !== undefined &&
customDisplay.type === 'link' &&
customDisplay.url !== undefined && (
Expand Down
11 changes: 11 additions & 0 deletions website/src/components/SequenceDetailsPage/MutationBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';
import type { MutationProportionCount } from '../../types/lapis';

type NucSubProps = {
pos: number;
Expand Down Expand Up @@ -110,3 +111,13 @@ export const AMINOACID_COLORS: Record<string, string> = {
export function getAaColor(aa: string): string {
return AMINOACID_COLORS[aa] ?? AMINOACID_COLORS.X;
}

export const SubstitutionsContainer = ({ values }: { values: MutationProportionCount[] }) => {
return values.map(({ mutationFrom, mutationTo, position, sequenceName }) =>
sequenceName === undefined ? (
<NucSubBadge mutationFrom={mutationFrom} pos={position} mutationTo={mutationTo} />
) : (
<AaSubBadge gene={sequenceName} mutationFrom={mutationFrom} pos={position} mutationTo={mutationTo} />
),
);
};

0 comments on commit fd978c4

Please sign in to comment.