Skip to content
Snippets Groups Projects
Commit f1c572f2 authored by Adrian Orłów's avatar Adrian Orłów
Browse files

fix: pr rfc changes

parent e92abcca
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!62feat: add reactions details on map + interactive layer improvements
Pipeline #82268 passed
Showing
with 32 additions and 26 deletions
/* eslint-disable no-magic-numbers */
import { drugsFixture } from '@/models/fixtures/drugFixtures';
import { chemicalsFixture } from '@/models/fixtures/chemicalsFixture';
import { drugsFixture } from '@/models/fixtures/drugFixtures';
import { StoreType } from '@/redux/store';
import {
InitialStoreState,
getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore';
import { render, screen } from '@testing-library/react';
import { PinItem, PinType } from '../PinsList/PinsList.types';
import { PinItem, PinTypeWithNone } from '../PinsList/PinsList.types';
import { AccordionsDetails } from './AccordionsDetails.component';
const DRUGS_PINS_LIST = drugsFixture.map(drug => ({
......@@ -24,7 +24,7 @@ const CHEMICALS_PINS_LIST = chemicalsFixture.map(chemical => ({
const renderComponent = (
pinsList: PinItem[],
type: PinType,
type: PinTypeWithNone,
initialStoreState: InitialStoreState = {},
): { store: StoreType } => {
const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState);
......
......@@ -5,7 +5,7 @@ import {
AccordionItemHeading,
AccordionItemPanel,
} from '@/shared/Accordion';
import { PinItem, PinType } from '../PinsList/PinsList.types';
import { PinItem, PinTypeWithNone } from '../PinsList/PinsList.types';
import {
getAdditionalInfo,
getEntityDescriptions,
......@@ -15,7 +15,7 @@ import {
interface AccordionsDetailsProps {
pinsList: PinItem[];
type: PinType;
type: PinTypeWithNone;
}
export const AccordionsDetails = ({ pinsList, type }: AccordionsDetailsProps): JSX.Element => {
......
import { PinItem, PinType } from '../PinsList/PinsList.types';
import { PinItem, PinTypeWithNone } from '../PinsList/PinsList.types';
export const getEntityNames = (pinsList: PinItem[]): string => {
let name = '';
......@@ -34,7 +34,7 @@ export const getEntitySynonyms = (pinsList: PinItem[]): string => {
return synonyms;
};
export const getAdditionalInfo = (pinsList: PinItem[], type: PinType): string => {
export const getAdditionalInfo = (pinsList: PinItem[], type: PinTypeWithNone): string => {
if (type === 'drugs') {
return pinsList
.map(element => ('bloodBrainBarrier' in element.data ? element.data.bloodBrainBarrier : ''))
......
import { assertNever } from '@/utils/assertNever';
import { AccordionsDetails } from '../AccordionsDetails/AccordionsDetails.component';
import { PinItem, PinType } from './PinsList.types';
import { PinItem, PinTypeWithNone } from './PinsList.types';
import { PinsListItem } from './PinsListItem';
interface PinsListProps {
pinsList: PinItem[];
type: PinType;
type: PinTypeWithNone;
}
export const PinsList = ({ pinsList, type }: PinsListProps): JSX.Element => {
......
import { Drug, Chemical, Mirna } from '@/types/models';
import { Chemical, Drug, Mirna } from '@/types/models';
import { PinType } from '@/types/pin';
export type PinItem = {
id: string | number;
......@@ -6,4 +7,4 @@ export type PinItem = {
data: Drug | Chemical | Mirna;
};
export type PinType = 'chemicals' | 'drugs' | 'mirna' | 'bioEntity' | 'none';
export type PinTypeWithNone = PinType | 'none';
import { twMerge } from 'tailwind-merge';
import { Icon } from '@/shared/Icon';
import { PinDetailsItem } from '@/types/models';
import { twMerge } from 'tailwind-merge';
import { PinTypeWithNone } from '../PinsList.types';
import { getPinColor } from './PinsListItem.component.utils';
import { PinType } from '../PinsList.types';
interface MirnaPinsListItemProps {
name: string;
type: PinType;
type: PinTypeWithNone;
pin: PinDetailsItem;
}
......
import { PinType } from '../PinsList.types';
import { PinTypeWithNone } from '../PinsList.types';
export const getPinColor = (type: PinType): string => {
const pinColors: Record<PinType, string> = {
export const getPinColor = (type: PinTypeWithNone): string => {
const pinColors: Record<PinTypeWithNone, string> = {
bioEntity: 'fill-primary-500',
drugs: 'fill-orange',
chemicals: 'fill-purple',
......
import { PinType } from '@/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsList.types';
import { ONE } from '@/constants/common';
import { BioEntity } from '@/types/models';
import { PinType } from '@/types/pin';
import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection';
import { Feature } from 'ol';
import { getBioEntitySingleFeature } from './getBioEntitySingleFeature';
......@@ -19,6 +19,7 @@ export const getBioEntitiesFeatures = (
getBioEntitySingleFeature(bioEntity, {
pointToProjection,
type,
// pin's index number
value: index + ONE,
}),
);
......
import { PinType } from '@/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsList.types';
import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
import { initialMapStateFixture } from '@/redux/map/map.fixtures';
import { PinType } from '@/types/pin';
import { UsePointToProjectionResult, usePointToProjection } from '@/utils/map/usePointToProjection';
import {
GetReduxWrapperUsingSliceReducer,
......@@ -29,7 +29,7 @@ describe('getBioEntitiesFeatures - subUtil', () => {
const bioEntities = bioEntititesContent.map(({ bioEntity }) => bioEntity);
const pointToProjection = getPointToProjection(Wrapper);
const pinTypes: PinType[] = ['bioEntity', 'drugs', 'chemicals', 'mirna', 'none'];
const pinTypes: PinType[] = ['bioEntity', 'drugs', 'chemicals', 'mirna'];
it.each(pinTypes)('should return array of instances of Feature with Style type=%s', type => {
const result = getBioEntitiesFeatures(bioEntities, {
......
import { PinType } from '@/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsList.types';
import { PINS_COLORS } from '@/constants/canvas';
import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
import { initialMapStateFixture } from '@/redux/map/map.fixtures';
import { PinType } from '@/types/pin';
import { UsePointToProjectionResult, usePointToProjection } from '@/utils/map/usePointToProjection';
import {
GetReduxWrapperUsingSliceReducer,
......@@ -38,7 +38,7 @@ describe('getBioEntitySingleFeature - subUtil', () => {
const pointToProjection = getPointToProjection(Wrapper);
const value = 1448;
const pinTypes: PinType[] = ['bioEntity', 'drugs', 'chemicals', 'mirna', 'none'];
const pinTypes: PinType[] = ['bioEntity', 'drugs', 'chemicals', 'mirna'];
it.each(pinTypes)('should return instance of Feature with Style type=%s', type => {
const result = getBioEntitySingleFeature(bioEntity, {
......@@ -47,8 +47,10 @@ describe('getBioEntitySingleFeature - subUtil', () => {
value,
});
const style = result.getStyle() as Style;
expect(result).toBeInstanceOf(Feature);
expect(result.getStyle()).toBeInstanceOf(Style);
expect(style).toBeInstanceOf(Style);
});
it.each(pinTypes)('should run getPinStyle with valid args for type=%s', async type => {
......
import { PinType } from '@/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsList.types';
import { PINS_COLORS } from '@/constants/canvas';
import { BioEntity } from '@/types/models';
import { PinType } from '@/types/pin';
import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection';
import { Feature } from 'ol';
import { getPinFeature } from './getPinFeature';
......
......@@ -10,6 +10,8 @@ import { handleSearchResultAction } from './handleSearchResultAction';
export const onMapSingleClick =
(mapSize: MapSize, modelId: number, dispatch: AppDispatch) =>
async ({ coordinate }: MapBrowserEvent<UIEvent>): Promise<void> => {
// side-effect below is to prevent complications with data update - old data may conflict with new data
// so we need to reset all the data before updating
dispatch(handleDataReset);
const searchResults = await getSearchResults({ coordinate, mapSize, modelId });
......
import { PinType } from '@/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsList.types';
import { PinType } from '@/types/pin';
export const PIN_PATH2D =
'M12.3077 0C6.25641 0 0 4.61538 0 12.3077C0 19.5897 11.0769 30.9744 11.5897 31.4872C11.7949 31.6923 12 31.7949 12.3077 31.7949C12.6154 31.7949 12.8205 31.6923 13.0256 31.4872C13.5385 30.9744 24.6154 19.6923 24.6154 12.3077C24.6154 4.61538 18.359 0 12.3077 0Z';
......@@ -13,7 +13,6 @@ export const PINS_COLORS: Record<PinType, string> = {
chemicals: '#640CE3',
bioEntity: '#106AD7',
mirna: '#F1009F',
none: '#000',
};
export const LINE_COLOR = '#00AAFF';
......
export type PinType = 'chemicals' | 'drugs' | 'mirna' | 'bioEntity';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment