Merge branch 'feature/actions' into 'release'

Feature/actions

See merge request theappsmith/internal-tools-client!26
This commit is contained in:
Abhinav Jha 2019-09-20 09:41:27 +00:00
commit 5d42a8c909
23 changed files with 593 additions and 133 deletions

View File

@ -1,7 +1,7 @@
import API, { HttpMethod } from "./Api"; import API, { HttpMethod } from "./Api";
import { ApiResponse } from "./ApiResponses"; import { ApiResponse } from "./ApiResponses";
import { APIRequest } from "./ApiRequests"; import { APIRequest } from "./ApiRequests";
import _ from "lodash"; import { mapToPropList } from "../utils/AppsmithUtils";
export interface CreateActionRequest<T> extends APIRequest { export interface CreateActionRequest<T> extends APIRequest {
resourceId: string; resourceId: string;
@ -48,7 +48,7 @@ export interface ActionCreateUpdateResponse extends ApiResponse {
export interface ExecuteActionRequest extends APIRequest { export interface ExecuteActionRequest extends APIRequest {
actionId: string; actionId: string;
dynamicBindingMap: Record<string, any>; dynamicBindingList?: Property[];
} }
export interface ExecuteActionResponse extends ApiResponse { export interface ExecuteActionResponse extends ApiResponse {
@ -67,12 +67,8 @@ class ActionAPI extends API {
httpMethod: apiConfig.method, httpMethod: apiConfig.method,
path: apiConfig.path, path: apiConfig.path,
body: apiConfig.body, body: apiConfig.body,
headers: _.map(apiConfig.requestHeaders, (value, key) => { headers: mapToPropList(apiConfig.requestHeaders),
return { key: key, value: value }; queryParameters: mapToPropList(apiConfig.queryParams),
}),
queryParameters: _.map(apiConfig.queryParams, (value, key) => {
return { key: key, value: value };
}),
}, },
}; };
return API.post(ActionAPI.url, createAPI); return API.post(ActionAPI.url, createAPI);
@ -87,12 +83,8 @@ class ActionAPI extends API {
httpMethod: apiConfig.method, httpMethod: apiConfig.method,
path: apiConfig.path, path: apiConfig.path,
body: apiConfig.body, body: apiConfig.body,
headers: _.map(apiConfig.requestHeaders, (value, key) => { headers: mapToPropList(apiConfig.requestHeaders),
return { key: key, value: value }; queryParameters: mapToPropList(apiConfig.queryParams),
}),
queryParameters: _.map(apiConfig.queryParams, (value, key) => {
return { key: key, value: value };
}),
}, },
}; };
return API.post(ActionAPI.url, updateAPI); return API.post(ActionAPI.url, updateAPI);
@ -113,7 +105,7 @@ class ActionAPI extends API {
static executeAction( static executeAction(
executeAction: ExecuteActionRequest, executeAction: ExecuteActionRequest,
): Promise<ActionCreateUpdateResponse> { ): Promise<ActionCreateUpdateResponse> {
return API.post(ActionAPI.url, executeAction); return API.post(ActionAPI.url + "/execute", executeAction);
} }
} }

View File

