From 9007502a120dddbecd28853f777fb4ed85fcb04a Mon Sep 17 00:00:00 2001 From: Mihai Macaneata Date: Wed, 8 Apr 2020 11:27:42 +0300 Subject: [PATCH] section tabs --- src/actions/index.js | 11 +++++++++ src/components/theme/View/TabsView.jsx | 33 +++++--------------------- src/constants/ActionTypes.js | 1 + src/reducers/section_tabs.js | 28 ++++++++++++++++++++++ 4 files changed, 46 insertions(+), 27 deletions(-) create mode 100644 src/reducers/section_tabs.js diff --git a/src/actions/index.js b/src/actions/index.js index e69de29b..e1b6a35e 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -0,0 +1,11 @@ +import { + SET_SECTION_TABS, +} from '~/constants/ActionTypes'; + + +export function setSectionTabs(payload) { + return { + type: SET_SECTION_TABS, + payload: payload, + }; +} \ No newline at end of file diff --git a/src/components/theme/View/TabsView.jsx b/src/components/theme/View/TabsView.jsx index 280d428e..0a9cccec 100644 --- a/src/components/theme/View/TabsView.jsx +++ b/src/components/theme/View/TabsView.jsx @@ -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', @@ -77,6 +80,7 @@ class DefaultView extends Component { title: i.name, }; }); + this.props.setSectionTabs(tabsItems); return tabsItems; }; @@ -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 ( - //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- // ); - return ( hasBlocksData(content) && (
@@ -167,5 +146,5 @@ export default compose( pathname: props.location.pathname, content: state.prefetch?.[state.router.location.pathname] || state.content.data, - })), + }),mapDispatchToProps), )(DefaultView); \ No newline at end of file diff --git a/src/constants/ActionTypes.js b/src/constants/ActionTypes.js index e69de29b..6c20dcc2 100644 --- a/src/constants/ActionTypes.js +++ b/src/constants/ActionTypes.js @@ -0,0 +1 @@ +export const SET_SECTION_TABS = 'SET_SECTION_TABS'; \ No newline at end of file diff --git a/src/reducers/section_tabs.js b/src/reducers/section_tabs.js new file mode 100644 index 00000000..032dbb05 --- /dev/null +++ b/src/reducers/section_tabs.js @@ -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; +} \ No newline at end of file