This PR contains changes to retain context on the following items, Leaving and then returning to a page should maintain what api/query was open Entity explorer should stay as you left it when you left the page (collapse levels) Widget/explorer tab Width - Should be the same across all pages of an app Property Pane width Complex widgets, multi tier property panes Co-authored-by: hetunandu <hetunandu@gmail.com> Co-authored-by: Akash N <akash@codemonk.in> Co-authored-by: Hetu Nandu <hetu@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
81 lines
2.1 KiB
TypeScript
81 lines
2.1 KiB
TypeScript
import {
|
|
ReduxAction,
|
|
ReduxActionTypes,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import {
|
|
setPanelPropertySectionState,
|
|
setPanelSelectedPropertyTabIndex,
|
|
setWidgetPropertySectionState,
|
|
setWidgetSelectedPropertyTabIndex,
|
|
} from "actions/editorContextActions";
|
|
|
|
import { all, put, takeLatest } from "redux-saga/effects";
|
|
import {
|
|
CodeEditorFocusState,
|
|
setCodeEditorCursorAction,
|
|
setFocusableCodeEditorField,
|
|
} from "actions/editorContextActions";
|
|
import { FocusEntity, identifyEntityFromPath } from "navigation/FocusEntity";
|
|
|
|
/**
|
|
* This method appends the PageId along with the focusable propertyPath
|
|
* @param action
|
|
*/
|
|
function* setEditorFieldFocus(action: ReduxAction<CodeEditorFocusState>) {
|
|
const { cursorPosition, key } = action.payload;
|
|
|
|
const entityInfo = identifyEntityFromPath(
|
|
window.location.pathname,
|
|
window.location.hash,
|
|
);
|
|
|
|
if (key) {
|
|
if (entityInfo.entity !== FocusEntity.PROPERTY_PANE) {
|
|
yield put(setFocusableCodeEditorField(key));
|
|
}
|
|
yield put(setCodeEditorCursorAction(key, cursorPosition));
|
|
}
|
|
}
|
|
|
|
function* setPropertySectionStateSaga(
|
|
action: ReduxAction<{
|
|
key: string;
|
|
isOpen: boolean;
|
|
panelPropertyPath?: string;
|
|
}>,
|
|
) {
|
|
const { isOpen, key, panelPropertyPath } = action.payload;
|
|
|
|
if (panelPropertyPath) {
|
|
yield put(setPanelPropertySectionState(key, isOpen, panelPropertyPath));
|
|
} else {
|
|
yield put(setWidgetPropertySectionState(key, isOpen));
|
|
}
|
|
}
|
|
|
|
function* setSelectedPropertyTabIndexSaga(
|
|
action: ReduxAction<{ index: number; panelPropertyPath?: string }>,
|
|
) {
|
|
const { index, panelPropertyPath } = action.payload;
|
|
|
|
if (panelPropertyPath) {
|
|
yield put(setPanelSelectedPropertyTabIndex(index, panelPropertyPath));
|
|
} else {
|
|
yield put(setWidgetSelectedPropertyTabIndex(index));
|
|
}
|
|
}
|
|
|
|
export default function* editorContextSagas() {
|
|
yield all([
|
|
takeLatest(
|
|
ReduxActionTypes.SET_PROPERTY_SECTION_STATE,
|
|
setPropertySectionStateSaga,
|
|
),
|
|
takeLatest(
|
|
ReduxActionTypes.SET_SELECTED_PROPERTY_TAB_INDEX,
|
|
setSelectedPropertyTabIndexSaga,
|
|
),
|
|
takeLatest(ReduxActionTypes.SET_EDITOR_FIELD_FOCUS, setEditorFieldFocus),
|
|
]);
|
|
}
|