@ -47,7 +47,7 @@ class Api {
); );
} }
static post(url: string, queryParams?: any, body?: any) { static post(url: string, body?: any, queryParams?: any) {
return axiosInstance.post( return axiosInstance.post(
url + this.convertObjectToQueryParams(queryParams), url + this.convertObjectToQueryParams(queryParams),
body, body,

View File

@ -14,7 +14,7 @@ export interface SavePageRequest {
} }
export interface PageLayout { export interface PageLayout {
dsl: ContainerWidgetProps<any>; dsl: Partial<ContainerWidgetProps<any>>;
actions: PageAction[]; actions: PageAction[];
} }

View File

@ -22,18 +22,11 @@ export type ActionType =
| "DOWNLOAD"; | "DOWNLOAD";
export interface ActionPayload { export interface ActionPayload {
actionId: string;
actionType: ActionType; actionType: ActionType;
contextParams: Record<string, string>; contextParams: Record<string, string>;
} }
export interface APIActionPayload extends ActionPayload {
apiId: string;
}
export interface QueryActionPayload extends ActionPayload {
queryId: string;
}
export type NavigationType = "NEW_TAB" | "INLINE"; export type NavigationType = "NEW_TAB" | "INLINE";
export interface NavigateActionPayload extends ActionPayload { export interface NavigateActionPayload extends ActionPayload {
@ -71,5 +64,5 @@ export interface PageAction {
actionId: string; actionId: string;
actionType: ActionType; actionType: ActionType;
actionName: string; actionName: string;
dynamicBindings: string[]; dynamicBindings?: string[];
} }

View File

@ -9,9 +9,8 @@ export type EncodingType = "gzip";
export const PROD_BASE_URL = "https://mobtools.com/api/"; export const PROD_BASE_URL = "https://mobtools.com/api/";
export const MOCK_BASE_URL = export const MOCK_BASE_URL =
"https://f78ff9dd-2c08-45f1-9bf9-8c670a1bb696.mock.pstmn.io"; "https://f78ff9dd-2c08-45f1-9bf9-8c670a1bb696.mock.pstmn.io";
export const STAGE_BASE_URL = export const STAGE_BASE_URL = "https://appsmith-test.herokuapp.com";
"https://14157cb0-190f-4082-a791-886a8df05930.mock.pstmn.io"; export const BASE_URL = STAGE_BASE_URL;
export const BASE_URL = MOCK_BASE_URL;
export const REQUEST_TIMEOUT_MS = 2000; export const REQUEST_TIMEOUT_MS = 2000;
export const REQUEST_HEADERS: APIHeaders = { export const REQUEST_HEADERS: APIHeaders = {
Accept: "application/json", Accept: "application/json",

View File

@ -7,4 +7,11 @@ export type ControlType =
| "DATE_PICKER" | "DATE_PICKER"
| "DROP_DOWN" | "DROP_DOWN"
| "COLOR_PICKER" | "COLOR_PICKER"
| "TIMEZONE_PICKER"
| "ACTION_SELECTOR"
| "RECORD_ACTION_SELECTOR"
| "OPTION_INPUT"
| "IMAGE_PICKER"
| "SHAPE_PICKER"
| "VALIDATION_INPUT"
| "ZOOM"; | "ZOOM";

View File

@ -2,7 +2,7 @@
import { WidgetProps, WidgetCardProps } from "../widgets/BaseWidget"; import { WidgetProps, WidgetCardProps } from "../widgets/BaseWidget";
export type ReduxActionType = export type ReduxActionType =
| "LOAD_CANVAS_WIDGETS" | "UPDATE_CANVAS"
| "FETCH_CANVAS" | "FETCH_CANVAS"
| "CLEAR_CANVAS" | "CLEAR_CANVAS"
| "DROP_WIDGET_CANVAS" | "DROP_WIDGET_CANVAS"
@ -29,7 +29,7 @@ export type ReduxActionType =
| "SHOW_PROPERTY_PANE"; | "SHOW_PROPERTY_PANE";
export const ReduxActionTypes: { [id: string]: ReduxActionType } = { export const ReduxActionTypes: { [id: string]: ReduxActionType } = {
LOAD_CANVAS_WIDGETS: "LOAD_CANVAS_WIDGETS", UPDATE_CANVAS: "UPDATE_CANVAS",
FETCH_CANVAS: "FETCH_CANVAS", FETCH_CANVAS: "FETCH_CANVAS",
CLEAR_CANVAS: "CLEAR_CANVAS", CLEAR_CANVAS: "CLEAR_CANVAS",
FETCH_PAGE: "FETCH_PAGE", FETCH_PAGE: "FETCH_PAGE",

View File

@ -10,8 +10,7 @@ export type WidgetType =
| "CHECKBOX_WIDGET" | "CHECKBOX_WIDGET"
| "RADIO_GROUP_WIDGET" | "RADIO_GROUP_WIDGET"
| "INPUT_WIDGET" | "INPUT_WIDGET"
| "SWITCH_WIDGET" | "SWITCH_WIDGET";
| "ALERT_WIDGET";
export const WidgetTypes: { [id: string]: WidgetType } = { export const WidgetTypes: { [id: string]: WidgetType } = {
BUTTON_WIDGET: "BUTTON_WIDGET", BUTTON_WIDGET: "BUTTON_WIDGET",
@ -26,7 +25,6 @@ export const WidgetTypes: { [id: string]: WidgetType } = {
DROP_DOWN_WIDGET: "DROP_DOWN_WIDGET", DROP_DOWN_WIDGET: "DROP_DOWN_WIDGET",
CHECKBOX_WIDGET: "CHECKBOX_WIDGET", CHECKBOX_WIDGET: "CHECKBOX_WIDGET",
RADIO_GROUP_WIDGET: "RADIO_GROUP_WIDGET", RADIO_GROUP_WIDGET: "RADIO_GROUP_WIDGET",
ALERT_WIDGET: "ALERT_WIDGET",
}; };
export type ContainerOrientation = "HORIZONTAL" | "VERTICAL"; export type ContainerOrientation = "HORIZONTAL" | "VERTICAL";

View File

@ -0,0 +1,44 @@
import { PageResponse } from "../api/PageApi";
const PageMockResponse: PageResponse = {
responseMeta: {
responseCode: "SUCCESS",
},
layout: {
dsl: {
widgetId: "0",
widgetType: "CONTAINER_WIDGET",
topRow: 2,
leftColumn: 2,
rightColumn: 10,
bottomRow: 10,
children: [
{
widgetId: "1",
widgetType: "BUTTON_WIDGET",
topRow: 2,
leftColumn: 2,
text: "submit",
rightColumn: 10,
bottomRow: 10,
onClick: [
{
actionId: "5d8082e2795dc6000482bc84",
actionType: "API",
},
],
},
],
},
actions: [
{
actionId: "5d8082e2795dc6000482bc84",
actionType: "API",
actionName: "getUsers",
dynamicBindings: ["$.apiData.0.name"],
},
],
},
};
export default PageMockResponse;

View File

@ -8,14 +8,14 @@ const PropertyPaneConfigResponse: PropertyPaneConfigState = {
id: "1", id: "1",
children: [ children: [
{ {
id: "1", id: "1.1",
propertyName: "text", propertyName: "text",
label: "Button Text", label: "Button Text",
controlType: "INPUT_TEXT", controlType: "INPUT_TEXT",
placeholderText: "Enter button text here", placeholderText: "Enter button text here",
}, },
{ {
id: "2", id: "1.2",
propertyName: "buttonStyle", propertyName: "buttonStyle",
label: "Button Style", label: "Button Style",
controlType: "DROP_DOWN", controlType: "DROP_DOWN",
@ -24,18 +24,29 @@ const PropertyPaneConfigResponse: PropertyPaneConfigState = {
{ label: "Secondary Button", value: "SECONDARY_BUTTON" }, { label: "Secondary Button", value: "SECONDARY_BUTTON" },
], ],
}, },
{
id: "1.3",
propertyName: "isDisabled",
label: "Disabled",
controlType: "SWITCH",
},
{
id: "1.4",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
], ],
}, },
{ {
sectionName: "Action", sectionName: "Actions",
id: "2", id: "2",
children: [ children: [
{ {
id: "3", id: "2.1",
propertyName: "text", propertyName: "onClick",
label: "Button Text", label: "onClick",
controlType: "INPUT_TEXT", controlType: "ACTION_SELECTOR",
placeholderText: "Enter button text here",
}, },
], ],
}, },
@ -44,84 +55,497 @@ const PropertyPaneConfigResponse: PropertyPaneConfigState = {
{ {
sectionName: "General", sectionName: "General",
id: "3", id: "3",
children: [], children: [
{
id: "3.1",
propertyName: "text",
label: "Text",
controlType: "INPUT_TEXT",
placeholderText: "Enter your text here",
},
{
id: "3.2",
propertyName: "textStyle",
label: "Text Style",
controlType: "DROP_DOWN",
options: [
{ label: "Heading", value: "HEADING" },
{ label: "Label", value: "LABEL" },
{ label: "Body", value: "BODY" },
{ label: "Sub text", value: "SUB_TEXT" },
],
},
{
id: "3.3",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
],
}, },
], ],
IMAGE_WIDGET: [ IMAGE_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "4", id: "4",
children: [], children: [
{
id: "4.1",
propertyName: "image",
label: "Image",
controlType: "IMAGE_PICKER",
},
{
id: "4.2",
propertyName: "defaultImage",
label: "Default Image",
controlType: "IMAGE_PICKER",
},
{
id: "4.3",
propertyName: "imageShape",
label: "Shape",
controlType: "SHAPE_PICKER",
},
{
id: "4.4",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
],
}, },
], ],
INPUT_WIDGET: [ INPUT_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "5", id: "5",
children: [], children: [
{
id: "5.1",
propertyName: "label",
label: "Label",
controlType: "INPUT_TEXT",
inputType: "TEXT",
placeholderText: "Label the widget",
},
{
id: "5.2",
propertyName: "inputType",
label: "Data Type",
controlType: "DROP_DOWN",
options: [
{ label: "Text", value: "TEXT" },
{ label: "Number", value: "NUMBER" },
{ label: "Integer", value: "INTEGER" },
{ label: "Phone Number", value: "PHONE_NUMBER" },
{ label: "Email", value: "EMAIL" },
{ label: "Passwork", value: "PASSWORD" },
{ label: "Currency", value: "CURRENCY" },
{ label: "Search", value: "SEARCH" },
],
},
{
id: "5.3",
propertyName: "placeholderText",
label: "Placeholder",
controlType: "INPUT_TEXT",
placeholderText: "Enter your text here",
},
{
id: "5.4",
propertyName: "maxChars",
label: "Max Chars",
controlType: "INPUT_TEXT",
inputType: "INTEGER",
placeholderText: "Maximum character length",
},
{
id: "5.5",
propertyName: "validators",
label: "Validators",
controlType: "VALIDATION_INPUT",
},
{
id: "5.6",
children: [
{
id: "5.6.1",
propertyName: "focusIndexx",
label: "Focus Index",
controlType: "INPUT_TEXT",
inputType: "INTEGER",
placeholderText: "Enter the order of tab focus",
},
{
id: "5.6.2",
propertyName: "autoFocus",
label: "Auto Focus",
controlType: "SWITCH",
},
],
},
{
id: "5.7",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
{
id: "5.8",
propertyName: "isDisabled",
label: "Disabled",
controlType: "SWITCH",
},
],
}, },
], ],
SWITCH_WIDGET: [ SWITCH_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "6", id: "6",
children: [], children: [
{
id: "6.1",
propertyName: "label",
label: "Label",
controlType: "INPUT_TEXT",
inputType: "TEXT",
placeholderText: "Label the widget",
},
{
id: "6.2",
propertyName: "isOn",
label: "Default State",
controlType: "SWITCH",
},
{
id: "6.3",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
{
id: "6.4",
propertyName: "isDisabled",
label: "Disabled",
controlType: "SWITCH",
},
],
}, },
], ],
CONTAINER_WIDGET: [ CONTAINER_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "7", id: "7",
children: [], children: [
{
id: "7.1",
propertyName: "backgroundColor",
label: "Background Color",
controlType: "COLOR_PICKER",
},
{
id: "6.3",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
],
}, },
], ],
SPINNER_WIDGET: [ SPINNER_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "8", id: "8",
children: [], children: [
{
id: "8.1",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
],
}, },
], ],
DATE_PICKER_WIDGET: [ DATE_PICKER_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "9", id: "9",
children: [], children: [
{
id: "9.1",
propertyName: "datePickerType",
label: "Picker Type",
controlType: "DROP_DOWN",
options: [
{ label: "Single Date", value: "DATE_PICKER" },
{ label: "Date Range", value: "DATE_RANGE_PICKER" },
],
},
{
id: "9.4",
propertyName: "label",
label: "Enter Date Label",
controlType: "INPUT_TEXT",
},
{
id: "9.1",
propertyName: "defaultDate",
label: "Default Date",
controlType: "DATE_PICKER",
},
{
id: "9.2",
propertyName: "defaultTimezone",
label: "Default Timezone",
controlType: "TIMEZONE_PICKER",
},
{
id: "9.3",
propertyName: "enableTime",
label: "Enable Pick Time",
controlType: "SWITCH",
},
{
id: "9.5",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
{
id: "9.6",
propertyName: "isDisabled",
label: "Disabled",
controlType: "SWITCH",
},
],
},
{
sectionName: "Actions",
id: "10",
children: [
{
id: "10.1",
propertyName: "onDateSelected",
label: "onDateSelected",
controlType: "ACTION_SELECTOR",
},
{
id: "10.2",
propertyName: "onDateRangeSelected",
label: "onDateRangeSelected",
controlType: "ACTION_SELECTOR",
},
],
}, },
], ],
TABLE_WIDGET: [ TABLE_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "9", id: "11",
children: [], children: [
{
id: "11.1",
propertyName: "label",
label: "Enter Table Label",
controlType: "INPUT_TEXT",
},
{
id: "11.2",
propertyName: "tableData",
label: "Enter data array",
controlType: "INPUT_TEXT",
},
{
id: "11.3",
propertyName: "nextPageKey",
label: "Next Pagination Key",
controlType: "INPUT_TEXT",
},
{
id: "11.4",
propertyName: "prevPageKey",
label: "Previous Pagination Key",
controlType: "INPUT_TEXT",
},
{
id: "11.5",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
],
},
{
sectionName: "Actions",
id: "12",
children: [
{
id: "12.1",
propertyName: "tableActions",
label: "Record action",
controlType: "RECORD_ACTION_SELECTOR",
},
{
id: "12.2",
propertyName: "onRowSelected",
label: "onRowSelected",
controlType: "ACTION_SELECTOR",
},
{
id: "12.3",
propertyName: "onPageChange",
label: "onPageChange",
controlType: "ACTION_SELECTOR",
},
],
}, },
], ],
DROP_DOWN_WIDGET: [ DROP_DOWN_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "10", id: "13",
children: [], children: [
{
id: "13.1",
propertyName: "type",
label: "Selection Type",
controlType: "DROP_DOWN",
options: [
{ label: "Single Select", value: "SINGLE_SELECT" },
{ label: "Multi Select", value: "MULTI_SELECT" },
],
},
{
id: "13.2",
propertyName: "label",
label: "Label",
controlType: "INPUT_TEXT",
placeholderText: "Enter the label",
},
{
id: "13.3",
propertyName: "placeholderText",
label: "Placeholder",
controlType: "INPUT_TEXT",
placeholderText: "Enter the placeholder",
},
{
id: "13.4",
propertyName: "options",
label: "Options",
controlType: "OPTION_INPUT",
},
{
id: "13.5",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
],
},
{
sectionName: "Actions",
id: "14",
children: [
{
id: "14.1",
propertyName: "onOptionSelected",
label: "onOptionSelected",
controlType: "ACTION_SELECTOR",
},
],
}, },
], ],
CHECKBOX_WIDGET: [ CHECKBOX_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "11", id: "15",
children: [], children: [
{
id: "15.1",
propertyName: "label",
label: "Label",
controlType: "INPUT_TEXT",
placeholderText: "Enter the label",
},
{
id: "15.2",
propertyName: "defaultCheckedState",
label: "Default State",
controlType: "SWITCH",
},
{
id: "13.5",
propertyName: "isDisabled",
label: "Disabled",
controlType: "SWITCH",
},
{
id: "13.5",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
},
],
},
{
sectionName: "Actions",
id: "16",
children: [
{
id: "16.1",
propertyName: "onCheckChange",
label: "onCheckChange",
controlType: "ACTION_SELECTOR",
},
],
}, },
], ],
RADIO_GROUP_WIDGET: [ RADIO_GROUP_WIDGET: [
{ {
sectionName: "General", sectionName: "General",
id: "12", id: "16",
children: [], children: [
{
id: "16.1",
propertyName: "label",
label: "Label",
controlType: "INPUT_TEXT",
placeholderText: "Enter the label",
},
{
id: "16.2",
propertyName: "defaultOptionValue",
label: "Default Selected Value",
controlType: "SWITCH",
},
{
id: "16.3",
propertyName: "options",
label: "Options",
controlType: "OPTION_INPUT",
},
{
id: "13.5",
propertyName: "isVisible",
label: "Visibile",
controlType: "SWITCH",
}, },
], ],
ALERT_WIDGET: [ },
{ {
sectionName: "General", sectionName: "Actions",
id: "13", id: "17",
children: [], children: [
{
id: "17.1",
propertyName: "onOptionSelected",
label: "onOptionSelected",
controlType: "ACTION_SELECTOR",
},
],
}, },
], ],
}, },

