Skip to content
Snippets Groups Projects
Commit 4f585cd0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

show banner only when link is available

parent 66dcdc7a
No related branches found
No related tags found
2 merge requests!275Resolve "cookie banner for matomo",!273Resolve "link on cookie banner is invalid"
Pipeline #96820 passed
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
......
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(
......
......@@ -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>
......
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',
},
];
......@@ -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',
......
......@@ -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,
......
......@@ -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,
......
......@@ -197,7 +197,7 @@ describe('triggerSearch', () => {
x: 545.8013,
y: 500.9926,
},
searchDistance: undefined,
searchDistance: '10',
zoom: 5,
});
});
......
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