Skip to content
Snippets Groups Projects

Merge 18.0.5

Merged Piotr Gawron requested to merge merge-18.0.5 into development
16 files
+ 78
32
Compare changes
  • Side-by-side
  • Inline
Files
16
import { NOOP } from '@/constants/common';
import { NOOP, ZERO } from '@/constants/common';
import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { mapOpenedMapsSelector } from '@/redux/map/map.selectors';
@@ -8,9 +8,12 @@ import { currentModelIdSelector, modelsDataSelector } from '@/redux/models/model
import { projectOverviewImagesSelector } from '@/redux/project/project.selectors';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { MapModel, OverviewImageLink, OverviewImageLinkModel } from '@/types/models';
import { getSearchData } from '@/redux/search/search.thunks';
import { openSearchDrawerWithSelectedTab } from '@/redux/drawer/drawer.slice';
import {
OverviewImageLinkImageHandler,
OverviewImageLinkModelHandler,
OverviewImageLinkSearchHandler,
} from '../OverviewImageModal.types';
interface UseOverviewImageLinkActionsResult {
@@ -75,6 +78,16 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
dispatch(closeModal());
};
const onSearchClick: OverviewImageLinkSearchHandler = link => {
const { query } = link;
const searchValues = query.split(',');
dispatch(getSearchData({ searchQueries: searchValues, isPerfectMatch: false }));
dispatch(openSearchDrawerWithSelectedTab(searchValues[ZERO]));
dispatch(closeModal());
};
const onImageClick: OverviewImageLinkImageHandler = link => {
const isImageAvailable = checkIfImageIsAvailable(link.linkedOverviewImage);
if (!isImageAvailable) {
@@ -87,6 +100,7 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
const handleLinkClick: UseOverviewImageLinkActionsResult['handleLinkClick'] = link => {
const isImageLink = 'linkedOverviewImage' in link;
const isModelLink = 'linkedModel' in link;
const isSearchLink = 'query' in link;
if (isImageLink) {
return onImageClick(link);
@@ -96,6 +110,10 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
return onSubmapClick(link);
}
if (isSearchLink) {
return onSearchClick(link);
}
return NOOP();
};
Loading