2022-04-12 10:50:01 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxAction,
|
|
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2022-10-17 15:16:38 +00:00
|
|
|
import { CanvasWidgetsStructureReduxState } from "reducers/entityReducers/canvasWidgetsStructureReducer";
|
2021-06-17 13:26:54 +00:00
|
|
|
|
2022-12-02 05:49:51 +00:00
|
|
|
export type SelectWidgetActionPayload = {
|
|
|
|
|
widgetId?: string;
|
|
|
|
|
isMultiSelect?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type SelectMultipleWidgetsActionPayload = { widgetIds?: string[] };
|
|
|
|
|
|
2021-06-17 13:26:54 +00:00
|
|
|
export const selectWidgetAction = (
|
|
|
|
|
widgetId?: string,
|
|
|
|
|
isMultiSelect?: boolean,
|
2022-12-02 05:49:51 +00:00
|
|
|
): ReduxAction<SelectWidgetActionPayload> => ({
|
2021-06-17 13:26:54 +00:00
|
|
|
type: ReduxActionTypes.SELECT_WIDGET,
|
|
|
|
|
payload: { widgetId, isMultiSelect },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const selectWidgetInitAction = (
|
|
|
|
|
widgetId?: string,
|
|
|
|
|
isMultiSelect?: boolean,
|
2022-12-02 05:49:51 +00:00
|
|
|
): ReduxAction<SelectWidgetActionPayload> => ({
|
2021-06-17 13:26:54 +00:00
|
|
|
type: ReduxActionTypes.SELECT_WIDGET_INIT,
|
|
|
|
|
payload: { widgetId, isMultiSelect },
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-16 09:24:42 +00:00
|
|
|
export const deselectAllInitAction = () => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.DESELECT_MULTIPLE_WIDGETS_INIT,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-28 07:11:47 +00:00
|
|
|
export const selectMultipleWidgetsAction = (
|
2021-06-17 13:26:54 +00:00
|
|
|
widgetIds?: string[],
|
2022-12-02 05:49:51 +00:00
|
|
|
): ReduxAction<SelectMultipleWidgetsActionPayload> => {
|
2021-06-17 13:26:54 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SELECT_MULTIPLE_WIDGETS,
|
|
|
|
|
payload: { widgetIds },
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-28 07:11:47 +00:00
|
|
|
export const silentAddSelectionsAction = (
|
2021-06-17 13:26:54 +00:00
|
|
|
widgetIds?: string[],
|
2022-12-02 05:49:51 +00:00
|
|
|
): ReduxAction<SelectMultipleWidgetsActionPayload> => {
|
2021-06-17 13:26:54 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SELECT_WIDGETS,
|
|
|
|
|
payload: { widgetIds },
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const deselectMultipleWidgetsAction = (
|
|
|
|
|
widgetIds?: string[],
|
2022-12-02 05:49:51 +00:00
|
|
|
): ReduxAction<SelectMultipleWidgetsActionPayload> => {
|
2021-06-17 13:26:54 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.DESELECT_WIDGETS,
|
|
|
|
|
payload: { widgetIds },
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-24 11:38:20 +00:00
|
|
|
export const selectAllWidgetsInCanvasInitAction = () => {
|
2021-06-28 07:11:47 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SELECT_ALL_WIDGETS_IN_CANVAS_INIT,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const selectMultipleWidgetsInitAction = (widgetIds: string[]) => {
|
2021-06-17 13:26:54 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SELECT_MULTIPLE_WIDGETS_INIT,
|
2021-06-28 07:11:47 +00:00
|
|
|
payload: { widgetIds },
|
2021-06-17 13:26:54 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-17 15:16:38 +00:00
|
|
|
export const deselectModalWidgetAction = (
|
|
|
|
|
modalId: string,
|
|
|
|
|
modalWidgetChildren?: CanvasWidgetsStructureReduxState[],
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.DESELECT_MODAL_WIDGETS,
|
|
|
|
|
payload: { modalId, modalWidgetChildren },
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-17 13:26:54 +00:00
|
|
|
export const shiftSelectWidgetsEntityExplorerInitAction = (
|
|
|
|
|
widgetId: string,
|
|
|
|
|
siblingWidgets: string[],
|
|
|
|
|
): ReduxAction<{ widgetId: string; siblingWidgets: string[] }> => ({
|
|
|
|
|
type: ReduxActionTypes.SHIFT_SELECT_WIDGET_INIT,
|
|
|
|
|
payload: { widgetId, siblingWidgets },
|
|
|
|
|
});
|
2022-10-17 15:16:38 +00:00
|
|
|
|
|
|
|
|
export const appendSelectedWidgetToUrl = (selectedWidgets: string[]) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.APPEND_SELECTED_WIDGET_TO_URL,
|
|
|
|
|
payload: { selectedWidgets },
|
|
|
|
|
};
|
|
|
|
|
};
|