Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions src/actions/uiActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import ErrorTypes from "../enums/ErrorTypes";

export const SET_SNACKBAR_MESSAGE = 'SET_SNACKBAR_MESSAGE';
export const SET_LAYOUT = 'SET_LAYOUT';
export const TOGGLE_HIDDEN_REGION = 'TOGGLE_HIDDEN_REGION';
export const SET_REGION_VISIBILITY = 'SET_REGION_VISIBILITY'
export const SET_HIDDEN_REGIONS = 'SET_HIDDEN_REGIONS';

export function showNotification(message, title = '') {
return {
Expand All @@ -29,7 +28,6 @@ export function showWarning(message, title = '') {
}
}


export function showError(message, title = '') {
return {
type: SET_SNACKBAR_MESSAGE,
Expand All @@ -55,26 +53,18 @@ export function hideNotification() {
}

export function setLayoutProperty(property, value) {
return {
type: SET_LAYOUT,
layout: {
[property]: value
}
}
}

export function toggleHiddenRegion(region) {
return {
type: TOGGLE_HIDDEN_REGION,
region: region
return {
type: SET_LAYOUT,
layout: {
[property]: value
}
}
}

export function setRegionVisibility(region, isVisible) {
export function setHiddenRegions(hiddenRegions) {
return {
type: SET_REGION_VISIBILITY,
region: region,
isVisible: isVisible
type: SET_HIDDEN_REGIONS,
hiddenRegions: hiddenRegions
}
}

Expand Down
28 changes: 6 additions & 22 deletions src/reducers/uiReducers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SET_LAYOUT, SET_SNACKBAR_MESSAGE, TOGGLE_HIDDEN_REGION, SET_REGION_VISIBILITY} from "../actions/uiActions";
import {SET_LAYOUT, SET_SNACKBAR_MESSAGE, SET_HIDDEN_REGIONS} from "../actions/uiActions";

export default function ui(state = buildDefaultUiObject(), action) {
switch(action.type) {
Expand All @@ -15,29 +15,13 @@ export default function ui(state = buildDefaultUiObject(), action) {
...action.layout
}
}
case TOGGLE_HIDDEN_REGION:
let hiddenRegions = {
...state.hiddenRegions,
[action.region]: !state.hiddenRegions[action.region]
}
// Save to local storage
localStorage.setItem("hiddenRegions", JSON.stringify(hiddenRegions))
case SET_HIDDEN_REGIONS:
return {
...state,
hiddenRegions: hiddenRegions
}
case SET_REGION_VISIBILITY:

let hiddenRegions_ = {
...state.hiddenRegions,
[action.region]: !action.isVisible
}

localStorage.setItem("hiddenRegions", JSON.stringify(hiddenRegions_));

return {
...state,
hiddenRegions: hiddenRegions_
hiddenRegions: {
...state.hiddenRegions,
...action.hiddenRegions,
}
}
default:
return state
Expand Down
8 changes: 0 additions & 8 deletions src/selectors/uiSelectors.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
export const isHiddenRegion = (state) => (screen) => (regionID) => {
return !!state.ui.hiddenRegions[getUniqueRegionID(state)(screen)(regionID)]
}

export const getHiddenRegionState = (state) => (screen) => (regionID) => {
return state.ui.hiddenRegions[getUniqueRegionID(state)(screen)(regionID)]
}

export const getUniqueRegionID = (state) => (screen) => (regionID) => {
const user = state.application.userData.eamAccount.userCode
return `${user}_${screen}_${regionID}`
Expand Down
Loading