diff --git a/CHANGELOG b/CHANGELOG index c918ec8ab49aae104a394936ea74f7cda8599e5f..902cddca671ea45f1b4f6e4ba8c2523354b06b44 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ minerva-front (18.0.8) stable; urgency=medium + * Small improvement: support for links that should be opened immediately + (#342) * Bug fix: data overlay removal did not work (#333) * Bug fix: submap download did not download selected map (#337) diff --git a/public/config.js b/public/config.js index 4d245aa0d429a56c8c6eb2e3cf44078f4edef59e..b9e38b92679505dbf5d7de750f41878c386ce0ed 100644 --- a/public/config.js +++ b/public/config.js @@ -1,11 +1,12 @@ // const root = 'https://minerva-dev.lcsb.uni.lu'; // const root = 'https://scimap.lcsb.uni.lu'; -const root = 'https://lux1.atcomp.pl'; +// const root = 'https://lux1.atcomp.pl'; +const root = 'http://localhost:8080'; window.config = { BASE_API_URL: `${root}/minerva/api`, BASE_NEW_API_URL: `${root}/minerva/new_api/`, - BASE_MAP_IMAGES_URL: `${root}/`, + BASE_MAP_IMAGES_URL: `${root}`, DEFAULT_PROJECT_ID: 'sample', ADMIN_PANEL_URL: `${root}/minerva/admin.xhtml`, }; diff --git a/src/components/Map/Drawer/ProjectInfoDrawer/ProjectInfoDrawer.component.tsx b/src/components/Map/Drawer/ProjectInfoDrawer/ProjectInfoDrawer.component.tsx index 80c6cd351b1dce422bbc0cec3c861e2f481c1dbf..f1a8a2b897513e95c9f58850870214518ee04765 100644 --- a/src/components/Map/Drawer/ProjectInfoDrawer/ProjectInfoDrawer.component.tsx +++ b/src/components/Map/Drawer/ProjectInfoDrawer/ProjectInfoDrawer.component.tsx @@ -31,9 +31,6 @@ export const ProjectInfoDrawer = (): JSX.Element => { const sourceDownloadLink = BASE_API_URL + apiPath.getSourceFile(); - // eslint-disable-next-line no-console - console.log(sourceDownloadLink); - let licenseName: string = ''; if (project) { licenseName = project.license ? project.license.name : project.customLicenseName; diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx index 64d82fabf6a64324b2f08d52f52c4166541434d6..2f20b71dce6ab874779cbe8b735ec8fb90665143 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx @@ -1,4 +1,4 @@ -import { FIRST_ARRAY_ELEMENT } from '@/constants/common'; +import { FIRST_ARRAY_ELEMENT, ZERO } from '@/constants/common'; import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture'; import { MODELS_MOCK } from '@/models/mocks/modelsMock'; import { INITIAL_STORE_STATE_MOCK } from '@/redux/root/root.fixtures'; @@ -110,7 +110,9 @@ describe('BioEntitiesAccordion - component', () => { expect(screen.getByText(`Content (${countAll})`)).toBeInTheDocument(); expect(screen.getByText(`Core PD map (${countCore})`)).toBeInTheDocument(); - expect(screen.getByText(`Histamine signaling (${countHistamine})`)).toBeInTheDocument(); + if (countHistamine > ZERO) { + expect(screen.getByText(`Histamine signaling (${countHistamine})`)).toBeInTheDocument(); + } expect(screen.getByText(`PRKN substrates (${countPrkn})`)).toBeInTheDocument(); }); diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx index 589688c92153478e9ec414ebd29a6fd11d24a95c..75723b88b1ea50e338ac23e8530dfa93f4770fb5 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/PinsList/PinsListItem/PinsListItem.component.test.tsx @@ -25,7 +25,10 @@ const CHEMICALS_PIN = { }; const PIN_NUMBER = 10; -const BIO_ENTITY = bioEntitiesContentFixture[0].bioEntity; +const BIO_ENTITY = { + ...bioEntitiesContentFixture[0].bioEntity, + model: 5053, +}; const INITIAL_STORE_STATE: InitialStoreState = { models: MODELS_DATA_MOCK_WITH_MAIN_MAP, diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleAliasResults.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleAliasResults.ts index c3d05abac90d5ed78f58e8dc986bf6adcb0316f8..a0f97e1628e93b77972050fd01d6ef86dabab283 100644 --- a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleAliasResults.ts +++ b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleAliasResults.ts @@ -6,6 +6,8 @@ import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; import { clearBioEntities } from '@/redux/bioEntity/bioEntity.slice'; import { Point } from '@/types/map'; import { getMultiBioEntityByIds } from '@/redux/bioEntity/thunks/getMultiBioEntity'; +import { handleOpenImmediateLink } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/handleOpenImmediateLink'; +import { ZERO } from '@/constants/common'; import { findClosestBioEntityPoint } from './findClosestBioEntityPoint'; type SearchConfig = { @@ -40,12 +42,13 @@ export const handleAliasResults = dispatch(clearBioEntities()); return; } + + handleOpenImmediateLink(bioEntities[ZERO]); } dispatch(selectTab(`${id}`)); dispatch(openBioEntityDrawerById(id)); - PluginsEventBus.dispatchEvent('onSearch', { type: 'bioEntity', searchValues: [closestSearchResult], diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleOpenImmediateLink.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleOpenImmediateLink.ts new file mode 100644 index 0000000000000000000000000000000000000000..360df8c0cb43c8e90ea7ed3c390fbf7a12601c02 --- /dev/null +++ b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleOpenImmediateLink.ts @@ -0,0 +1,17 @@ +import { BioEntity } from '@/types/models'; +import { showToast } from '@/utils/showToast'; + +export const handleOpenImmediateLink = (bioEntity: BioEntity): void => { + const link = bioEntity.immediateLink; + if (link !== null) { + const tab = window.open(link, '_blank'); + if (tab) { + tab.focus(); + } else { + showToast({ + type: 'error', + message: `Browser prevented minerva from opening link: <a href="${link}" target="_blank">${link}</a>`, + }); + } + } +}; diff --git a/src/models/bioEntitySchema.ts b/src/models/bioEntitySchema.ts index 1e01a1d5b020a9d1c21e93b2158ddd176fa2a6cd..bd96f4c69fd80fce9992a7a28aea62a0fe23e541 100644 --- a/src/models/bioEntitySchema.ts +++ b/src/models/bioEntitySchema.ts @@ -13,6 +13,7 @@ import { submodelSchema } from './submodelSchema'; export const bioEntitySchema = z.object({ id: z.union([z.number().int().positive(), z.string()]), stringType: z.string(), + immediateLink: z.string().nullable(), name: z.string(), elementId: z.string(), model: z.number(),