PromucFlow_constructor/app/client/src/actions/widgetSelectionActions.ts
Hetu Nandu c155a511f1
chore: Separate files for Redux Types (#38559)
Co-authored-by: Diljit <diljit@appsmith.com>
2025-01-10 10:21:54 +05:30

70 lines
2.0 KiB
TypeScript

import type { ReduxAction } from "./ReduxActionTypes";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import type { SelectionRequestType } from "sagas/WidgetSelectUtils";
import type { NavigationMethod } from "utils/history";
export interface WidgetSelectionRequestPayload {
selectionRequestType: SelectionRequestType;
payload?: string[];
invokedBy?: NavigationMethod;
basePageId?: string;
parentId?: string;
}
export type WidgetSelectionRequest = (
selectionRequestType: SelectionRequestType,
payload?: string[],
invokedBy?: NavigationMethod,
basePageId?: string,
parentId?: string,
) => ReduxAction<WidgetSelectionRequestPayload>;
// Use to select a widget programmatically via platform action
export const selectWidgetInitAction: WidgetSelectionRequest = (
selectionRequestType,
payload,
invokedBy?: NavigationMethod,
basePageId?: string,
parentId?: string,
) => ({
type: ReduxActionTypes.SELECT_WIDGET_INIT,
payload: { selectionRequestType, payload, basePageId, invokedBy, parentId },
});
export interface SetSelectedWidgetsPayload {
widgetIds: string[];
invokedBy?: NavigationMethod;
}
// To be used to collect selected widget state from url and set on state
export const setSelectedWidgets = (
widgetIds: string[],
invokedBy?: NavigationMethod,
): ReduxAction<SetSelectedWidgetsPayload> => {
return {
type: ReduxActionTypes.SET_SELECTED_WIDGETS,
payload: { widgetIds, invokedBy },
};
};
export const setLastSelectedWidget = (widgetId: string) => {
return {
type: ReduxActionTypes.SET_LAST_SELECTED_WIDGET,
payload: { lastSelectedWidget: widgetId },
};
};
export const setSelectedWidgetAncestry = (widgetIds: string[]) => {
return {
type: ReduxActionTypes.SET_SELECTED_WIDGET_ANCESTRY,
payload: widgetIds,
};
};
export const setEntityExplorerAncestry = (widgetIds: string[]) => {
return {
type: ReduxActionTypes.SET_ENTITY_EXPLORER_WIDGET_ANCESTRY,
payload: widgetIds,
};
};