UNPKG

cluedin-widget

Version:

This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.

88 lines (66 loc) 2.08 kB
/* { '/Organization': { version: '1', //simple increment to remove state for specific entity removedWidgets: [ 'OnBoarding','LastDocument' ], widgetStates: [ { name: 'OnBoarding', parameters: { show: false } }, { name: 'PeopleOnThisPlatform', isSuggestedSearch: true, parameters: { filter: 'someValues' } } ] } } */ import localStorage from 'store'; import config from '../config/index'; const globalKey = 'cluedIn_' + config.clientId; let onBoardingKey = globalKey + '_onBoarding'; export function setProviderId(providerName, providerGuid) { localStorage.set('ls.' + providerName, providerGuid); } export function getExcludedWidgets(entityType) { let state = localStorage.get(globalKey) || {}; var stateForEntityType = state[entityType] || void 0; if (!stateForEntityType) { return []; } return (stateForEntityType.removedWidgets || []); } export function getWidget(entityType) { let state = localStorage.get(globalKey) || {}; return state[entityType] || void 0; } export function resetWidget(entityType) { let state = localStorage.get(globalKey) || {}; if (state[entityType]) { state[entityType].removedWidgets = []; } localStorage.set(globalKey, state); } export function getOnBoarding() { let state = localStorage.get(onBoardingKey) || {}; return state; } export function removeOnBoarding() { let state = localStorage.get(onBoardingKey) || {}; state.done = true; localStorage.set(onBoardingKey, state); } export function removeWidget(entityType, widgetName) { let state = localStorage.get(globalKey) || {}; var stateForEntityType = state[entityType]; if (stateForEntityType) { if (stateForEntityType.removedWidgets && stateForEntityType.removedWidgets.length > 0) { stateForEntityType.removedWidgets.push(widgetName); } else { stateForEntityType.removedWidgets = [widgetName]; } state[entityType] = stateForEntityType; } else { state[entityType] = { removedWidgets: [widgetName], widgetStates: [], }; } localStorage.set(globalKey, state); }