Skip to content

Commit

Permalink
[Resource] fixes fullscreen opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Aug 18, 2022
1 parent 598b8a6 commit b8a4a53
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const ResourcePage = (props) => {
embedded={props.embedded}
showHeader={props.embedded ? props.showHeader : true}
showTitle={get(props.resourceNode, 'display.showTitle')}
fullscreen={!props.embedded && get(props.resourceNode, 'display.fullscreen')}
title={props.resourceNode.name}
subtitle={props.subtitle}
path={[].concat(ancestors.map(ancestorNode => ({
Expand Down
7 changes: 7 additions & 0 deletions src/main/core/Resources/modules/resource/store/actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import get from 'lodash/get'

import {makeActionCreator, makeInstanceActionCreator} from '#/main/app/store/actions'
import {API_REQUEST} from '#/main/app/api'

import {actions as toolActions} from '#/main/core/tool/store/actions'
import {selectors} from '#/main/core/resource/store/selectors'

// actions
Expand Down Expand Up @@ -48,6 +51,10 @@ actions.fetchResource = (slug, embedded = false, loadApp) => (dispatch) => dispa
// load resource data inside the store
dispatch(actions.loadResourceType(response.resourceNode.meta.type, response))

if (!embedded) {
dispatch(toolActions.setFullscreen(get(response.resourceNode, 'display.fullscreen', false)))
}

// mark the resource as loaded
// it's done through another action (not RESOURCE_LOAD) to be sure all reducers have been resolved
// and store is up-to-date
Expand Down
2 changes: 2 additions & 0 deletions src/main/core/Resources/modules/tool/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const TOOL_SET_LOADED = 'TOOL_SET_LOADED'
export const TOOL_SET_ACCESS_DENIED = 'TOOL_SET_ACCESS_DENIED'
export const TOOL_SET_NOT_FOUND = 'TOOL_SET_NOT_FOUND'
export const TOOL_TOGGLE_FULLSCREEN = 'TOOL_TOGGLE_FULLSCREEN'
export const TOOL_SET_FULLSCREEN = 'TOOL_SET_FULLSCREEN'

// action creators
export const actions = {}
Expand All @@ -25,6 +26,7 @@ actions.setLoaded = makeActionCreator(TOOL_SET_LOADED, 'loaded')
actions.setAccessDenied = makeActionCreator(TOOL_SET_ACCESS_DENIED, 'accessDenied')
actions.setNotFound = makeActionCreator(TOOL_SET_NOT_FOUND, 'notFound')
actions.toggleFullscreen = makeActionCreator(TOOL_TOGGLE_FULLSCREEN)
actions.setFullscreen = makeActionCreator(TOOL_SET_FULLSCREEN, 'fullscreen')

actions.open = (name, context, basePath) => (dispatch, getState) => {
const prevName = selectors.name(getState())
Expand Down
6 changes: 4 additions & 2 deletions src/main/core/Resources/modules/tool/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
TOOL_SET_LOADED,
TOOL_SET_ACCESS_DENIED,
TOOL_SET_NOT_FOUND,
TOOL_TOGGLE_FULLSCREEN
TOOL_TOGGLE_FULLSCREEN,
TOOL_SET_FULLSCREEN
} from '#/main/core/tool/store/actions'

const reducer = combineReducers({
Expand Down Expand Up @@ -39,7 +40,8 @@ const reducer = combineReducers({
}),
fullscreen: makeReducer(false, {
[TOOL_LOAD]: (state, action) => get(action.toolData, 'data.display.fullscreen') || false,
[TOOL_TOGGLE_FULLSCREEN]: (state) => !state
[TOOL_TOGGLE_FULLSCREEN]: (state) => !state,
[TOOL_SET_FULLSCREEN]: (state, action) => action.fullscreen
}),
data: makeReducer({}, {
[TOOL_LOAD]: (state, action) => action.toolData.data || {}
Expand Down

0 comments on commit b8a4a53

Please sign in to comment.