Skip to content
Snippets Groups Projects
Commit 525ba2b3 authored by Adrian Orłów's avatar Adrian Orłów :fire:
Browse files

Revert "Merge branch 'MIN-296-clicking-map-search-event' into 'development'"

This reverts merge request !147
parent a4563456
No related branches found
No related tags found
1 merge request!149Revert "Merge branch 'MIN-296-clicking-map-search-event' into 'development'"
Pipeline #87082 passed
Showing with 14 additions and 98 deletions
......@@ -20,5 +20,5 @@ export const handleSearchResultForRightClickAction = async ({
REACTION: handleReactionResults,
}[type];
await action(dispatch, closestSearchResult)(closestSearchResult);
await action(dispatch)(closestSearchResult);
};
......@@ -24,10 +24,7 @@ describe('handleAliasResults - util', () => {
.reply(HttpStatusCode.Ok, bioEntityResponseFixture);
beforeAll(async () => {
handleAliasResults(
dispatch,
ELEMENT_SEARCH_RESULT_MOCK_ALIAS,
)(ELEMENT_SEARCH_RESULT_MOCK_ALIAS);
handleAliasResults(dispatch)(ELEMENT_SEARCH_RESULT_MOCK_ALIAS);
});
it('should run openBioEntityDrawerById as first action', async () => {
......
......@@ -3,11 +3,10 @@ import { openBioEntityDrawerById } from '@/redux/drawer/drawer.slice';
import { AppDispatch } from '@/redux/store';
import { searchFitBounds } from '@/services/pluginsManager/map/triggerSearch/searchFitBounds';
import { ElementSearchResult } from '@/types/models';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
/* prettier-ignore */
export const handleAliasResults =
(dispatch: AppDispatch, closestSearchResult: ElementSearchResult, hasFitBounds?: boolean, fitBoundsZoom?: number) =>
(dispatch: AppDispatch, hasFitBounds?: boolean, fitBoundsZoom?: number) =>
async ({ id }: ElementSearchResult): Promise<void> => {
dispatch(openBioEntityDrawerById(id));
......@@ -17,14 +16,7 @@ export const handleAliasResults =
isPerfectMatch: true
}),
)
.unwrap().then((bioEntityContents) => {
PluginsEventBus.dispatchEvent('onSearch', {
type: 'bioEntity',
searchValues: [closestSearchResult],
results: [bioEntityContents],
});
.unwrap().then(() => {
if (hasFitBounds) {
searchFitBounds(fitBoundsZoom);
}
......
......@@ -33,10 +33,7 @@ describe('handleReactionResults - util', () => {
.reply(HttpStatusCode.Ok, reactionsFixture);
beforeAll(async () => {
handleReactionResults(
dispatch,
ELEMENT_SEARCH_RESULT_MOCK_REACTION,
)(ELEMENT_SEARCH_RESULT_MOCK_REACTION);
handleReactionResults(dispatch)(ELEMENT_SEARCH_RESULT_MOCK_REACTION);
});
it('should run getReactionsByIds as first action', () => {
......
......@@ -6,11 +6,10 @@ import { AppDispatch } from '@/redux/store';
import { searchFitBounds } from '@/services/pluginsManager/map/triggerSearch/searchFitBounds';
import { ElementSearchResult, Reaction } from '@/types/models';
import { PayloadAction } from '@reduxjs/toolkit';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
/* prettier-ignore */
export const handleReactionResults =
(dispatch: AppDispatch, closestSearchResult: ElementSearchResult, hasFitBounds?: boolean, fitBoundsZoom?: number) =>
(dispatch: AppDispatch, hasFitBounds?: boolean, fitBoundsZoom?: number) =>
async ({ id }: ElementSearchResult): Promise<void> => {
const data = await dispatch(getReactionsByIds([id])) as PayloadAction<Reaction[] | undefined>;
const payload = data?.payload;
......@@ -31,13 +30,7 @@ export const handleReactionResults =
searchQueries: bioEntitiesIds,
isPerfectMatch: true },
)
).unwrap().then((bioEntityContents) => {
PluginsEventBus.dispatchEvent('onSearch', {
type: 'bioEntity',
searchValues: [closestSearchResult],
results: [bioEntityContents],
});
).unwrap().then(() => {
if (hasFitBounds) {
searchFitBounds(fitBoundsZoom);
}
......
......@@ -25,7 +25,7 @@ export const handleSearchResultAction = async ({
REACTION: handleReactionResults,
}[type];
await action(dispatch, closestSearchResult, hasFitBounds, fitBoundsZoom)(closestSearchResult);
await action(dispatch, hasFitBounds, fitBoundsZoom)(closestSearchResult);
if (type === 'ALIAS') {
PluginsEventBus.dispatchEvent('onBioEntityClick', closestSearchResult);
......
......@@ -7,7 +7,7 @@ import {
import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse';
import { HttpStatusCode } from 'axios';
import contentsReducer from './bioEntity.slice';
import { getBioEntity, getMultiBioEntity } from './bioEntity.thunks';
import { getBioEntity } from './bioEntity.thunks';
import { BioEntityContentsState } from './bioEntity.types';
const mockedAxiosClient = mockNetworkNewAPIResponse();
......@@ -56,51 +56,4 @@ describe('bioEntityContents thunks', () => {
expect(payload).toEqual(undefined);
});
});
describe('getMultiBioEntity', () => {
it('should return transformed bioEntityContent array', async () => {
mockedAxiosClient
.onGet(
apiPath.getBioEntityContentsStringWithQuery({
searchQuery: SEARCH_QUERY,
isPerfectMatch: false,
}),
)
.reply(HttpStatusCode.Ok, bioEntityResponseFixture);
const data = await store
.dispatch(
getMultiBioEntity({
searchQueries: [SEARCH_QUERY],
isPerfectMatch: false,
}),
)
.unwrap();
expect(data).toEqual(bioEntityResponseFixture.content);
});
it('should combine all returned bioEntityContent arrays and return array with all provided bioEntityContent elements', async () => {
mockedAxiosClient
.onGet(
apiPath.getBioEntityContentsStringWithQuery({
searchQuery: SEARCH_QUERY,
isPerfectMatch: false,
}),
)
.reply(HttpStatusCode.Ok, bioEntityResponseFixture);
const data = await store
.dispatch(
getMultiBioEntity({
searchQueries: [SEARCH_QUERY, SEARCH_QUERY],
isPerfectMatch: false,
}),
)
.unwrap();
expect(data).toEqual([
...bioEntityResponseFixture.content,
...bioEntityResponseFixture.content,
]);
});
});
});
import { PerfectMultiSearchParams, PerfectSearchParams } from '@/types/search';
import { PayloadAction, createAsyncThunk } from '@reduxjs/toolkit';
import { createAsyncThunk } from '@reduxjs/toolkit';
import { bioEntityResponseSchema } from '@/models/bioEntityResponseSchema';
import { apiPath } from '@/redux/apiPath';
import { axiosInstanceNewAPI } from '@/services/api/utils/axiosInstance';
......@@ -25,26 +25,17 @@ export const getBioEntity = createAsyncThunk(
);
type GetMultiBioEntityProps = PerfectMultiSearchParams;
type GetMultiBioEntityActions = PayloadAction<BioEntityContent[] | undefined>[];
export const getMultiBioEntity = createAsyncThunk(
'project/getMultiBioEntity',
async (
{ searchQueries, isPerfectMatch }: GetMultiBioEntityProps,
{ dispatch },
): Promise<BioEntityContent[]> => {
): Promise<void> => {
const asyncGetBioEntityFunctions = searchQueries.map(searchQuery =>
dispatch(getBioEntity({ searchQuery, isPerfectMatch })),
);
const bioEntityContentsActions = (await Promise.all(
asyncGetBioEntityFunctions,
)) as GetMultiBioEntityActions;
const bioEntityContents = bioEntityContentsActions
.map(bioEntityContentsAction => bioEntityContentsAction.payload || [])
.flat();
return bioEntityContents;
await Promise.all(asyncGetBioEntityFunctions);
},
);
import {
BioEntityContent,
Chemical,
CreatedOverlay,
Drug,
ElementSearchResult,
MapOverlay,
} from '@/types/models';
import { BioEntityContent, Chemical, CreatedOverlay, Drug, MapOverlay } from '@/types/models';
import { dispatchEvent } from './pluginsEventBus';
export type BackgroundEvents = 'onBackgroundOverlayChange';
......@@ -43,7 +36,7 @@ export type ClickedBioEntity = {
export type SearchDataBioEntity = {
type: 'bioEntity';
searchValues: string[] | ElementSearchResult[];
searchValues: string[];
results: BioEntityContent[][];
};
......
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