mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 01:18:23 +00:00
Fixes CurrentUser & Mode not present in globals in inspector (#7812)
* Fix current user not being present in inspector
* Add Mode in globas in inspector
* Fix creating page not changing the slug.
* Revert "Fix creating page not changing the slug."
This reverts commit 0ff9c18ab8.
This commit is contained in:
parent
a000a7fdd9
commit
f94b49e180
2 changed files with 52 additions and 57 deletions
|
|
@ -179,11 +179,16 @@ const EditorComponent = (props) => {
|
|||
updateState({
|
||||
currentUser: appUserDetails,
|
||||
});
|
||||
|
||||
useCurrentStateStore.getState().actions.setCurrentState({
|
||||
globals: {
|
||||
...currentState.globals,
|
||||
theme: { name: props?.darkMode ? 'dark' : 'light' },
|
||||
urlparams: JSON.parse(JSON.stringify(queryString.parse(props.location.search))),
|
||||
currentUser: userVars,
|
||||
/* Constant value.it will only change for viewer */
|
||||
mode: {
|
||||
value: 'edit',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -380,16 +385,7 @@ const EditorComponent = (props) => {
|
|||
threshold: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const globals = {
|
||||
...currentState.globals,
|
||||
theme: { name: props?.darkMode ? 'dark' : 'light' },
|
||||
urlparams: JSON.parse(JSON.stringify(queryString.parse(props.location.search))),
|
||||
};
|
||||
|
||||
updateState({ appId: props?.params?.id });
|
||||
useCurrentStateStore.getState().actions.setCurrentState({ globals });
|
||||
|
||||
getCanvasWidth();
|
||||
initEditorWalkThrough();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,54 +41,53 @@ const initialState = {
|
|||
};
|
||||
|
||||
export const useEditorStore = create(
|
||||
zustandDevTools(
|
||||
(set, get) => ({
|
||||
...initialState,
|
||||
actions: {
|
||||
setShowComments: (showComments) =>
|
||||
set({ showComments }, false, {
|
||||
type: ACTIONS.SET_HOVERED_COMPONENT,
|
||||
showComments,
|
||||
}),
|
||||
toggleComments: () =>
|
||||
set({ showComments: !get().showComments }, false, {
|
||||
type: ACTIONS.TOGGLE_COMMENTS,
|
||||
}),
|
||||
toggleCurrentLayout: (currentLayout) =>
|
||||
set({ currentLayout }, false, {
|
||||
type: ACTIONS.TOGGLE_CURRENT_LAYOUT,
|
||||
currentLayout,
|
||||
}),
|
||||
setIsEditorActive: (isEditorActive) => set(() => ({ isEditorActive })),
|
||||
updateEditorState: (state) => set((prev) => ({ ...prev, ...state })),
|
||||
updateQueryConfirmationList: (queryConfirmationList) => set({ queryConfirmationList }),
|
||||
setHoveredComponent: (hoveredComponent) =>
|
||||
set({ hoveredComponent }, false, {
|
||||
type: ACTIONS.SET_HOVERED_COMPONENT,
|
||||
hoveredComponent,
|
||||
}),
|
||||
setSelectionInProgress: (isSelectionInProgress) => {
|
||||
set(
|
||||
{
|
||||
isSelectionInProgress,
|
||||
},
|
||||
false,
|
||||
{ type: ACTIONS.SET_SELECTION_IN_PROGRESS }
|
||||
);
|
||||
},
|
||||
setSelectedComponents: (selectedComponents, isMulti = false) => {
|
||||
const newSelectedComponents = isMulti
|
||||
? [...get().selectedComponents, ...selectedComponents]
|
||||
: selectedComponents;
|
||||
|
||||
set({
|
||||
selectedComponents: newSelectedComponents,
|
||||
});
|
||||
},
|
||||
// Dev tools for this store are disabled comments since its freezing chrome tab
|
||||
(set, get) => ({
|
||||
...initialState,
|
||||
actions: {
|
||||
setShowComments: (showComments) =>
|
||||
set({ showComments }, false, {
|
||||
type: ACTIONS.SET_HOVERED_COMPONENT,
|
||||
showComments,
|
||||
}),
|
||||
toggleComments: () =>
|
||||
set({ showComments: !get().showComments }, false, {
|
||||
type: ACTIONS.TOGGLE_COMMENTS,
|
||||
}),
|
||||
toggleCurrentLayout: (currentLayout) =>
|
||||
set({ currentLayout }, false, {
|
||||
type: ACTIONS.TOGGLE_CURRENT_LAYOUT,
|
||||
currentLayout,
|
||||
}),
|
||||
setIsEditorActive: (isEditorActive) => set(() => ({ isEditorActive })),
|
||||
updateEditorState: (state) => set((prev) => ({ ...prev, ...state })),
|
||||
updateQueryConfirmationList: (queryConfirmationList) => set({ queryConfirmationList }),
|
||||
setHoveredComponent: (hoveredComponent) =>
|
||||
set({ hoveredComponent }, false, {
|
||||
type: ACTIONS.SET_HOVERED_COMPONENT,
|
||||
hoveredComponent,
|
||||
}),
|
||||
setSelectionInProgress: (isSelectionInProgress) => {
|
||||
set(
|
||||
{
|
||||
isSelectionInProgress,
|
||||
},
|
||||
false,
|
||||
{ type: ACTIONS.SET_SELECTION_IN_PROGRESS }
|
||||
);
|
||||
},
|
||||
}),
|
||||
{ name: STORE_NAME }
|
||||
)
|
||||
setSelectedComponents: (selectedComponents, isMulti = false) => {
|
||||
const newSelectedComponents = isMulti
|
||||
? [...get().selectedComponents, ...selectedComponents]
|
||||
: selectedComponents;
|
||||
|
||||
set({
|
||||
selectedComponents: newSelectedComponents,
|
||||
});
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ name: STORE_NAME }
|
||||
);
|
||||
|
||||
export const useEditorActions = () => useEditorStore((state) => state.actions);
|
||||
|
|
|
|||
Loading…
Reference in a new issue