## Description Implemented in #21317. A problem arose where if a widget that exists inside a tabs widget is setting the default value of the tab in order to navigate change the tab, it would fail to switch it because the selected widget logic takes over. > Improve selected widget visibility by skipping feature when selection happens via a canvas click Fixes #22070 Media https://user-images.githubusercontent.com/12022471/229714138-55f89cda-3c27-4953-91c0-46f5a9834adf.mov ## Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual - Cypress ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
317 lines
9.4 KiB
TypeScript
317 lines
9.4 KiB
TypeScript
import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
|
|
import type { AppState } from "@appsmith/reducers";
|
|
import {
|
|
setApiPaneConfigSelectedTabIndex,
|
|
setApiPaneResponsePaneHeight,
|
|
setApiPaneResponseSelectedTab,
|
|
setApiRightPaneSelectedTab,
|
|
} from "actions/apiPaneActions";
|
|
import {
|
|
setAllEntityCollapsibleStates,
|
|
setAllSubEntityCollapsibleStates,
|
|
setCodeEditorHistory,
|
|
setExplorerSwitchIndex,
|
|
setFocusableInputField,
|
|
setPanelPropertiesState,
|
|
setWidgetSelectedPropertyTabIndex,
|
|
} from "actions/editorContextActions";
|
|
import {
|
|
getApiPaneConfigSelectedTabIndex,
|
|
getApiPaneResponsePaneHeight,
|
|
getApiPaneResponseSelectedTab,
|
|
getApiRightPaneSelectedTab,
|
|
} from "selectors/apiPaneSelectors";
|
|
import {
|
|
getAllEntityCollapsibleStates,
|
|
getAllPropertySectionState,
|
|
getAllSubEntityCollapsibleStates,
|
|
getCodeEditorHistory,
|
|
getExplorerSwitchIndex,
|
|
getFocusableInputField,
|
|
getPropertyPanelState,
|
|
getSelectedCanvasDebuggerTab,
|
|
getWidgetSelectedPropertyTabIndex,
|
|
} from "selectors/editorContextSelectors";
|
|
import {
|
|
getAllDatasourceCollapsibleState,
|
|
getSelectedWidgets,
|
|
isDatasourceInViewMode,
|
|
} from "selectors/ui";
|
|
|
|
import {
|
|
setAllDatasourceCollapsible,
|
|
setDatasourceViewMode,
|
|
} from "actions/datasourceActions";
|
|
import { setCanvasDebuggerSelectedTab } from "actions/debuggerActions";
|
|
import { updateExplorerWidthAction } from "actions/explorerActions";
|
|
import {
|
|
setJsPaneConfigSelectedTabIndex,
|
|
setJsPaneResponsePaneHeight,
|
|
setJsPaneResponseSelectedTab,
|
|
} from "actions/jsPaneActions";
|
|
import {
|
|
setAllPropertySectionState,
|
|
setFocusablePropertyPaneField,
|
|
setPropertyPaneWidthAction,
|
|
setSelectedPropertyPanels,
|
|
} from "actions/propertyPaneActions";
|
|
import {
|
|
setQueryPaneConfigSelectedTabIndex,
|
|
setQueryPaneResponsePaneHeight,
|
|
setQueryPaneResponseSelectedTab,
|
|
} from "actions/queryPaneActions";
|
|
import { selectWidgetInitAction } from "actions/widgetSelectionActions";
|
|
import {
|
|
DEFAULT_ENTITY_EXPLORER_WIDTH,
|
|
DEFAULT_PROPERTY_PANE_WIDTH,
|
|
} from "constants/AppConstants";
|
|
import { PluginPackageName } from "entities/Action";
|
|
import { FocusEntity } from "navigation/FocusEntity";
|
|
import { ActionExecutionResizerHeight } from "pages/Editor/APIEditor/constants";
|
|
import { SelectionRequestType } from "sagas/WidgetSelectUtils";
|
|
import { getExplorerWidth } from "selectors/explorerSelector";
|
|
import {
|
|
getJSPaneConfigSelectedTabIndex,
|
|
getJSPaneResponsePaneHeight,
|
|
getJSPaneResponseSelectedTab,
|
|
} from "selectors/jsPaneSelectors";
|
|
import {
|
|
getFocusablePropertyPaneField,
|
|
getPropertyPaneWidth,
|
|
getSelectedPropertyPanel,
|
|
} from "selectors/propertyPaneSelectors";
|
|
import {
|
|
getQueryPaneConfigSelectedTabIndex,
|
|
getQueryPaneResponsePaneHeight,
|
|
getQueryPaneResponseSelectedTab,
|
|
} from "selectors/queryPaneSelectors";
|
|
import { NavigationMethod } from "../utils/history";
|
|
|
|
export enum FocusElement {
|
|
ApiPaneConfigTabs = "ApiPaneConfigTabs",
|
|
ApiPaneResponseTabs = "ApiPaneResponseTabs",
|
|
ApiPaneResponseHeight = "ApiPaneResponseHeight",
|
|
CanvasDebuggerTabs = "CanvasDebuggerTabs",
|
|
CodeEditorHistory = "CodeEditorHistory",
|
|
EntityCollapsibleState = "EntityCollapsibleState",
|
|
EntityExplorerWidth = "EntityExplorerWidth",
|
|
ExplorerSwitchIndex = "ExplorerSwitchIndex",
|
|
DatasourceViewMode = "DatasourceViewMode",
|
|
DatasourceAccordions = "DatasourceAccordions",
|
|
ApiRightPaneTabs = "ApiRightPaneTabs",
|
|
QueryPaneConfigTabs = "QueryPaneConfigTabs",
|
|
QueryPaneResponseTabs = "QueryPaneResponseTabs",
|
|
QueryPaneResponseHeight = "QueryPaneResponseHeight",
|
|
JSPaneConfigTabs = "JSPaneConfigTabs",
|
|
JSPaneResponseTabs = "JSPaneResponseTabs",
|
|
JSPaneResponseHeight = "JSPaneResponseHeight",
|
|
PropertySections = "PropertySections",
|
|
PropertyField = "PropertyField",
|
|
PropertyTabs = "PropertyTabs",
|
|
PropertyPanelContext = "PropertyPanelContext",
|
|
PropertyPaneWidth = "PropertyPaneWidth",
|
|
SelectedPropertyPanel = "SelectedPropertyPanel",
|
|
SelectedWidgets = "SelectedWidgets",
|
|
SubEntityCollapsibleState = "SubEntityCollapsibleState",
|
|
InputField = "InputField",
|
|
}
|
|
|
|
type Config = {
|
|
name: FocusElement;
|
|
selector: (state: AppState) => unknown;
|
|
setter: (payload: any) => ReduxAction<any>;
|
|
defaultValue?: unknown;
|
|
subTypes?: Record<string, { defaultValue: unknown }>;
|
|
};
|
|
|
|
export const FocusElementsConfig: Record<FocusEntity, Config[]> = {
|
|
[FocusEntity.NONE]: [],
|
|
[FocusEntity.PAGE]: [
|
|
{
|
|
name: FocusElement.CodeEditorHistory,
|
|
selector: getCodeEditorHistory,
|
|
setter: setCodeEditorHistory,
|
|
defaultValue: {},
|
|
},
|
|
{
|
|
name: FocusElement.EntityExplorerWidth,
|
|
selector: getExplorerWidth,
|
|
setter: updateExplorerWidthAction,
|
|
defaultValue: DEFAULT_ENTITY_EXPLORER_WIDTH,
|
|
},
|
|
{
|
|
name: FocusElement.EntityCollapsibleState,
|
|
selector: getAllEntityCollapsibleStates,
|
|
setter: setAllEntityCollapsibleStates,
|
|
defaultValue: {},
|
|
},
|
|
{
|
|
name: FocusElement.SubEntityCollapsibleState,
|
|
selector: getAllSubEntityCollapsibleStates,
|
|
setter: setAllSubEntityCollapsibleStates,
|
|
defaultValue: {},
|
|
},
|
|
{
|
|
name: FocusElement.ExplorerSwitchIndex,
|
|
selector: getExplorerSwitchIndex,
|
|
setter: setExplorerSwitchIndex,
|
|
defaultValue: 0,
|
|
},
|
|
{
|
|
name: FocusElement.PropertyPanelContext,
|
|
selector: getPropertyPanelState,
|
|
setter: setPanelPropertiesState,
|
|
defaultValue: {},
|
|
},
|
|
],
|
|
[FocusEntity.CANVAS]: [
|
|
{
|
|
name: FocusElement.PropertySections,
|
|
selector: getAllPropertySectionState,
|
|
setter: setAllPropertySectionState,
|
|
defaultValue: {},
|
|
},
|
|
{
|
|
name: FocusElement.SelectedPropertyPanel,
|
|
selector: getSelectedPropertyPanel,
|
|
setter: setSelectedPropertyPanels,
|
|
defaultValue: {},
|
|
},
|
|
{
|
|
name: FocusElement.SelectedWidgets,
|
|
selector: getSelectedWidgets,
|
|
setter: (widgetIds: string[]) =>
|
|
selectWidgetInitAction(
|
|
SelectionRequestType.Multiple,
|
|
widgetIds,
|
|
NavigationMethod.ContextSwitching,
|
|
),
|
|
defaultValue: [],
|
|
},
|
|
{
|
|
name: FocusElement.CanvasDebuggerTabs,
|
|
selector: getSelectedCanvasDebuggerTab,
|
|
setter: setCanvasDebuggerSelectedTab,
|
|
defaultValue: 0,
|
|
},
|
|
{
|
|
name: FocusElement.PropertyPaneWidth,
|
|
selector: getPropertyPaneWidth,
|
|
setter: setPropertyPaneWidthAction,
|
|
defaultValue: DEFAULT_PROPERTY_PANE_WIDTH,
|
|
},
|
|
],
|
|
[FocusEntity.DATASOURCE]: [
|
|
{
|
|
name: FocusElement.DatasourceViewMode,
|
|
selector: isDatasourceInViewMode,
|
|
setter: setDatasourceViewMode,
|
|
defaultValue: true,
|
|
},
|
|
{
|
|
name: FocusElement.DatasourceAccordions,
|
|
selector: getAllDatasourceCollapsibleState,
|
|
setter: setAllDatasourceCollapsible,
|
|
},
|
|
],
|
|
[FocusEntity.JS_OBJECT]: [
|
|
{
|
|
name: FocusElement.InputField,
|
|
selector: getFocusableInputField,
|
|
setter: setFocusableInputField,
|
|
},
|
|
{
|
|
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.InputField,
|
|
selector: getFocusableInputField,
|
|
setter: setFocusableInputField,
|
|
},
|
|
{
|
|
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: getWidgetSelectedPropertyTabIndex,
|
|
setter: setWidgetSelectedPropertyTabIndex,
|
|
defaultValue: 0,
|
|
},
|
|
{
|
|
name: FocusElement.PropertyField,
|
|
selector: getFocusablePropertyPaneField,
|
|
setter: setFocusablePropertyPaneField,
|
|
defaultValue: "",
|
|
},
|
|
],
|
|
[FocusEntity.API]: [
|
|
{
|
|
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.InputField,
|
|
selector: getFocusableInputField,
|
|
setter: setFocusableInputField,
|
|
},
|
|
{
|
|
name: FocusElement.ApiRightPaneTabs,
|
|
selector: getApiRightPaneSelectedTab,
|
|
setter: setApiRightPaneSelectedTab,
|
|
},
|
|
],
|
|
};
|