Skip to content

Commit

Permalink
section tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-macaneata committed Apr 8, 2020
1 parent 83fc18e commit 9007502
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 27 deletions.
11 changes: 11 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {
SET_SECTION_TABS,
} from '~/constants/ActionTypes';


export function setSectionTabs(payload) {
return {
type: SET_SECTION_TABS,
payload: payload,
};
}
33 changes: 6 additions & 27 deletions src/components/theme/View/TabsView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import {
hasBlocksData,
} from '@plone/volto/helpers';
import { flattenToAppURL } from '@plone/volto/helpers';

import { setSectionTabs } from '~/actions';
const mapDispatchToProps = {
setSectionTabs,
};
const messages = defineMessages({
unknownBlock: {
id: 'Unknown Block',
Expand Down Expand Up @@ -77,6 +80,7 @@ class DefaultView extends Component {
title: i.name,
};
});
this.props.setSectionTabs(tabsItems);
return tabsItems;
};

Expand All @@ -87,31 +91,6 @@ class DefaultView extends Component {
const blocksLayoutFieldname = getBlocksLayoutFieldname(content);
const tabs = this.computeFolderTabs(content['@components'].siblings);

// const currentUrl = this.props.content?.['@id'];
// const shouldRenderRoutes =
// typeof currentUrl !== 'undefined' &&
// samePath(currentUrl, this.props.pathname)
// ? true
// : false;
//
// if (shouldRenderRoutes === false)
// return (
// <div className="lds-default">
// <div />
// <div />
// <div />
// <div />
// <div />
// <div />
// <div />
// <div />
// <div />
// <div />
// <div />
// <div />
// </div>
// );

return (
hasBlocksData(content) && (
<div id="page-document" className="ui wrapper">
Expand Down Expand Up @@ -167,5 +146,5 @@ export default compose(
pathname: props.location.pathname,
content:
state.prefetch?.[state.router.location.pathname] || state.content.data,
})),
}),mapDispatchToProps),
)(DefaultView);
1 change: 1 addition & 0 deletions src/constants/ActionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SET_SECTION_TABS = 'SET_SECTION_TABS';
28 changes: 28 additions & 0 deletions src/reducers/section_tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { SET_SECTION_TABS } from '~/constants/ActionTypes';

const initialState = {
error: null,
items: null,
loaded: false,
loading: false,
};

/**
* Navigation reducer.
* @function navigation
* @param {Object} state Current state.
* @param {Object} action Action to be handled.
* @returns {Object} New state.
*/
export default function section_tabs(state = initialState, action = {}) {
if (action.type === SET_SECTION_TABS) {
return {
...state,
error: null,
items: action.payload,
loaded: true,
loading: false,
};
}
return state;
}

0 comments on commit 9007502

Please sign in to comment.