Revert "Merge branch 'feature/server-side-pagination' into 'release'"
This reverts merge request !271
This commit is contained in:
parent
60726a69b5
commit
6987b392d7
|
|
@ -1,9 +1,9 @@
|
|||
import { RestAction, PaginationField } from "api/ActionAPI";
|
||||
import {
|
||||
ReduxActionTypes,
|
||||
ReduxAction,
|
||||
ReduxActionErrorTypes,
|
||||
} from "constants/ReduxActionConstants";
|
||||
import { RestAction } from "api/ActionAPI";
|
||||
|
||||
export const createActionRequest = (payload: Partial<RestAction>) => {
|
||||
return {
|
||||
|
|
@ -32,13 +32,10 @@ export const fetchActions = (
|
|||
};
|
||||
};
|
||||
|
||||
export const runApiAction = (id: string, paginationField?: PaginationField) => {
|
||||
export const runApiAction = (id: string) => {
|
||||
return {
|
||||
type: ReduxActionTypes.RUN_API_REQUEST,
|
||||
payload: {
|
||||
id: id,
|
||||
paginationField: paginationField,
|
||||
},
|
||||
payload: id,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ import {
|
|||
ReduxAction,
|
||||
ReduxActionErrorTypes,
|
||||
} from "constants/ReduxActionConstants";
|
||||
import { PaginationField } from "api/ActionAPI";
|
||||
|
||||
import {
|
||||
ActionPayload,
|
||||
ExecuteErrorPayload,
|
||||
|
|
@ -13,17 +11,10 @@ import {
|
|||
|
||||
export const executeAction = (
|
||||
actionPayloads: ActionPayload[],
|
||||
paginationField?: PaginationField,
|
||||
): ReduxAction<{
|
||||
actions: ActionPayload[];
|
||||
paginationField: PaginationField;
|
||||
}> => {
|
||||
): ReduxAction<ActionPayload[]> => {
|
||||
return {
|
||||
type: ReduxActionTypes.EXECUTE_ACTION,
|
||||
payload: {
|
||||
actions: actionPayloads,
|
||||
paginationField: paginationField,
|
||||
},
|
||||
payload: actionPayloads,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ export interface APIConfigRequest {
|
|||
path: string;
|
||||
body: JSON | string | Record<string, any> | null;
|
||||
queryParameters: Property[];
|
||||
isPaginated: boolean;
|
||||
}
|
||||
|
||||
export interface QueryConfig {
|
||||
|
|
@ -61,12 +60,9 @@ export interface RestAction {
|
|||
cacheResponse?: string;
|
||||
}
|
||||
|
||||
export type PaginationField = "PREV" | "NEXT" | undefined;
|
||||
|
||||
export interface ExecuteActionRequest extends APIRequest {
|
||||
action: Pick<RestAction, "id"> | Omit<RestAction, "id">;
|
||||
params?: Property[];
|
||||
paginationField: PaginationField;
|
||||
}
|
||||
|
||||
export interface ExecuteActionResponse extends ApiResponse {
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
import React from "react";
|
||||
import { Icon, IconName } from "@blueprintjs/core";
|
||||
import styled from "styled-components";
|
||||
|
||||
const PagerContainer = styled.div<{
|
||||
visible: boolean;
|
||||
}>`
|
||||
&&&&& {
|
||||
height: 49px;
|
||||
display: ${props => (props.visible ? "flex" : "none")};
|
||||
}
|
||||
`;
|
||||
function PagerIcon(props: { icon: IconName; onClick: Function }) {
|
||||
return (
|
||||
<Icon
|
||||
className={"e-next e-icons e-icon-next e-nextpage"}
|
||||
style={{
|
||||
padding: 14,
|
||||
marginTop: 5,
|
||||
}}
|
||||
icon={props.icon}
|
||||
iconSize={14}
|
||||
onClick={props.onClick as any}
|
||||
></Icon>
|
||||
);
|
||||
}
|
||||
interface PagerProps {
|
||||
pageNo: number;
|
||||
prevPageClick: Function;
|
||||
nextPageClick: Function;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
const PageWrapper = styled.div`
|
||||
&&&&& {
|
||||
width: 140px;
|
||||
display: flex;
|
||||
margin: 0 auto;
|
||||
}
|
||||
`;
|
||||
|
||||
export function TablePagination(props: PagerProps) {
|
||||
return (
|
||||
<PagerContainer
|
||||
className={"e-control e-pager e-lib"}
|
||||
visible={props.visible}
|
||||
>
|
||||
<PageWrapper>
|
||||
<PagerIcon
|
||||
icon={"chevron-left"}
|
||||
onClick={props.prevPageClick}
|
||||
></PagerIcon>
|
||||
<div
|
||||
className={"e-numericcontainer"}
|
||||
style={{
|
||||
marginTop: 12,
|
||||
marginLeft: 6,
|
||||
}}
|
||||
>
|
||||
<a
|
||||
className={"e-link e-numericitem e-spacing e-currentitem e-active"}
|
||||
>
|
||||
{props.pageNo}
|
||||
</a>
|
||||
</div>
|
||||
<PagerIcon
|
||||
icon={"chevron-right"}
|
||||
onClick={props.nextPageClick}
|
||||
></PagerIcon>
|
||||
</PageWrapper>
|
||||
</PagerContainer>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import React, { FormEvent } from "react";
|
||||
import React from "react";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
Checkbox as BlueprintCheckbox,
|
||||
|
|
@ -13,12 +13,6 @@ import {
|
|||
export type CheckboxProps = ICheckboxProps & {
|
||||
intent: Intent;
|
||||
align: "left" | "right";
|
||||
input?: {
|
||||
onChange?: (value: boolean) => void;
|
||||
value?: boolean;
|
||||
checked?: boolean;
|
||||
};
|
||||
label: string;
|
||||
};
|
||||
|
||||
export const StyledCheckbox = styled(BlueprintCheckbox)<CheckboxProps>`
|
||||
|
|
@ -41,20 +35,7 @@ export const StyledCheckbox = styled(BlueprintCheckbox)<CheckboxProps>`
|
|||
`;
|
||||
|
||||
export const Checkbox = (props: CheckboxProps) => {
|
||||
const handleChange = (e: any) => {
|
||||
props.input &&
|
||||
props.input.onChange &&
|
||||
props.input.onChange(e.target.checked);
|
||||
};
|
||||
return (
|
||||
<StyledCheckbox
|
||||
{...props}
|
||||
alignIndicator={props.align}
|
||||
onChange={handleChange}
|
||||
checked={props.input ? !!props.input.checked : false}
|
||||
label={props.label}
|
||||
/>
|
||||
);
|
||||
return <StyledCheckbox {...props} alignIndicator={props.align} />;
|
||||
};
|
||||
|
||||
export default Checkbox;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import styled from "constants/DefaultTheme";
|
|||
import { ColumnAction } from "components/propertyControls/ColumnActionSelectorControl";
|
||||
import { ActionPayload } from "constants/ActionConstants";
|
||||
import { Classes } from "@blueprintjs/core";
|
||||
import { TablePagination } from "../appsmith/TablePagination";
|
||||
|
||||
export interface TableComponentProps {
|
||||
data: object[];
|
||||
|
|
@ -33,28 +32,13 @@ export interface TableComponentProps {
|
|||
columnActions?: ColumnAction[];
|
||||
onCommandClick: (actions: ActionPayload[]) => void;
|
||||
disableDrag: (disable: boolean) => void;
|
||||
nextPageClick: Function;
|
||||
prevPageClick: Function;
|
||||
pageNo: number;
|
||||
serverSidePaginationEnabled: boolean;
|
||||
}
|
||||
|
||||
const StyledGridComponent = styled(GridComponent)`
|
||||
&&& {
|
||||
height: calc(100% - 49px);
|
||||
.e-altrow {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
.e-gridcontent {
|
||||
height: calc(100% - 50px);
|
||||
overflow: auto;
|
||||
}
|
||||
.e-altrow {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
`;
|
||||
|
||||
const TableContainer = styled.div`
|
||||
height: 100%;
|
||||
`;
|
||||
const settings: SelectionSettingsModel = {
|
||||
type: "Multiple",
|
||||
};
|
||||
|
|
@ -180,15 +164,15 @@ const TableComponent = memo(
|
|||
}
|
||||
|
||||
return (
|
||||
<TableContainer className={props.isLoading ? Classes.SKELETON : ""}>
|
||||
<div className={props.isLoading ? Classes.SKELETON : ""}>
|
||||
<StyledGridComponent
|
||||
selectionSettings={settings}
|
||||
dataSource={props.data}
|
||||
rowSelected={rowSelected}
|
||||
ref={grid}
|
||||
width={"100%"}
|
||||
allowPaging={!props.serverSidePaginationEnabled}
|
||||
height={"100%"}
|
||||
allowPaging={true}
|
||||
allowReordering={true}
|
||||
allowResizing={true}
|
||||
showColumnMenu={true}
|
||||
|
|
@ -196,6 +180,7 @@ const TableComponent = memo(
|
|||
columnDrop={columnDrop}
|
||||
commandClick={onCommandClick}
|
||||
columnMenuOpen={columnMenuOpen}
|
||||
// queryCellInfo={customizeCell}
|
||||
>
|
||||
<Inject
|
||||
services={[Resize, Page, Reorder, ColumnMenu, CommandColumn]}
|
||||
|
|
@ -215,13 +200,7 @@ const TableComponent = memo(
|
|||
)}
|
||||
</ColumnsDirective>
|
||||
</StyledGridComponent>
|
||||
<TablePagination
|
||||
visible={props.serverSidePaginationEnabled}
|
||||
pageNo={props.pageNo}
|
||||
prevPageClick={props.prevPageClick}
|
||||
nextPageClick={props.nextPageClick}
|
||||
></TablePagination>
|
||||
</TableContainer>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
(prevProps, nextProps) => {
|
||||
|
|
@ -230,9 +209,7 @@ const TableComponent = memo(
|
|||
JSON.stringify(nextProps.data) !== JSON.stringify(prevProps.data) ||
|
||||
nextProps.height !== prevProps.height ||
|
||||
JSON.stringify(nextProps.columnActions) !==
|
||||
JSON.stringify(prevProps.columnActions) ||
|
||||
nextProps.serverSidePaginationEnabled !==
|
||||
prevProps.serverSidePaginationEnabled;
|
||||
JSON.stringify(prevProps.columnActions);
|
||||
|
||||
return !propsNotEqual;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { getActionResponses } from "selectors/entitiesSelector";
|
|||
|
||||
const ResponseWrapper = styled.div`
|
||||
position: relative;
|
||||
flex: 1;
|
||||
flex: 4;
|
||||
height: 100%;
|
||||
overflow-y: scroll;
|
||||
`;
|
||||
|
|
|
|||
|
|
@ -13,17 +13,10 @@ import { ActionPayload } from "constants/ActionConstants";
|
|||
import { RenderModes } from "constants/WidgetConstants";
|
||||
import { OccupiedSpace } from "constants/editorConstants";
|
||||
|
||||
import {
|
||||
getOccupiedSpaces,
|
||||
getPaginatedWidgets,
|
||||
} from "selectors/editorSelectors";
|
||||
import { PaginationField, RestAction } from "api/ActionAPI";
|
||||
import { getOccupiedSpaces } from "selectors/editorSelectors";
|
||||
|
||||
export type EditorContextType = {
|
||||
executeAction?: (
|
||||
actionPayloads: ActionPayload[],
|
||||
paginationField?: PaginationField,
|
||||
) => void;
|
||||
executeAction?: (actionPayloads: ActionPayload[]) => void;
|
||||
updateWidget?: (
|
||||
operation: WidgetOperation,
|
||||
widgetId: string,
|
||||
|
|
@ -36,7 +29,6 @@ export type EditorContextType = {
|
|||
) => void;
|
||||
disableDrag?: (disable: boolean) => void;
|
||||
occupiedSpaces?: { [containerWidgetId: string]: OccupiedSpace[] };
|
||||
paginatedWidgets?: string[];
|
||||
};
|
||||
export const EditorContext: Context<EditorContextType> = createContext({});
|
||||
|
||||
|
|
@ -50,7 +42,6 @@ const EditorContextProvider = (props: EditorContextProviderProps) => {
|
|||
updateWidget,
|
||||
updateWidgetProperty,
|
||||
occupiedSpaces,
|
||||
paginatedWidgets,
|
||||
disableDrag,
|
||||
children,
|
||||
} = props;
|
||||
|
|
@ -61,7 +52,6 @@ const EditorContextProvider = (props: EditorContextProviderProps) => {
|
|||
updateWidget,
|
||||
updateWidgetProperty,
|
||||
occupiedSpaces,
|
||||
paginatedWidgets,
|
||||
disableDrag,
|
||||
}}
|
||||
>
|
||||
|
|
@ -72,10 +62,6 @@ const EditorContextProvider = (props: EditorContextProviderProps) => {
|
|||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
paginatedWidgets: getPaginatedWidgets(
|
||||
state.entities.actions.map(action => action.config),
|
||||
state.entities.canvasWidgets,
|
||||
),
|
||||
occupiedSpaces: getOccupiedSpaces(state),
|
||||
};
|
||||
};
|
||||
|
|
@ -95,10 +81,8 @@ const mapDispatchToProps = (dispatch: any) => {
|
|||
RenderModes.CANVAS,
|
||||
),
|
||||
),
|
||||
executeAction: (
|
||||
actionPayloads: ActionPayload[],
|
||||
paginationField?: PaginationField,
|
||||
) => dispatch(executeAction(actionPayloads, paginationField)),
|
||||
executeAction: (actionPayloads: ActionPayload[]) =>
|
||||
dispatch(executeAction(actionPayloads)),
|
||||
updateWidget: (
|
||||
operation: WidgetOperation,
|
||||
widgetId: string,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,8 @@ import { Field, BaseFieldProps } from "redux-form";
|
|||
import Checkbox, {
|
||||
CheckboxProps,
|
||||
} from "components/designSystems/blueprint/Checkbox";
|
||||
|
||||
export const CheckboxField = (props: BaseFieldProps & CheckboxProps) => {
|
||||
return (
|
||||
<Field type="checkbox" component={Checkbox} name={props.name} {...props} />
|
||||
);
|
||||
return <Field type="checkbox" component={Checkbox} {...props} />;
|
||||
};
|
||||
|
||||
export default CheckboxField;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,3 @@ div.bp3-popover-arrow {
|
|||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.display-none {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -27,7 +27,6 @@ import { RenderModes } from "constants/WidgetConstants";
|
|||
import { EditorContext } from "components/editorComponents/EditorContextProvider";
|
||||
import AppViewerPageContainer from "./AppViewerPageContainer";
|
||||
import AppViewerSideNavWrapper from "./viewer/AppViewerSideNavWrapper";
|
||||
import { PaginationField } from "api/ActionAPI";
|
||||
|
||||
const AppViewWrapper = styled.div`
|
||||
margin-top: ${props => props.theme.headerHeight};
|
||||
|
|
@ -114,10 +113,8 @@ const mapStateToProps = (state: AppState) => ({
|
|||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => ({
|
||||
executeAction: (
|
||||
actionPayloads: ActionPayload[],
|
||||
paginationField?: PaginationField,
|
||||
) => dispatch(executeAction(actionPayloads, paginationField)),
|
||||
executeAction: (actionPayloads: ActionPayload[]) =>
|
||||
dispatch(executeAction(actionPayloads)),
|
||||
updateWidgetProperty: (
|
||||
widgetId: string,
|
||||
propertyName: string,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import styled from "styled-components";
|
|||
import FormLabel from "components/editorComponents/FormLabel";
|
||||
import FormRow from "components/editorComponents/FormRow";
|
||||
import { BaseButton } from "components/designSystems/blueprint/ButtonComponent";
|
||||
import { RestAction, PaginationField } from "api/ActionAPI";
|
||||
import { RestAction } from "api/ActionAPI";
|
||||
import TextField from "components/editorComponents/form/fields/TextField";
|
||||
import DynamicTextField from "components/editorComponents/form/fields/DynamicTextField";
|
||||
import DropdownField from "components/editorComponents/form/fields/DropdownField";
|
||||
|
|
@ -15,8 +15,6 @@ import ApiResponseView from "components/editorComponents/ApiResponseView";
|
|||
import { API_EDITOR_FORM_NAME } from "constants/forms";
|
||||
import LoadingOverlayScreen from "components/editorComponents/LoadingOverlayScreen";
|
||||
import { FormIcons } from "icons/FormIcons";
|
||||
import { BaseTabbedView } from "components/designSystems/appsmith/TabbedView";
|
||||
import Pagination from "./Pagination";
|
||||
|
||||
const Form = styled.form`
|
||||
display: flex;
|
||||
|
|
@ -77,18 +75,13 @@ const DatasourceWrapper = styled.div`
|
|||
max-width: 320px;
|
||||
`;
|
||||
|
||||
const TabbedViewContainer = styled.div`
|
||||
flex: 1;
|
||||
padding-top: 12px;
|
||||
`;
|
||||
|
||||
interface APIFormProps {
|
||||
pluginId: string;
|
||||
allowSave: boolean;
|
||||
allowPostBody: boolean;
|
||||
onSubmit: FormSubmitHandler<RestAction>;
|
||||
onSaveClick: () => void;
|
||||
onRunClick: (paginationField?: PaginationField) => void;
|
||||
onRunClick: () => void;
|
||||
onDeleteClick: () => void;
|
||||
isSaving: boolean;
|
||||
isRunning: boolean;
|
||||
|
|
@ -130,9 +123,7 @@ const ApiEditorForm: React.FC<Props> = (props: Props) => {
|
|||
<ActionButton
|
||||
text="Run"
|
||||
accent="secondary"
|
||||
onClick={() => {
|
||||
onRunClick();
|
||||
}}
|
||||
onClick={onRunClick}
|
||||
loading={isRunning}
|
||||
/>
|
||||
<ActionButton
|
||||
|
|
@ -162,49 +153,29 @@ const ApiEditorForm: React.FC<Props> = (props: Props) => {
|
|||
</FormRow>
|
||||
</MainConfiguration>
|
||||
<SecondaryWrapper>
|
||||
<TabbedViewContainer>
|
||||
<BaseTabbedView
|
||||
tabs={[
|
||||
{
|
||||
key: "apiInput",
|
||||
title: "API Input",
|
||||
panelComponent: (
|
||||
<RequestParamsWrapper>
|
||||
<KeyValueFieldArray
|
||||
name="actionConfiguration.headers"
|
||||
label="Headers"
|
||||
/>
|
||||
<KeyValueFieldArray
|
||||
name="actionConfiguration.queryParameters"
|
||||
label="Params"
|
||||
/>
|
||||
{allowPostBody && (
|
||||
<React.Fragment>
|
||||
<FormLabel>{"Post Body"}</FormLabel>
|
||||
<JSONEditorFieldWrapper>
|
||||
<DynamicTextField
|
||||
name="actionConfiguration.body"
|
||||
height={300}
|
||||
showLineNumbers
|
||||
allowTabIndent
|
||||
/>
|
||||
</JSONEditorFieldWrapper>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</RequestParamsWrapper>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "pagination",
|
||||
title: "Pagination",
|
||||
panelComponent: (
|
||||
<Pagination onTestClick={props.onRunClick}></Pagination>
|
||||
),
|
||||
},
|
||||
]}
|
||||
></BaseTabbedView>
|
||||
</TabbedViewContainer>
|
||||
|
||||
<RequestParamsWrapper>
|
||||
<KeyValueFieldArray
|
||||
name="actionConfiguration.headers"
|
||||
label="Headers"
|
||||
/>
|
||||
<KeyValueFieldArray
|
||||
name="actionConfiguration.queryParameters"
|
||||
label="Params"
|
||||
/>
|
||||
{allowPostBody && (
|
||||
<React.Fragment>
|
||||
<FormLabel>{"Post Body"}</FormLabel>
|
||||
<JSONEditorFieldWrapper>
|
||||
<DynamicTextField
|
||||
name="actionConfiguration.body"
|
||||
height={300}
|
||||
showLineNumbers
|
||||
allowTabIndent
|
||||
/>
|
||||
</JSONEditorFieldWrapper>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</RequestParamsWrapper>
|
||||
<ApiResponseView />
|
||||
</SecondaryWrapper>
|
||||
</Form>
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
import React from "react";
|
||||
import DynamicTextField from "components/editorComponents/form/fields/DynamicTextField";
|
||||
import { Button } from "@blueprintjs/core";
|
||||
import styled from "constants/DefaultTheme";
|
||||
import CheckboxField from "components/editorComponents/form/fields/CheckboxField";
|
||||
interface PaginationProps {
|
||||
onTestClick: Function;
|
||||
}
|
||||
const PaginationFieldWrapper = styled.div`
|
||||
display: flex;
|
||||
`;
|
||||
export default function Pagination(props: PaginationProps) {
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<CheckboxField
|
||||
name="actionConfiguration.isPaginated"
|
||||
intent={"primary"}
|
||||
align={"left"}
|
||||
label={"Is Paginated?"}
|
||||
></CheckboxField>
|
||||
</div>
|
||||
<label>Previous url</label>
|
||||
<PaginationFieldWrapper>
|
||||
<DynamicTextField name="actionConfiguration.prev" />
|
||||
<Button
|
||||
onClick={() => {
|
||||
props.onTestClick("PREV");
|
||||
}}
|
||||
text={"Test"}
|
||||
rightIcon={"play"}
|
||||
></Button>
|
||||
</PaginationFieldWrapper>
|
||||
<label>Next url</label>
|
||||
<PaginationFieldWrapper>
|
||||
<DynamicTextField name="actionConfiguration.next" />
|
||||
<Button
|
||||
onClick={() => {
|
||||
props.onTestClick("NEXT");
|
||||
}}
|
||||
text={"Test"}
|
||||
rightIcon={"play"}
|
||||
></Button>
|
||||
</PaginationFieldWrapper>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
deleteAction,
|
||||
updateAction,
|
||||
} from "actions/actionActions";
|
||||
import { RestAction, PaginationField } from "api/ActionAPI";
|
||||
import { RestAction } from "api/ActionAPI";
|
||||
import { AppState } from "reducers";
|
||||
import { RouteComponentProps } from "react-router";
|
||||
import { API_EDITOR_FORM_NAME } from "constants/forms";
|
||||
|
|
@ -28,7 +28,7 @@ interface ReduxStateProps {
|
|||
interface ReduxActionProps {
|
||||
submitForm: (name: string) => void;
|
||||
createAction: (values: RestAction) => void;
|
||||
runAction: (id: string, paginationField: PaginationField) => void;
|
||||
runAction: (id: string) => void;
|
||||
deleteAction: (id: string) => void;
|
||||
updateAction: (data: RestAction) => void;
|
||||
}
|
||||
|
|
@ -57,8 +57,8 @@ class ApiEditor extends React.Component<Props> {
|
|||
handleDeleteClick = () => {
|
||||
this.props.deleteAction(this.props.match.params.apiId);
|
||||
};
|
||||
handleRunClick = (paginationField?: PaginationField) => {
|
||||
this.props.runAction(this.props.match.params.apiId, paginationField);
|
||||
handleRunClick = () => {
|
||||
this.props.runAction(this.props.match.params.apiId);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
@ -112,8 +112,7 @@ const mapStateToProps = (state: AppState): ReduxStateProps => ({
|
|||
const mapDispatchToProps = (dispatch: any): ReduxActionProps => ({
|
||||
submitForm: (name: string) => dispatch(submit(name)),
|
||||
createAction: (action: RestAction) => dispatch(createActionRequest(action)),
|
||||
runAction: (id: string, paginationField: PaginationField) =>
|
||||
dispatch(runApiAction(id, paginationField)),
|
||||
runAction: (id: string) => dispatch(runApiAction(id)),
|
||||
deleteAction: (id: string) => dispatch(deleteAction({ id })),
|
||||
updateAction: (data: RestAction) => dispatch(updateAction({ data })),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import ActionAPI, {
|
|||
ExecuteActionRequest,
|
||||
Property,
|
||||
RestAction,
|
||||
PaginationField,
|
||||
} from "api/ActionAPI";
|
||||
import { AppState } from "reducers";
|
||||
import _ from "lodash";
|
||||
|
|
@ -125,10 +124,7 @@ function* executeJSActionSaga(jsAction: ExecuteJSActionPayload) {
|
|||
});
|
||||
}
|
||||
|
||||
export function* executeAPIQueryActionSaga(
|
||||
apiAction: ActionPayload,
|
||||
paginationField: PaginationField,
|
||||
) {
|
||||
export function* executeAPIQueryActionSaga(apiAction: ActionPayload) {
|
||||
try {
|
||||
const api: PageAction = yield select(getAction, apiAction.actionId);
|
||||
if (!api) {
|
||||
|
|
@ -144,7 +140,6 @@ export function* executeAPIQueryActionSaga(
|
|||
const executeActionRequest: ExecuteActionRequest = {
|
||||
action: { id: apiAction.actionId },
|
||||
params,
|
||||
paginationField: paginationField,
|
||||
};
|
||||
const response: ActionApiResponse = yield ActionAPI.executeAction(
|
||||
executeActionRequest,
|
||||
|
|
@ -207,10 +202,7 @@ function validateActionPayload(actionPayload: ActionPayload) {
|
|||
return validation;
|
||||
}
|
||||
|
||||
export function* executeActionSaga(
|
||||
actionPayloads: ActionPayload[],
|
||||
paginationField: PaginationField,
|
||||
): any {
|
||||
export function* executeActionSaga(actionPayloads: ActionPayload[]): any {
|
||||
yield all(
|
||||
_.map(actionPayloads, (actionPayload: ActionPayload) => {
|
||||
const actionValidation = validateActionPayload(actionPayload);
|
||||
|
|
@ -221,17 +213,9 @@ export function* executeActionSaga(
|
|||
|
||||
switch (actionPayload.actionType) {
|
||||
case "API":
|
||||
return call(
|
||||
executeAPIQueryActionSaga,
|
||||
actionPayload,
|
||||
paginationField,
|
||||
);
|
||||
return call(executeAPIQueryActionSaga, actionPayload);
|
||||
case "QUERY":
|
||||
return call(
|
||||
executeAPIQueryActionSaga,
|
||||
actionPayload,
|
||||
paginationField,
|
||||
);
|
||||
return call(executeAPIQueryActionSaga, actionPayload);
|
||||
case "JS_FUNCTION":
|
||||
return call(
|
||||
executeJSActionSaga,
|
||||
|
|
@ -244,17 +228,9 @@ export function* executeActionSaga(
|
|||
);
|
||||
}
|
||||
|
||||
export function* executeReduxActionSaga(
|
||||
action: ReduxAction<{
|
||||
actions: ActionPayload[];
|
||||
paginationField: PaginationField;
|
||||
}>,
|
||||
) {
|
||||
export function* executeReduxActionSaga(action: ReduxAction<ActionPayload[]>) {
|
||||
if (!_.isNil(action.payload)) {
|
||||
yield* executeActionSaga(
|
||||
action.payload.actions,
|
||||
action.payload.paginationField,
|
||||
);
|
||||
yield* executeActionSaga(action.payload);
|
||||
} else {
|
||||
yield put(
|
||||
executeActionError({
|
||||
|
|
@ -355,22 +331,16 @@ export function* deleteActionSaga(actionPayload: ReduxAction<{ id: string }>) {
|
|||
}
|
||||
}
|
||||
|
||||
export function* runApiActionSaga(
|
||||
reduxAction: ReduxAction<{
|
||||
id: string;
|
||||
paginationField: PaginationField;
|
||||
}>,
|
||||
) {
|
||||
export function* runApiActionSaga(action: ReduxAction<string>) {
|
||||
try {
|
||||
const {
|
||||
values,
|
||||
dirty,
|
||||
valid,
|
||||
}: {
|
||||
values: RestAction;
|
||||
dirty: boolean;
|
||||
valid: boolean;
|
||||
} = yield select(getFormData, API_EDITOR_FORM_NAME);
|
||||
}: { values: RestAction; dirty: boolean; valid: boolean } = yield select(
|
||||
getFormData,
|
||||
API_EDITOR_FORM_NAME,
|
||||
);
|
||||
const actionObject: PageAction = yield select(getAction, values.id);
|
||||
let action: ExecuteActionRequest["action"] = { id: values.id };
|
||||
let jsonPathKeys = actionObject.jsonPathKeys;
|
||||
|
|
@ -379,8 +349,7 @@ export function* runApiActionSaga(
|
|||
return;
|
||||
}
|
||||
if (dirty) {
|
||||
action = _.omit(transformRestAction(values), "id") as RestAction;
|
||||
|
||||
action = _.omit(transformRestAction(values), "id");
|
||||
const actionString = JSON.stringify(action);
|
||||
if (isDynamicValue(actionString)) {
|
||||
const { paths } = getDynamicBindings(actionString);
|
||||
|
|
@ -390,13 +359,10 @@ export function* runApiActionSaga(
|
|||
jsonPathKeys = [];
|
||||
}
|
||||
}
|
||||
const { paginationField } = reduxAction.payload;
|
||||
|
||||
const params = yield call(getActionParams, jsonPathKeys);
|
||||
const response: ActionApiResponse = yield ActionAPI.executeAction({
|
||||
action,
|
||||
params,
|
||||
paginationField,
|
||||
});
|
||||
let payload = createActionResponse(response);
|
||||
if (response.responseMeta && response.responseMeta.error) {
|
||||
|
|
@ -410,7 +376,7 @@ export function* runApiActionSaga(
|
|||
} catch (error) {
|
||||
yield put({
|
||||
type: ReduxActionErrorTypes.RUN_API_ERROR,
|
||||
payload: { error, id: reduxAction.payload },
|
||||
payload: { error, id: action.payload },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import { OccupiedSpace } from "constants/editorConstants";
|
|||
import { WidgetTypes } from "constants/WidgetConstants";
|
||||
import { getParsedDataTree } from "./nameBindingsWithDataSelector";
|
||||
import _ from "lodash";
|
||||
import { RestAction } from "api/ActionAPI";
|
||||
|
||||
const getEditorState = (state: AppState) => state.ui.editor;
|
||||
const getWidgetConfigs = (state: AppState) => state.entities.widgetConfig;
|
||||
|
|
@ -172,29 +171,6 @@ const getOccupiedSpacesForContainer = (
|
|||
});
|
||||
};
|
||||
|
||||
export const getPaginatedWidgets = (
|
||||
actions: RestAction[],
|
||||
widgets: Record<string, FlattenedWidgetProps>,
|
||||
): string[] => {
|
||||
const paginatedActions = actions.filter(
|
||||
action => action.actionConfiguration.isPaginated,
|
||||
);
|
||||
const paginatedWidgets: string[] = [];
|
||||
Object.keys(widgets).forEach((key: string) => {
|
||||
const widget = widgets[key];
|
||||
if (widget.dynamicBindings) {
|
||||
Object.keys(widget.dynamicBindings).forEach(db => {
|
||||
paginatedActions.forEach(pApi => {
|
||||
if (widget[db].indexOf(pApi.name) !== -1) {
|
||||
paginatedWidgets.push(widget.widgetId);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
return paginatedWidgets;
|
||||
};
|
||||
|
||||
export const getOccupiedSpaces = createSelector(
|
||||
getWidgets,
|
||||
(
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import { PositionTypes } from "constants/WidgetConstants";
|
|||
import ErrorBoundary from "components/editorComponents/ErrorBoundry";
|
||||
import { WidgetPropertyValidationType } from "utils/ValidationFactory";
|
||||
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
||||
import { PaginationField } from "api/ActionAPI";
|
||||
/***
|
||||
* BaseWidget
|
||||
*
|
||||
|
|
@ -83,14 +82,9 @@ abstract class BaseWidget<
|
|||
* Widgets can execute actions using this `executeAction` method.
|
||||
* Triggers may be specific to the widget
|
||||
*/
|
||||
executeAction(
|
||||
actionPayloads?: ActionPayload[],
|
||||
paginationField?: PaginationField,
|
||||
): void {
|
||||
executeAction(actionPayloads?: ActionPayload[]): void {
|
||||
const { executeAction } = this.context;
|
||||
executeAction &&
|
||||
!_.isNil(actionPayloads) &&
|
||||
executeAction(actionPayloads, paginationField);
|
||||
executeAction && !_.isNil(actionPayloads) && executeAction(actionPayloads);
|
||||
}
|
||||
|
||||
disableDrag(disable: boolean) {
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
|
|||
getPageView() {
|
||||
const { tableData } = this.props;
|
||||
const columns = constructColumns(tableData);
|
||||
|
||||
const serverSidePaginationEnabled = this.context.paginatedWidgets.includes(
|
||||
this.props.widgetId,
|
||||
);
|
||||
return (
|
||||
<TableComponent
|
||||
data={this.props.tableData}
|
||||
|
|
@ -67,18 +63,22 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
|
|||
|
||||
super.executeAction(onRowSelected);
|
||||
}}
|
||||
serverSidePaginationEnabled={serverSidePaginationEnabled}
|
||||
pageNo={1}
|
||||
nextPageClick={() => {
|
||||
super.executeAction(this.props.onPageChange, "NEXT");
|
||||
}}
|
||||
prevPageClick={() => {
|
||||
super.executeAction(this.props.onPageChange, "PREV");
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// componentDidUpdate(prevProps: TableWidgetProps) {
|
||||
// super.componentDidUpdate(prevProps);
|
||||
// if (
|
||||
// !_.isEqual(prevProps.tableData, this.props.tableData) &&
|
||||
// prevProps.selectedRow
|
||||
// ) {
|
||||
// this.updateSelectedRowProperty(
|
||||
// this.props.tableData[prevProps.selectedRow.rowIndex],
|
||||
// prevProps.selectedRow.rowIndex,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
onCommandClick = (actions: ActionPayload[]) => {
|
||||
super.executeAction(actions);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user