current user global inspector fix (#10468)

This commit is contained in:
Rudhra Deep Biswas 2024-08-13 13:03:58 +05:30 committed by GitHub
parent 68e27d6e74
commit 5024eff92e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,13 +7,15 @@ import { useEditorStore } from '@/_stores/editorStore';
import { useQueryPanelStore } from '@/_stores/queryPanelStore';
import update from 'immutability-helper';
const { diff } = require('deep-object-diff');
import { useAppDataStore } from './appDataStore';
import { authenticationService } from '@/_services';
const initialState = {
queries: {},
components: {},
globals: {
theme: { name: 'light' },
urlparams: null,
currentUser: {},
},
errors: {},
variables: {},
@ -53,9 +55,22 @@ export const useCurrentStateStore = create(
},
setEditorReady: (isEditorReady) => set({ isEditorReady }),
initializeCurrentStateOnVersionSwitch: () => {
//fetch user for current app
const currentUser = useAppDataStore.getState().currentUser;
const userVars = {
email: currentUser?.email,
firstName: currentUser?.first_name,
lastName: currentUser?.last_name,
groups: authenticationService.currentSessionValue.group_permissions?.map((group) => group.group),
ssoUserInfo: currentUser?.sso_user_info,
};
const newInitialState = {
...initialState,
constants: get().constants,
globals: {
...get().globals,
currentUser: userVars,
},
};
set({ ...newInitialState }, false, {
type: 'INITIALIZE_CURRENT_STATE_ON_VERSION_SWITCH',