2022-04-12 10:50:01 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxAction,
|
|
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2023-01-28 02:17:06 +00:00
|
|
|
import { SelectionRequestType } from "sagas/WidgetSelectUtils";
|
2021-06-17 13:26:54 +00:00
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
export type WidgetSelectionRequestPayload = {
|
|
|
|
|
selectionRequestType: SelectionRequestType;
|
|
|
|
|
payload?: string[];
|
2022-12-02 05:49:51 +00:00
|
|
|
};
|
|
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
export type WidgetSelectionRequest = (
|
|
|
|
|
selectionRequestType: SelectionRequestType,
|
|
|
|
|
payload?: string[],
|
|
|
|
|
) => ReduxAction<WidgetSelectionRequestPayload>;
|
2022-12-02 05:49:51 +00:00
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
// Use to select a widget programmatically via platform action
|
|
|
|
|
export const selectWidgetInitAction: WidgetSelectionRequest = (
|
|
|
|
|
selectionRequestType,
|
|
|
|
|
payload,
|
|
|
|
|
) => ({
|
2021-06-17 13:26:54 +00:00
|
|
|
type: ReduxActionTypes.SELECT_WIDGET_INIT,
|
2023-01-28 02:17:06 +00:00
|
|
|
payload: { selectionRequestType, payload },
|
2021-06-17 13:26:54 +00:00
|
|
|
});
|
|
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
// To be used to collect selected widget state from url and set on state
|
|
|
|
|
export const setSelectedWidgets = (widgetIds: string[]) => {
|
2021-06-17 13:26:54 +00:00
|
|
|
return {
|
2023-01-28 02:17:06 +00:00
|
|
|
type: ReduxActionTypes.SET_SELECTED_WIDGETS,
|
2021-06-17 13:26:54 +00:00
|
|
|
payload: { widgetIds },
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
export const setLastSelectedWidget = (widgetId: string) => {
|
2021-06-17 13:26:54 +00:00
|
|
|
return {
|
2023-01-28 02:17:06 +00:00
|
|
|
type: ReduxActionTypes.SET_LAST_SELECTED_WIDGET,
|
|
|
|
|
payload: { lastSelectedWidget: widgetId },
|
2021-06-17 13:26:54 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
export const setSelectedWidgetAncestry = (widgetIds: string[]) => {
|
2021-06-28 07:11:47 +00:00
|
|
|
return {
|
2023-01-28 02:17:06 +00:00
|
|
|
type: ReduxActionTypes.SET_SELECTED_WIDGET_ANCESTRY,
|
|
|
|
|
payload: widgetIds,
|
2021-06-28 07:11:47 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-17 15:16:38 +00:00
|
|
|
export const appendSelectedWidgetToUrl = (selectedWidgets: string[]) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.APPEND_SELECTED_WIDGET_TO_URL,
|
|
|
|
|
payload: { selectedWidgets },
|
|
|
|
|
};
|
|
|
|
|
};
|