## Description ### Part 3 of selected widget refactor As part of context switching and selected widget refactor, we saw that widgets that are inside modals or tabs and are hidden cannot be switched to without updating some meta properties. The meta properties are actually owned by the end user and the developer user would create some default values for it as well. This becomes a problem soon when the platform also tries to update it. So as part of this refactor, we will use the selected widget ancestry (the chain of widgets from the top to the currently selected widget) to handle if widgets need to be visible or not. It will also indicate the widgets in the path of selection to "make way" for the selected widget to be seen. Media https://user-images.githubusercontent.com/12022471/224916943-b10e8694-0c95-4157-bb93-288d7c0bf60a.mov - This works on any number of levels of hirarchy - The logic is supposed to handled by each widget that can potentially hide other widgets inside it - Improves some platform perf as the handing so widget meta is not done by the platform anymore Affected widgets: - Modal Widget - Tabs Widget > tl;dr: Update the platform's way to show widgets that can be hidden. Makes sure a selected widget is always shown. Fixes #1282 Resolves #18173 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual - Cypress ### Test Plan > Test case link:- [#2202](https://github.com/appsmithorg/TestSmith/issues/2202) ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity:- https://github.com/appsmithorg/appsmith/issues/1282#issuecomment-1472204952 ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] 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 - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [x] Test plan has been approved by relevant developers - [x] 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
133 lines
2.8 KiB
TypeScript
133 lines
2.8 KiB
TypeScript
import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
|
|
import {
|
|
ReduxActionTypes,
|
|
WidgetReduxActionTypes,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import type { ExecuteTriggerPayload } from "constants/AppsmithActionConstants/ActionConstants";
|
|
import type { BatchAction } from "actions/batchActions";
|
|
import { batchAction } from "actions/batchActions";
|
|
import type { WidgetProps } from "widgets/BaseWidget";
|
|
|
|
export const executeTrigger = (
|
|
payload: ExecuteTriggerPayload,
|
|
): BatchAction<ExecuteTriggerPayload> =>
|
|
batchAction({
|
|
type: ReduxActionTypes.EXECUTE_TRIGGER_REQUEST,
|
|
payload,
|
|
});
|
|
|
|
export const disableDragAction = (
|
|
isDraggingDisabled: boolean,
|
|
): ReduxAction<{ isDraggingDisabled: boolean }> => {
|
|
return {
|
|
type: ReduxActionTypes.DISABLE_WIDGET_DRAG,
|
|
payload: {
|
|
isDraggingDisabled,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const createModalAction = (
|
|
modalName: string,
|
|
): ReduxAction<{ modalName: string }> => {
|
|
return {
|
|
type: ReduxActionTypes.CREATE_MODAL_INIT,
|
|
payload: {
|
|
modalName,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const focusWidget = (
|
|
widgetId?: string,
|
|
): ReduxAction<{ widgetId?: string }> => ({
|
|
type: ReduxActionTypes.FOCUS_WIDGET,
|
|
payload: { widgetId },
|
|
});
|
|
|
|
export const showModal = (id: string, shouldSelectModal = true) => {
|
|
return {
|
|
type: ReduxActionTypes.SHOW_MODAL,
|
|
payload: {
|
|
modalId: id,
|
|
shouldSelectModal,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const closePropertyPane = () => {
|
|
return {
|
|
type: ReduxActionTypes.HIDE_PROPERTY_PANE,
|
|
payload: {
|
|
force: false,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const closeTableFilterPane = () => {
|
|
return {
|
|
type: ReduxActionTypes.HIDE_TABLE_FILTER_PANE,
|
|
payload: {
|
|
force: false,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const copyWidget = (isShortcut: boolean) => {
|
|
return {
|
|
type: ReduxActionTypes.COPY_SELECTED_WIDGET_INIT,
|
|
payload: {
|
|
isShortcut: !!isShortcut,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const pasteWidget = (
|
|
groupWidgets = false,
|
|
mouseLocation: { x: number; y: number },
|
|
) => {
|
|
return {
|
|
type: ReduxActionTypes.PASTE_COPIED_WIDGET_INIT,
|
|
payload: {
|
|
groupWidgets: groupWidgets,
|
|
mouseLocation,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const deleteSelectedWidget = (
|
|
isShortcut: boolean,
|
|
disallowUndo = false,
|
|
) => {
|
|
return {
|
|
type: WidgetReduxActionTypes.WIDGET_DELETE,
|
|
payload: {
|
|
isShortcut,
|
|
disallowUndo,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const cutWidget = () => {
|
|
return {
|
|
type: ReduxActionTypes.CUT_SELECTED_WIDGET,
|
|
};
|
|
};
|
|
|
|
export const addSuggestedWidget = (payload: Partial<WidgetProps>) => {
|
|
return {
|
|
type: ReduxActionTypes.ADD_SUGGESTED_WIDGET,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
/**
|
|
* action to group selected widgets into container
|
|
* @returns
|
|
*/
|
|
export const groupWidgets = () => {
|
|
return {
|
|
type: ReduxActionTypes.GROUP_WIDGETS_INIT,
|
|
};
|
|
};
|