diff --git a/CHANGELOG b/CHANGELOG index c5313949e9dca8703a1c8bca046444c16ae29672..b564876dd2f74879328ac4068e4823e09f033257 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +minerva-front (18.0.0) stable; urgency=medium + * Bug fix: show cookie baner only when cookie baner link is provided (#304) + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 24 Oct 2024 13:00:00 +0200 + minerva-front (18.0.0) stable; urgency=medium * Feature: minerva frontend - first version diff --git a/src/components/FunctionalArea/CookieBanner/CookieBanner.component.test.tsx b/src/components/FunctionalArea/CookieBanner/CookieBanner.component.test.tsx index f4c495825584af08cf7ef7695cc7a969438a67df..c5a0ccdb795bd74fb8218c58685bb2fdef8bb34c 100644 --- a/src/components/FunctionalArea/CookieBanner/CookieBanner.component.test.tsx +++ b/src/components/FunctionalArea/CookieBanner/CookieBanner.component.test.tsx @@ -1,18 +1,24 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; -import { ToolkitStoreWithSingleSlice } from '@/utils/createStoreInstanceUsingSliceReducer'; -import { CookieBannerState } from '@/redux/cookieBanner/cookieBanner.types'; -import { getReduxWrapperUsingSliceReducer } from '@/utils/testing/getReduxWrapperUsingSliceReducer'; -import cookieBannerReducer from '@/redux/cookieBanner/cookieBanner.slice'; import { act } from 'react-dom/test-utils'; -import { CookieBanner } from './CookieBanner.component'; +import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; +import { INITIAL_STORE_STATE_MOCK } from '@/redux/root/root.fixtures'; +import { StoreType } from '@/redux/store'; +import { CONFIGURATION_INITIAL_STORE_MOCKS } from '@/redux/configuration/configuration.mock'; import { USER_ACCEPTED_COOKIES_COOKIE_NAME, USER_ACCEPTED_COOKIES_COOKIE_VALUE, } from './CookieBanner.constants'; +import { CookieBanner } from './CookieBanner.component'; -const renderComponent = (): { store: ToolkitStoreWithSingleSlice<CookieBannerState> } => { - const { Wrapper, store } = getReduxWrapperUsingSliceReducer('cookieBanner', cookieBannerReducer); +const renderComponent = (): { store: StoreType } => { + // const { Wrapper, store } = getReduxWrapperUsingSliceReducer('cookieBanner', cookieBannerReducer); + // + + const { Wrapper, store } = getReduxWrapperWithStore({ + ...INITIAL_STORE_STATE_MOCK, + configuration: CONFIGURATION_INITIAL_STORE_MOCKS, + }); return ( render( diff --git a/src/components/FunctionalArea/CookieBanner/CookieBanner.component.tsx b/src/components/FunctionalArea/CookieBanner/CookieBanner.component.tsx index f27ac87c1a7192929a5a7276e599aa8eb1c60b65..643ed796c87e8bb4b154f780fc75e2a8d5dd60e0 100644 --- a/src/components/FunctionalArea/CookieBanner/CookieBanner.component.tsx +++ b/src/components/FunctionalArea/CookieBanner/CookieBanner.component.tsx @@ -5,6 +5,7 @@ import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { Button } from '@/shared/Button'; import Link from 'next/link'; import { useEffect } from 'react'; +import { cookiePolicyUrlSelector } from '@/redux/configuration/configuration.selectors'; import { USER_ACCEPTED_COOKIES_COOKIE_NAME, USER_ACCEPTED_COOKIES_COOKIE_VALUE, @@ -13,6 +14,7 @@ import { export const CookieBanner = (): React.ReactNode => { const dispatch = useAppDispatch(); const { visible, accepted } = useAppSelector(selectCookieBanner); + const cookiePolicyUrl = useAppSelector(cookiePolicyUrlSelector); useEffect(() => { const isAccepted = @@ -33,7 +35,7 @@ export const CookieBanner = (): React.ReactNode => { ); }; - if (!visible || accepted) { + if (!visible || accepted || !cookiePolicyUrl) { return null; } @@ -43,7 +45,7 @@ export const CookieBanner = (): React.ReactNode => { <p className="my-4 leading-loose"> Minerva platform uses essential cookies to ensure its proper operation. For any queries in relation to our policy on cookies and your choices, please{' '} - <Link href="/" className="font-semibold text-[#1C00DE]"> + <Link href={cookiePolicyUrl} className="font-semibold text-[#1C00DE]"> read here </Link> </p> diff --git a/src/models/mocks/configurationOptionMock.ts b/src/models/mocks/configurationOptionMock.ts index f7a293f7592e80217573eef6dab39dc5a1038e87..16fb91c7fd1f4bafa5816bf2932f71ea3014be0b 100644 --- a/src/models/mocks/configurationOptionMock.ts +++ b/src/models/mocks/configurationOptionMock.ts @@ -1,12 +1,22 @@ import { ConfigurationOption } from '@/types/models'; +import { + COOKIE_POLICY_URL, + MAX_COLOR_VAL_NAME_ID, + MIN_COLOR_VAL_NAME_ID, + NEUTRAL_COLOR_VAL_NAME_ID, + OVERLAY_OPACITY_NAME_ID, + SEARCH_DISTANCE_NAME_ID, + SIMPLE_COLOR_VAL_NAME_ID, +} from '@/redux/configuration/configuration.constants'; export const CONFIGURATION_OPTIONS_TYPES_MOCK: string[] = [ - 'MIN_COLOR_VAL', - 'MAX_COLOR_VAL', - 'SIMPLE_COLOR_VAL', - 'NEUTRAL_COLOR_VAL', - 'OVERLAY_OPACITY', - 'SEARCH_DISTANCE', + MIN_COLOR_VAL_NAME_ID, + MAX_COLOR_VAL_NAME_ID, + SIMPLE_COLOR_VAL_NAME_ID, + NEUTRAL_COLOR_VAL_NAME_ID, + OVERLAY_OPACITY_NAME_ID, + SEARCH_DISTANCE_NAME_ID, + COOKIE_POLICY_URL, ]; export const CONFIGURATION_OPTIONS_COLOURS_MOCK: ConfigurationOption[] = [ @@ -64,4 +74,13 @@ export const CONFIGURATION_OPTIONS_COLOURS_MOCK: ConfigurationOption[] = [ value: '10', group: 'Point and click', }, + { + idObject: 41, + type: 'COOKIE_POLICY_URL', + valueType: 'URL', + commonName: 'Privacy policy (url)', + isServerSide: false, + value: 'default-cookie-policy.xhtml', + group: 'Server configuration', + }, ]; diff --git a/src/redux/configuration/configuration.constants.ts b/src/redux/configuration/configuration.constants.ts index 28578664321a61e1fc7aeda6ef2006b3edaef8ee..032c5e0b8ac380663f285a5a651914757cf015ab 100644 --- a/src/redux/configuration/configuration.constants.ts +++ b/src/redux/configuration/configuration.constants.ts @@ -6,6 +6,7 @@ export const OVERLAY_OPACITY_NAME_ID = 'OVERLAY_OPACITY'; export const SEARCH_DISTANCE_NAME_ID = 'SEARCH_DISTANCE'; export const REQUEST_ACCOUNT_EMAIL = 'REQUEST_ACCOUNT_EMAIL'; export const TERMS_OF_SERVICE_ID = 'TERMS_OF_USE'; +export const COOKIE_POLICY_URL = 'COOKIE_POLICY_URL'; export const LEGEND_FILE_NAMES_IDS = [ 'LEGEND_FILE_1', diff --git a/src/redux/configuration/configuration.mock.ts b/src/redux/configuration/configuration.mock.ts index 07ee6ea998096fcad4a62772d50845021e074e18..4edae637b04ab9f9d37eb37bd1c08a7553958955 100644 --- a/src/redux/configuration/configuration.mock.ts +++ b/src/redux/configuration/configuration.mock.ts @@ -30,6 +30,8 @@ export const CONFIGURATION_INITIAL_STORE_MOCKS: ConfigurationState = { [CONFIGURATION_OPTIONS_TYPES_MOCK[2]]: CONFIGURATION_OPTIONS_COLOURS_MOCK[2], [CONFIGURATION_OPTIONS_TYPES_MOCK[3]]: CONFIGURATION_OPTIONS_COLOURS_MOCK[3], [CONFIGURATION_OPTIONS_TYPES_MOCK[4]]: CONFIGURATION_OPTIONS_COLOURS_MOCK[4], + [CONFIGURATION_OPTIONS_TYPES_MOCK[5]]: CONFIGURATION_OPTIONS_COLOURS_MOCK[5], + [CONFIGURATION_OPTIONS_TYPES_MOCK[6]]: CONFIGURATION_OPTIONS_COLOURS_MOCK[6], }, loading: 'idle', error: DEFAULT_ERROR, diff --git a/src/redux/configuration/configuration.selectors.ts b/src/redux/configuration/configuration.selectors.ts index 176847d40d89b9e31dd50f1fe1e8fb3657c14b94..01a9eb4c2d3437da7a252dc310d1353b020b490a 100644 --- a/src/redux/configuration/configuration.selectors.ts +++ b/src/redux/configuration/configuration.selectors.ts @@ -19,6 +19,7 @@ import { SEARCH_DISTANCE_NAME_ID, REQUEST_ACCOUNT_EMAIL, TERMS_OF_SERVICE_ID, + COOKIE_POLICY_URL, } from './configuration.constants'; import { ConfigurationHandlersIds, ConfigurationImageHandlersIds } from './configuration.types'; @@ -69,6 +70,11 @@ export const termsOfServiceValSelector = createSelector( state => configurationAdapterSelectors.selectById(state, TERMS_OF_SERVICE_ID)?.value, ); +export const cookiePolicyUrlSelector = createSelector( + configurationOptionsSelector, + state => configurationAdapterSelectors.selectById(state, COOKIE_POLICY_URL)?.value, +); + export const defaultLegendImagesSelector = createSelector(configurationOptionsSelector, state => LEGEND_FILE_NAMES_IDS.map( legendNameId => configurationAdapterSelectors.selectById(state, legendNameId)?.value, diff --git a/src/services/pluginsManager/map/triggerSearch/triggerSearch.test.ts b/src/services/pluginsManager/map/triggerSearch/triggerSearch.test.ts index bdec855900cbde830daca6eb1343a424e40087fc..abb470aa4b1fc5e1738a4b2962b0b36b2c168431 100644 --- a/src/services/pluginsManager/map/triggerSearch/triggerSearch.test.ts +++ b/src/services/pluginsManager/map/triggerSearch/triggerSearch.test.ts @@ -197,7 +197,7 @@ describe('triggerSearch', () => { x: 545.8013, y: 500.9926, }, - searchDistance: undefined, + searchDistance: '10', zoom: 5, }); });