Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Sep 17, 2020
1 parent 3f5a1ee commit 017506b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
31 changes: 27 additions & 4 deletions src/components/manage/Blocks/DetailedLink/View.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { injectIntl } from 'react-intl';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { settings } from '~/config';
import cx from 'classnames';
import './style.css';
import { useEffect } from 'react';
import { deleteQueryParam } from 'volto-datablocks/actions';

const getPath = (url) => {
if (!url) return '';
Expand Down Expand Up @@ -62,7 +63,22 @@ const View = (props) => {
'detailed-link-button display-inline-block',
buttonClassname || '',
)}
onClick={(e) => e.preventDefault}
onClick={(e) => {
if (
props.discodata_query.search.facilityInspireId ||
props.discodata_query.search.installationInspireId ||
props.discodata_query.search.lcpInspireId
) {
props.deleteQueryParam({
queryParam: [
'facilityInspireId',
'installationInspireId',
'lcpInspireId',
],
});
}
return e.preventDefault;
}}
to={getPath(detailedLink.path)}
>
<span>{buttonTitle || detailedLink.title || 'Go'}</span>
Expand All @@ -76,4 +92,11 @@ const View = (props) => {
);
};

export default injectIntl(View);
export default compose(
connect(
(state, props) => ({
discodata_query: state.discodata_query,
}),
{ deleteQueryParam },
),
)(View);
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/FiltersBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,9 @@ const View = ({ content, ...props }) => {
filterKey
].options.filter((option) => {
if (
state.filters[
typeof state.filters[
state.filtersMeta[filterKey].queryToSet
] &&
]?.filter === 'function' &&
!state.filters[
state.filtersMeta[filterKey].queryToSet
]
Expand Down
38 changes: 28 additions & 10 deletions src/components/manage/Blocks/NavigationBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getNavigationByParent,
getBasePath,
} from 'volto-tabsview/helpers';
import { deleteQueryParam } from 'volto-datablocks/actions';

const View = ({ content, ...props }) => {
const { data } = props;
Expand Down Expand Up @@ -58,6 +59,19 @@ const View = ({ content, ...props }) => {
active={state.activeItem === url}
onClick={() => {
history.push(`${url}${props.query}`);
if (
props.discodata_query.search.facilityInspireId ||
props.discodata_query.search.installationInspireId ||
props.discodata_query.search.lcpInspireId
) {
props.deleteQueryParam({
queryParam: [
'facilityInspireId',
'installationInspireId',
'lcpInspireId',
],
});
}
}}
/>
);
Expand All @@ -73,14 +87,18 @@ const View = ({ content, ...props }) => {
};

export default compose(
connect((state, props) => ({
query: state.router.location.search,
content:
state.prefetch?.[state.router.location.pathname] || state.content.data,
pathname: state.router.location.pathname,
navigation: getNavigationByParent(
state.navigation.items,
props.data?.parent?.value,
),
})),
connect(
(state, props) => ({
query: state.router.location.search,
content:
state.prefetch?.[state.router.location.pathname] || state.content.data,
pathname: state.router.location.pathname,
discodata_query: state.discodata_query,
navigation: getNavigationByParent(
state.navigation.items,
props.data?.parent?.value,
),
}),
{ deleteQueryParam },
),
)(View);

0 comments on commit 017506b

Please sign in to comment.