import { getApiPaneConfigSelectedTabIndex, getApiPaneResponsePaneHeight, getApiPaneResponseSelectedTab, getApiRightPaneSelectedTab, } from "selectors/apiPaneSelectors"; import { setApiPaneResponseSelectedTab, setApiPaneConfigSelectedTabIndex, setApiPaneResponsePaneHeight, setApiRightPaneSelectedTab, } from "actions/apiPaneActions"; import { AppState } from "@appsmith/reducers"; import { ReduxAction } from "@appsmith/constants/ReduxActionConstants"; import { getAllPropertySectionState, getFocusableCodeEditorField, getSelectedCanvasDebuggerTab, getSelectedPropertyTabIndex, } from "selectors/editorContextSelectors"; import { setFocusableCodeEditorField } from "actions/editorContextActions"; import { getAllDatasourceCollapsibleState, getSelectedWidgets, isDatasourceInViewMode, } from "selectors/ui"; import { selectMultipleWidgetsInitAction } from "actions/widgetSelectionActions"; import { FocusEntity } from "navigation/FocusEntity"; import { ActionExecutionResizerHeight } from "pages/Editor/APIEditor/constants"; import { getQueryPaneConfigSelectedTabIndex, getQueryPaneResponsePaneHeight, getQueryPaneResponseSelectedTab, } from "selectors/queryPaneSelectors"; import { setQueryPaneConfigSelectedTabIndex, setQueryPaneResponsePaneHeight, setQueryPaneResponseSelectedTab, } from "actions/queryPaneActions"; import { getJSPaneConfigSelectedTabIndex, getJSPaneResponsePaneHeight, getJSPaneResponseSelectedTab, } from "selectors/jsPaneSelectors"; import { setJsPaneConfigSelectedTabIndex, setJsPaneResponsePaneHeight, setJsPaneResponseSelectedTab, } from "actions/jsPaneActions"; import { setAllPropertySectionState, setFocusablePropertyPaneField, setSelectedPropertyTabIndex, } from "actions/propertyPaneActions"; import { setCanvasDebuggerSelectedTab } from "actions/debuggerActions"; import { setAllDatasourceCollapsible, setDatasourceViewMode, } from "actions/datasourceActions"; import { PluginPackageName } from "entities/Action"; import { getFocusablePropertyPaneField } from "selectors/propertyPaneSelectors"; export enum FocusElement { ApiPaneConfigTabs = "ApiPaneConfigTabs", ApiPaneResponseTabs = "ApiPaneResponseTabs", ApiPaneResponseHeight = "ApiPaneResponseHeight", DatasourceViewMode = "DatasourceViewMode", DatasourceAccordions = "DatasourceAccordions", ApiRightPaneTabs = "ApiRightPaneTabs", QueryPaneConfigTabs = "QueryPaneConfigTabs", QueryPaneResponseTabs = "QueryPaneResponseTabs", QueryPaneResponseHeight = "QueryPaneResponseHeight", JSPaneConfigTabs = "JSPaneConfigTabs", JSPaneResponseTabs = "JSPaneResponseTabs", JSPaneResponseHeight = "JSPaneResponseHeight", CodeEditor = "CodeEditor", PropertyField = "PropertyField", PropertySections = "PropertySections", PropertyTabs = "PropertyTabs", SelectedWidgets = "SelectedWidgets", CanvasDebuggerTabs = "CanvasDebuggerTabs", } type Config = { name: FocusElement; selector: (state: AppState) => unknown; setter: (payload: any) => ReduxAction; defaultValue?: unknown; subTypes?: Record; }; export const FocusElementsConfig: Record = { [FocusEntity.NONE]: [], [FocusEntity.CANVAS]: [ { name: FocusElement.PropertySections, selector: getAllPropertySectionState, setter: setAllPropertySectionState, defaultValue: {}, }, { name: FocusElement.SelectedWidgets, selector: getSelectedWidgets, setter: selectMultipleWidgetsInitAction, defaultValue: [], }, { name: FocusElement.CanvasDebuggerTabs, selector: getSelectedCanvasDebuggerTab, setter: setCanvasDebuggerSelectedTab, defaultValue: 0, }, ], [FocusEntity.DATASOURCE]: [ { name: FocusElement.DatasourceViewMode, selector: isDatasourceInViewMode, setter: setDatasourceViewMode, defaultValue: true, }, { name: FocusElement.DatasourceAccordions, selector: getAllDatasourceCollapsibleState, setter: setAllDatasourceCollapsible, }, ], [FocusEntity.JS_OBJECT]: [ { name: FocusElement.CodeEditor, selector: getFocusableCodeEditorField, setter: setFocusableCodeEditorField, }, { name: FocusElement.JSPaneConfigTabs, selector: getJSPaneConfigSelectedTabIndex, setter: setJsPaneConfigSelectedTabIndex, defaultValue: 0, }, { name: FocusElement.JSPaneResponseTabs, selector: getJSPaneResponseSelectedTab, setter: setJsPaneResponseSelectedTab, defaultValue: 0, }, { name: FocusElement.JSPaneResponseHeight, selector: getJSPaneResponsePaneHeight, setter: setJsPaneResponsePaneHeight, defaultValue: ActionExecutionResizerHeight, }, ], [FocusEntity.QUERY]: [ { name: FocusElement.CodeEditor, selector: getFocusableCodeEditorField, setter: setFocusableCodeEditorField, }, { name: FocusElement.QueryPaneConfigTabs, selector: getQueryPaneConfigSelectedTabIndex, setter: setQueryPaneConfigSelectedTabIndex, defaultValue: 0, }, { name: FocusElement.QueryPaneResponseTabs, selector: getQueryPaneResponseSelectedTab, setter: setQueryPaneResponseSelectedTab, defaultValue: 0, }, { name: FocusElement.QueryPaneResponseHeight, selector: getQueryPaneResponsePaneHeight, setter: setQueryPaneResponsePaneHeight, defaultValue: ActionExecutionResizerHeight, }, ], [FocusEntity.PROPERTY_PANE]: [ { name: FocusElement.PropertyTabs, selector: getSelectedPropertyTabIndex, setter: setSelectedPropertyTabIndex, defaultValue: 0, }, { name: FocusElement.PropertyField, selector: getFocusablePropertyPaneField, setter: setFocusablePropertyPaneField, }, ], [FocusEntity.API]: [ { name: FocusElement.CodeEditor, selector: getFocusableCodeEditorField, setter: setFocusableCodeEditorField, }, { name: FocusElement.ApiPaneConfigTabs, selector: getApiPaneConfigSelectedTabIndex, setter: setApiPaneConfigSelectedTabIndex, defaultValue: 0, subTypes: { [PluginPackageName.GRAPHQL]: { defaultValue: 2, }, }, }, { name: FocusElement.ApiPaneResponseTabs, selector: getApiPaneResponseSelectedTab, setter: setApiPaneResponseSelectedTab, defaultValue: 0, }, { name: FocusElement.ApiPaneResponseHeight, selector: getApiPaneResponsePaneHeight, setter: setApiPaneResponsePaneHeight, defaultValue: ActionExecutionResizerHeight, }, { name: FocusElement.ApiRightPaneTabs, selector: getApiRightPaneSelectedTab, setter: setApiRightPaneSelectedTab, }, ], };