Skip to content

Commit

Permalink
Merge branch 'develop' into fix-header.dropdown-resize
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Mar 23, 2022
2 parents 1323ee2 + aacf484 commit 36c2e28
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 29 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [0.4.0](https://github.com/eea/volto-eea-website-theme/compare/0.3.1...0.4.0)

- Enable Multilingual support [`#17`](https://github.com/eea/volto-eea-website-theme/pull/17)
- feat(title): add configuration to title block [`#16`](https://github.com/eea/volto-eea-website-theme/pull/16)
- Release 0.4.0 [`b430a9e`](https://github.com/eea/volto-eea-website-theme/commit/b430a9e8b88f2e218d049d8c3fa8cbfd5a992bc6)
- show language switcher on mobile [`bf6e9db`](https://github.com/eea/volto-eea-website-theme/commit/bf6e9db7ccdad2e9052588ba3a9d725dfdfbbd57)
- change(theme): site folder now points to the theme folder [`92ce02f`](https://github.com/eea/volto-eea-website-theme/commit/92ce02f198d0fc0a6f475e3215f78addc9a05d0a)

#### [0.3.1](https://github.com/eea/volto-eea-website-theme/compare/0.3.0...0.3.1)

> 15 March 2022
- Release page banner [`#15`](https://github.com/eea/volto-eea-website-theme/pull/15)
- feat(banner): add banner header [`#14`](https://github.com/eea/volto-eea-website-theme/pull/14)
- change(accordion): use remix icons for accordion title [`95df1c2`](https://github.com/eea/volto-eea-website-theme/commit/95df1c286ed474877c842f069e153e0e22410f08)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-eea-website-theme",
"version": "0.3.1",
"version": "0.4.0",
"description": "@eeacms/volto-eea-website-theme: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
2 changes: 1 addition & 1 deletion src/components/theme/Banner/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const View = (props) => {
)}
{!hideDownloadButton && (
<Banner.Action
icon="ri-arrow-down-s-line"
icon="ri-download-2-fill"
title={intl.formatMessage(messages.download)}
className="download"
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const address = 'Kongens Nytorv 6 1050 Copenhagen K (+45) 33 36 71 00';
export const languages = [
{ name: 'Albanian', code: 'sq' },
{ name: 'Български', code: 'bg' },
{ name: 'Bosnian', code: 'bs' },
{ name: 'Bosanski', code: 'bs' },
{ name: 'čeština', code: 'cs' },
{ name: 'Hrvatski', code: 'hr' },
{ name: 'dansk', code: 'da' },
Expand Down
48 changes: 35 additions & 13 deletions src/customizations/volto/components/theme/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,40 @@ import React from 'react';
import { Dropdown, Image } from 'semantic-ui-react';
import { connect, useDispatch, useSelector } from 'react-redux';

import { withRouter } from 'react-router-dom';
import { UniversalLink } from '@plone/volto/components';
import { getBaseUrl, hasApiExpander } from '@plone/volto/helpers';
import {
getBaseUrl,
hasApiExpander,
flattenToAppURL,
} from '@plone/volto/helpers';
import { getNavigation } from '@plone/volto/actions';

import { Header, Logo } from '@eeacms/volto-eea-design-system/ui';
import { usePrevious } from '@eeacms/volto-eea-design-system/helpers';

import { find } from 'lodash';
import LogoImage from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/eea-logo.svg';
import globeIcon from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/global-line.svg';
import eeaFlag from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/eea.png';

import config from '@plone/volto/registry';
import { compose } from 'recompose';

/**
* EEA Specific Header component.
*/
const EEAHeader = ({ pathname, token, items }) => {
const EEAHeader = ({ pathname, token, items, history }) => {
const currentLang = useSelector((state) => state.intl.locale);
const translations = useSelector(
(state) => state.content.data?.['@components']?.translations?.items,
);

const { eea } = config.settings;
const width = useSelector((state) => state.screen?.width);
const dispatch = useDispatch();
const previousToken = usePrevious(token);
const [language, setLanguage] = React.useState(eea.defaultLanguage);
const [language, setLanguage] = React.useState(
currentLang || eea.defaultLanguage,
);

React.useEffect(() => {
const { settings } = config;
Expand Down Expand Up @@ -118,13 +130,20 @@ const EEAHeader = ({ pathname, token, items }) => {
key={index}
text={
<span>
{item.name}
{item.name}{' '}
<span className="country-code">
{item.code.toUpperCase()}
</span>
</span>
}
onClick={() => setLanguage(item.code)}
onClick={() => {
const translation = find(translations, { language: item.code });
const to = translation
? flattenToAppURL(translation['@id'])
: `/${item.code}`;
setLanguage(item.code);
history.push(to);
}}
></Dropdown.Item>
))}
</Header.TopDropdownMenu>
Expand Down Expand Up @@ -162,10 +181,13 @@ const EEAHeader = ({ pathname, token, items }) => {
);
};

export default connect(
(state) => ({
token: state.userSession.token,
items: state.navigation.items,
}),
{ getNavigation },
export default compose(
withRouter,
connect(
(state) => ({
token: state.userSession.token,
items: state.navigation.items,
}),
{ getNavigation },
),
)(EEAHeader);
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* @module components/theme/Unauthorized/Unauthorized
*/

import React, { useEffect } from 'react';
import { useLocation, Link, useHistory } from 'react-router-dom';
import { getBaseUrl } from '@plone/volto/helpers';
import { Container, Button } from 'semantic-ui-react';

import { FormattedMessage } from 'react-intl';

import { withServerErrorCode } from '@plone/volto/helpers/Utils/Utils';

/**
* unauthorized function.
* @function Unauthorized
* @returns {string} Markup of the unauthorized page.
*/

const Unauthorized = () => {
const location = useLocation();
const pathname = location.pathname;
const base_pathname = getBaseUrl(pathname);
const login = `${base_pathname}/login`;
const history = useHistory();
const [countdown, setCountdown] = React.useState(5);

useEffect(() => {
const login_with_return = login + `?return_url=${pathname}`;
const timer = setTimeout(() => {
return history.push(login_with_return);
}, 5000);
return () => clearTimeout(timer);
}, [history, login, pathname]);

useEffect(() => {
const timer = setTimeout(() => {
if (countdown > 0) {
setCountdown(countdown - 1);
} else {
clearTimeout(timer);
}
}, 1000);
// Clear timeout if the component is unmounted
return () => clearTimeout(timer);
}, [countdown]);

return (
<Container className="view-wrapper">
<h1>
<FormattedMessage id="Unauthorized" defaultMessage="Unauthorized" />
</h1>
<h3>
<FormattedMessage
id="Forbidden, you will be redirected to the login screen in "
defaultMessage="Forbidden, you will be redirected to the login screen in "
/>
<span id="redirect-countdown">{countdown}</span>.
</h3>

<p className="description">
<FormattedMessage id="Click" defaultMessage="Click" />{' '}
<Link
className={'ui mini compact button my-half unauthorized-buttons'}
to={login}
>
<FormattedMessage id="Log in" defaultMessage="Log in" />
</Link>
<FormattedMessage
id="to get to login screen or click"
defaultMessage="to get to login screen or click"
/>{' '}
<Button
size={'mini'}
compact
onClick={() => history.goBack()}
className={'my-half unauthorized-buttons'}
>
<FormattedMessage id="Get back" defaultMessage="Get back" />
</Button>
<FormattedMessage
id="to get to the previous location"
defaultMessage="to get to the previous location"
/>
.
</p>
</Container>
);
};

export default withServerErrorCode(401)(Unauthorized);
35 changes: 22 additions & 13 deletions theme/theme.config
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,29 @@
@main : 'eea';
@custom : 'eea';
/* EEA Design system custom components */
@blockquote : 'eea';
@pullquote : 'eea';
@banner : 'eea';
@timeline : 'eea';
@footer : 'eea';
@header : 'eea';
@tags : 'eea';
@blockquote : 'eea';
@pullquote : 'eea';
@banner : 'eea';
@timeline : 'eea';
@footer : 'eea';
@header : 'eea';
@tag : 'eea';
@tags : 'eea';
@tagList : 'eea';
@inpageNavigation : 'eea';
@avatar : 'eea';
@divider : 'eea';
@testimonial : 'eea';
@avatarGrid : 'eea';
@keyContent : 'eea';
@publicationCard: 'eea';
@avatar : 'eea';
@divider : 'eea';
@testimonial : 'eea';
@avatarGrid : 'eea';
@keyContent : 'eea';
@publicationCard : 'eea';
@contentBox : 'eea';
@reverseCardGrid : 'eea';
@relatedContent : 'eea';
@share : 'eea';
@faqContent : 'eea';
@reportCard : 'eea';
@faqFilter : 'eea';

/*******************************
Folders
Expand Down

0 comments on commit 36c2e28

Please sign in to comment.