View File

@ -37,11 +37,7 @@ class PropertyPane extends Component<
} }
} }
renderPropertySection( renderPropertySection(propertySection: PropertySection, key: string) {
propertySection: PropertySection,
key: string,
isHorizontal?: boolean,
) {
return ( return (
<div key={key}> <div key={key}>
{!_.isNil(propertySection) ? ( {!_.isNil(propertySection) ? (
@ -51,7 +47,7 @@ class PropertyPane extends Component<
)} )}
<div <div
style={ style={
isHorizontal propertySection.orientation === "HORIZONTAL"
? { flexDirection: "row" } ? { flexDirection: "row" }
: { flexDirection: "column" } : { flexDirection: "column" }
} }
@ -63,7 +59,6 @@ class PropertyPane extends Component<
return this.renderPropertySection( return this.renderPropertySection(
propertyControlOrSection, propertyControlOrSection,
propertyControlOrSection.id, propertyControlOrSection.id,
true,
); );
} else { } else {
return PropertyControlFactory.createControl( return PropertyControlFactory.createControl(

View File

@ -2,6 +2,7 @@ import React from "react";
import BaseControl, { ControlProps } from "./BaseControl"; import BaseControl, { ControlProps } from "./BaseControl";
import { ControlType } from "../../constants/PropertyControlConstants"; import { ControlType } from "../../constants/PropertyControlConstants";
import { InputGroup } from "@blueprintjs/core"; import { InputGroup } from "@blueprintjs/core";
import { InputType } from "../../widgets/InputWidget";
class InputTextControl extends BaseControl<InputControlProps> { class InputTextControl extends BaseControl<InputControlProps> {
render() { render() {
@ -19,6 +20,8 @@ class InputTextControl extends BaseControl<InputControlProps> {
export interface InputControlProps extends ControlProps { export interface InputControlProps extends ControlProps {
placeholderText: string; placeholderText: string;
inputType: InputType;
isDisabled?: boolean;
} }
export default InputTextControl; export default InputTextControl;

View File

@ -6,17 +6,22 @@ import {
import PropertyPaneConfigResponse from "../../mockResponses/PropertyPaneConfigResponse"; import PropertyPaneConfigResponse from "../../mockResponses/PropertyPaneConfigResponse";
import { InputControlProps } from "../../pages/propertyControls/InputTextControl"; import { InputControlProps } from "../../pages/propertyControls/InputTextControl";
import { DropDownControlProps } from "../../pages/propertyControls/DropDownControl"; import { DropDownControlProps } from "../../pages/propertyControls/DropDownControl";
import { ControlProps } from "../../pages/propertyControls/BaseControl";
const initialState: PropertyPaneConfigState = PropertyPaneConfigResponse; const initialState: PropertyPaneConfigState = PropertyPaneConfigResponse;
export type ControlConfig = export type ControlConfig =
| InputControlProps | InputControlProps
| DropDownControlProps | DropDownControlProps
| InputControlProps; | InputControlProps
| ControlProps;
export type SectionOrientation = "HORIZONTAL" | "VERTICAL";
export interface PropertySection { export interface PropertySection {
id: string; id: string;
sectionName: string; sectionName?: string;
orientation?: SectionOrientation;
children: (ControlConfig | PropertySection)[]; children: (ControlConfig | PropertySection)[];
} }
@ -34,7 +39,6 @@ export interface PropertyPaneConfigState {
DROP_DOWN_WIDGET: PropertySection[]; DROP_DOWN_WIDGET: PropertySection[];
CHECKBOX_WIDGET: PropertySection[]; CHECKBOX_WIDGET: PropertySection[];
RADIO_GROUP_WIDGET: PropertySection[]; RADIO_GROUP_WIDGET: PropertySection[];
ALERT_WIDGET: PropertySection[];
}; };
configVersion: number; configVersion: number;
} }

View File

@ -3,16 +3,15 @@ import {
ReduxAction, ReduxAction,
} from "../constants/ReduxActionConstants"; } from "../constants/ReduxActionConstants";
import { call, takeEvery, select, all } from "redux-saga/effects"; import { call, takeEvery, select, all } from "redux-saga/effects";
import { import { PageAction, ActionPayload } from "../constants/ActionConstants";
APIActionPayload, import ActionAPI, {
QueryActionPayload, ActionCreateUpdateResponse,
PageAction, ExecuteActionRequest,
ActionPayload, } from "../api/ActionAPI";
} from "../constants/ActionConstants";
import ActionAPI, { ActionCreateUpdateResponse } from "../api/ActionAPI";
import { AppState } from "../reducers"; import { AppState } from "../reducers";
import { JSONPath } from "jsonpath-plus"; import { JSONPath } from "jsonpath-plus";
import _ from "lodash"; import _ from "lodash";
import { mapToPropList } from "../utils/AppsmithUtils";
const getDataTree = (state: AppState) => { const getDataTree = (state: AppState) => {
return state.entities; return state.entities;
@ -31,8 +30,12 @@ export function* evaluateJSONPathSaga(jsonPath: string): any {
return result; return result;
} }
export function* executeAPIActionSaga(apiAction: APIActionPayload) { export function* executeAPIQueryActionSaga(apiAction: ActionPayload) {
const api: PageAction = yield select(getAction, apiAction.apiId); const api: PageAction = yield select(getAction, apiAction.actionId);
const executeActionRequest: ExecuteActionRequest = {
actionId: apiAction.actionId,
};
if (!_.isNil(api.dynamicBindings)) {
const responses: any = yield all( const responses: any = yield all(
api.dynamicBindings.map((jsonPath: string) => { api.dynamicBindings.map((jsonPath: string) => {
return call(evaluateJSONPathSaga, jsonPath); return call(evaluateJSONPathSaga, jsonPath);
@ -41,42 +44,23 @@ export function* executeAPIActionSaga(apiAction: APIActionPayload) {
const dynamicBindingMap: Record<string, any> = _.keyBy( const dynamicBindingMap: Record<string, any> = _.keyBy(
responses, responses,
(response: string, index: number) => { (response: string, index: number) => {
return api.dynamicBindings[index]; return api.dynamicBindings ? api.dynamicBindings[index] : undefined;
}, },
); );
yield ActionAPI.executeAction({ executeActionRequest.dynamicBindingList = mapToPropList(dynamicBindingMap);
actionId: apiAction.apiId, }
dynamicBindingMap: dynamicBindingMap, yield ActionAPI.executeAction(executeActionRequest);
});
}
export function* executeQueryActionSaga(queryAction: QueryActionPayload) {
const query: PageAction = yield select(getAction, queryAction.queryId);
const responses: any = yield all(
query.dynamicBindings.map((jsonPath: string) => {
return call(evaluateJSONPathSaga, jsonPath);
}),
);
const dynamicBindingMap: Record<string, any> = _.keyBy(
responses,
(response: string, index: number) => {
return query.dynamicBindings[index];
},
);
yield ActionAPI.executeAction({
actionId: query.actionId,
dynamicBindingMap: dynamicBindingMap,
});
} }
export function* executeActionSaga(action: ReduxAction<ActionPayload[]>) { export function* executeActionSaga(action: ReduxAction<ActionPayload[]>) {
if (!_.isNil(action.payload)) { if (!_.isNil(action.payload)) {
yield all( yield all(
action.payload.map((actionPayload: ActionPayload) => { _.map(action.payload, (actionPayload: ActionPayload) => {
switch (actionPayload.actionType) { switch (actionPayload.actionType) {
case "API": case "API":
const apiActionPaylod: APIActionPayload = actionPayload as APIActionPayload; return call(executeAPIQueryActionSaga, actionPayload);
return call(executeAPIActionSaga, apiActionPaylod); case "QUERY":
return call(executeAPIQueryActionSaga, actionPayload);
} }
return undefined; return undefined;
}), }),

View File

@ -24,7 +24,10 @@ export function* fetchPageSaga(pageRequestAction: ReduxAction<PageRequest>) {
widgets: normalizedResponse.entities.canvasWidgets, widgets: normalizedResponse.entities.canvasWidgets,
}; };
yield all([ yield all([
put({ type: ReduxActionTypes.UPDATE_CANVAS, canvasWidgetsPayload }), put({
type: ReduxActionTypes.UPDATE_CANVAS,
payload: canvasWidgetsPayload,
}),
put({ put({
type: ReduxActionTypes.LOAD_CANVAS_ACTIONS, type: ReduxActionTypes.LOAD_CANVAS_ACTIONS,
payload: pageResponse.layout.actions, payload: pageResponse.layout.actions,

View File

@ -11,6 +11,8 @@ import netlifyIdentity from "netlify-identity-widget";
import FontFaceObserver from "fontfaceobserver"; import FontFaceObserver from "fontfaceobserver";
import PropertyControlRegistry from "./PropertyControlRegistry"; import PropertyControlRegistry from "./PropertyControlRegistry";
import WidgetBuilderRegistry from "./WidgetRegistry"; import WidgetBuilderRegistry from "./WidgetRegistry";
import { Property } from "../api/ActionAPI";
import _ from "lodash";
export const createReducer = ( export const createReducer = (
initialState: any, initialState: any,
@ -52,3 +54,9 @@ export const appInitializer = () => {
console.log(err); console.log(err);
}); });
}; };
export const mapToPropList = (map: Record<string, string>): Property[] => {
return _.map(map, (value, key) => {
return { key: key, value: value };
});
};

View File

@ -1,16 +1,12 @@
import React from "react"; import React, { Component } from "react";
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget"; import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
import { WidgetType } from "../constants/WidgetConstants"; import { WidgetType } from "../constants/WidgetConstants";
import { ActionPayload } from "../constants/ActionConstants"; import { ActionPayload } from "../constants/ActionConstants";
class AlertWidget extends BaseWidget<AlertWidgetProps, WidgetState> { class AlertWidget extends Component {
getPageView() { getPageView() {
return <div />; return <div />;
} }
getWidgetType(): WidgetType {
return "ALERT_WIDGET";
}
} }
export type AlertType = "DIALOG" | "NOTIFICATION"; export type AlertType = "DIALOG" | "NOTIFICATION";

View File

@ -38,6 +38,7 @@ export interface ButtonWidgetProps extends WidgetProps {
text?: string; text?: string;
buttonStyle?: ButtonStyle; buttonStyle?: ButtonStyle;
onClick?: ActionPayload[]; onClick?: ActionPayload[];
isDisabled?: boolean;
} }
export default ButtonWidget; export default ButtonWidget;

View File

@ -19,7 +19,7 @@ export type DatePickerType = "DATE_PICKER" | "DATE_RANGE_PICKER";
export interface DatePickerWidgetProps extends WidgetProps { export interface DatePickerWidgetProps extends WidgetProps {
defaultDate?: Date; defaultDate?: Date;
timezone?: TimeZone; defaultTimezone?: TimeZone;
enableTime: boolean; enableTime: boolean;
label: string; label: string;
datePickerType: DatePickerType; datePickerType: DatePickerType;

View File

@ -20,7 +20,7 @@ export interface DropdownOption {
} }
export interface DropdownWidgetProps extends WidgetProps { export interface DropdownWidgetProps extends WidgetProps {
placeholder?: string; placeholderText?: string;
label?: string; label?: string;
type: SelectionType; type: SelectionType;
options?: DropdownOption[]; options?: DropdownOption[];

View File

@ -22,13 +22,19 @@ export type InputType =
| "CURRENCY" | "CURRENCY"
| "SEARCH"; | "SEARCH";
export interface InputValidator {
validationRegex: string;
errorMessage: string;
}
export interface InputWidgetProps extends WidgetProps { export interface InputWidgetProps extends WidgetProps {
errorMessage?: string;
inputType: InputType; inputType: InputType;
defaultText?: string; defaultText?: string;
placeholder?: string; placeholderText?: string;
maxChars?: number;
label: string; label: string;
inputValidators: InputValidator[];
focusIndex?: number; focusIndex?: number;
isAutoFocusEnabled?: boolean;
} }
export default InputWidget; export default InputWidget;

View File

@ -15,13 +15,18 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
export type PaginationType = "PAGES" | "INFINITE_SCROLL"; export type PaginationType = "PAGES" | "INFINITE_SCROLL";
export interface TableAction extends ActionPayload {
actionName: string;
}
export interface TableWidgetProps extends WidgetProps { export interface TableWidgetProps extends WidgetProps {
pageKey?: string; nextPageKey?: string;
prevPageKey?: string;
label: string; label: string;
tableData?: object[]; tableData?: object[];
recordActions?: TableAction[];
onPageChange?: ActionPayload[]; onPageChange?: ActionPayload[];
onRowSelected?: ActionPayload[]; onRowSelected?: ActionPayload[];
onColumnActionClick?: Record<string, ActionPayload[]>;
} }
export default TableWidget; export default TableWidget;

View File

@ -11,7 +11,6 @@ class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
widgetId={this.props.widgetId} widgetId={this.props.widgetId}
key={this.props.widgetId} key={this.props.widgetId}
text={this.props.text} text={this.props.text}
tagName={this.props.tagName}
/> />
); );
} }
@ -26,7 +25,6 @@ export type TextStyle = "BODY" | "HEADING" | "LABEL" | "SUB_TEXT";
export interface TextWidgetProps extends WidgetProps { export interface TextWidgetProps extends WidgetProps {
text?: string; text?: string;
textStyle?: TextStyle; textStyle?: TextStyle;
tagName?: keyof JSX.IntrinsicElements;
} }
export default TextWidget; export default TextWidget;