* Changes to add js plugin * routes+reducer+create template * added debugger to js editor page * entity explorer changes * create js function * added copy, move and delete action * added js plugin * added existing js functions to data tree * removed actionconfig for js collection * new js function added to data tree and entity as well * parsing flow added * changes to data tree * parse and update js functions * small changes for def creator for js action * create delete modified * small changes for update * update flow change * entity properties added * removed linting errors * small changes in entity explorer * changes for update * move, copy implementation * conflict resolved * changes for dependecy map creation * Only make the variables the binding paths * Basic eval sync working * Minor fixes * removed unwanted code * entity props and autocomplete * saving in progress show * redirection fix after delete js action * removed unnecessary line * Fixing merge conflict * added sample body * removed dummy data and added plugin Type * few PR comments fixed * automplete fix * few more PR comments fix * PR commnets fix * move and copy api change * js colleciton name refactor & 'move to page' changes & search * view changes * autocomplete added for js collections * removing till async is implemented * small changes * separate js pane response view * Executing functions * js collection to js objects * entity explorer issue and resolve action on page switch * removed unused line * small color fix * js file icon added * added js action to property pane * Property pane changes for actions * property pane changes for js functions * showing syntax error for now * actions sorted in response tab * added js objects to slash and recent entitties * enabling this to be used inside of function * eval fix * feature flag changes for entity explorer and property pane * debugger changes * copy bug fix * small changes for eval * debugger bug fix * chnaged any to specific types * error in console fix * icons update * fixed test case * test case fix * non empty check for functions * evaluate test case fix * added new icons * text change * updated time for debounce for trial * after release mereg * changed icon * after merge * PR comments simple * fixed PR comments - redux form, settings remove * js object interface changes * name refactor * export default change * delete resolve actions chnage * after merge * adding execute fn as 3rd option and removed create new js function * issue 7054 fixed - app crash * execute function on response tab changes * refactor function name part 1 * refactor of js function name * try catch added refactor * test fix * not used line removed * test cases locator fixed Co-authored-by: Nidhi <nidhi.nair93@gmail.com> Co-authored-by: hetunandu <hetu@appsmith.com>
236 lines
6.6 KiB
TypeScript
236 lines
6.6 KiB
TypeScript
import React, { useEffect, ReactNode } from "react";
|
|
import {
|
|
Switch,
|
|
withRouter,
|
|
RouteComponentProps,
|
|
Route,
|
|
matchPath,
|
|
} from "react-router-dom";
|
|
import ApiEditor from "./APIEditor";
|
|
import IntegrationEditor from "./IntegrationEditor";
|
|
import QueryEditor from "./QueryEditor";
|
|
import DataSourceEditor from "./DataSourceEditor";
|
|
import JSEditor from "./JSEditor";
|
|
|
|
import GeneratePage from "./GeneratePage";
|
|
import CurlImportForm from "./APIEditor/CurlImportForm";
|
|
import ProviderTemplates from "./APIEditor/ProviderTemplates";
|
|
import {
|
|
API_EDITOR_ID_URL,
|
|
QUERIES_EDITOR_ID_URL,
|
|
DATA_SOURCES_EDITOR_ID_URL,
|
|
BUILDER_PAGE_URL,
|
|
BuilderRouteParams,
|
|
APIEditorRouteParams,
|
|
getCurlImportPageURL,
|
|
PAGE_LIST_EDITOR_URL,
|
|
INTEGRATION_EDITOR_URL,
|
|
JS_COLLECTION_EDITOR_URL,
|
|
JS_COLLECTION_ID_URL,
|
|
getGenerateTemplateURL,
|
|
getProviderTemplatesURL,
|
|
getGenerateTemplateFormURL,
|
|
} from "constants/routes";
|
|
import styled from "styled-components";
|
|
import { useShowPropertyPane } from "utils/hooks/dragResizeHooks";
|
|
import { closeAllModals } from "actions/widgetActions";
|
|
import { useDispatch } from "react-redux";
|
|
import PerformanceTracker, {
|
|
PerformanceTransactionName,
|
|
} from "utils/PerformanceTracker";
|
|
|
|
import * as Sentry from "@sentry/react";
|
|
const SentryRoute = Sentry.withSentryRouting(Route);
|
|
|
|
import { SaaSEditorRoutes } from "./SaaSEditor/routes";
|
|
import { useWidgetSelection } from "utils/hooks/useWidgetSelection";
|
|
import PagesEditor from "./PagesEditor";
|
|
|
|
const Wrapper = styled.div<{ isVisible: boolean }>`
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: ${(props) => (!props.isVisible ? "0px" : "100%")};
|
|
height: 100%;
|
|
background-color: ${(props) =>
|
|
props.isVisible ? "rgba(0, 0, 0, 0.26)" : "transparent"};
|
|
z-index: ${(props) => (props.isVisible ? 2 : -1)};
|
|
`;
|
|
|
|
const DrawerWrapper = styled.div<{
|
|
isVisible: boolean;
|
|
isActionPath: any;
|
|
}>`
|
|
background-color: white;
|
|
width: ${(props) => (!props.isVisible ? "0" : "100%")};
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
`;
|
|
|
|
interface RouterState {
|
|
isVisible: boolean;
|
|
isActionPath: Record<any, any> | null;
|
|
}
|
|
|
|
class EditorsRouter extends React.Component<
|
|
RouteComponentProps<BuilderRouteParams>,
|
|
RouterState
|
|
> {
|
|
constructor(props: RouteComponentProps<APIEditorRouteParams>) {
|
|
super(props);
|
|
const { applicationId, pageId } = this.props.match.params;
|
|
this.state = {
|
|
isVisible:
|
|
this.props.location.pathname !==
|
|
BUILDER_PAGE_URL(applicationId, pageId),
|
|
isActionPath: this.isMatchPath(),
|
|
};
|
|
}
|
|
|
|
componentDidUpdate(prevProps: Readonly<RouteComponentProps>): void {
|
|
if (this.props.location.pathname !== prevProps.location.pathname) {
|
|
const { applicationId, pageId } = this.props.match.params;
|
|
this.setState({
|
|
isVisible:
|
|
this.props.location.pathname !==
|
|
BUILDER_PAGE_URL(applicationId, pageId),
|
|
isActionPath: this.isMatchPath(),
|
|
});
|
|
}
|
|
}
|
|
|
|
isMatchPath = () => {
|
|
return matchPath(this.props.location.pathname, {
|
|
path: [
|
|
INTEGRATION_EDITOR_URL(),
|
|
API_EDITOR_ID_URL(),
|
|
QUERIES_EDITOR_ID_URL(),
|
|
],
|
|
exact: true,
|
|
strict: false,
|
|
});
|
|
};
|
|
|
|
handleClose = (e: React.MouseEvent) => {
|
|
PerformanceTracker.startTracking(
|
|
PerformanceTransactionName.CLOSE_SIDE_PANE,
|
|
{ path: this.props.location.pathname },
|
|
);
|
|
e.stopPropagation();
|
|
const { applicationId, pageId } = this.props.match.params;
|
|
this.setState({
|
|
isVisible: false,
|
|
});
|
|
this.props.history.replace(BUILDER_PAGE_URL(applicationId, pageId));
|
|
};
|
|
|
|
preventClose = (e: React.MouseEvent) => {
|
|
e.stopPropagation();
|
|
};
|
|
|
|
render(): React.ReactNode {
|
|
return (
|
|
<Wrapper isVisible={this.state.isVisible} onClick={this.handleClose}>
|
|
<PaneDrawer
|
|
isActionPath={this.state.isActionPath}
|
|
isVisible={this.state.isVisible}
|
|
onClick={this.preventClose}
|
|
>
|
|
<Switch>
|
|
<SentryRoute
|
|
component={IntegrationEditor}
|
|
exact
|
|
path={INTEGRATION_EDITOR_URL()}
|
|
/>
|
|
<SentryRoute
|
|
component={ApiEditor}
|
|
exact
|
|
path={API_EDITOR_ID_URL()}
|
|
/>
|
|
<SentryRoute
|
|
component={QueryEditor}
|
|
exact
|
|
path={QUERIES_EDITOR_ID_URL()}
|
|
/>
|
|
|
|
<SentryRoute
|
|
component={JSEditor}
|
|
exact
|
|
path={JS_COLLECTION_EDITOR_URL()}
|
|
/>
|
|
<SentryRoute
|
|
component={JSEditor}
|
|
exact
|
|
path={JS_COLLECTION_ID_URL()}
|
|
/>
|
|
|
|
<SentryRoute
|
|
component={CurlImportForm}
|
|
exact
|
|
path={getCurlImportPageURL()}
|
|
/>
|
|
{SaaSEditorRoutes.map((props) => (
|
|
<SentryRoute exact key={props.path} {...props} />
|
|
))}
|
|
<SentryRoute
|
|
component={PagesEditor}
|
|
exact
|
|
path={PAGE_LIST_EDITOR_URL()}
|
|
/>
|
|
<SentryRoute
|
|
component={DataSourceEditor}
|
|
exact
|
|
path={DATA_SOURCES_EDITOR_ID_URL()}
|
|
/>
|
|
<SentryRoute
|
|
component={ProviderTemplates}
|
|
exact
|
|
path={getProviderTemplatesURL()}
|
|
/>
|
|
<SentryRoute
|
|
component={GeneratePage}
|
|
exact
|
|
path={getGenerateTemplateURL()}
|
|
/>
|
|
<SentryRoute
|
|
component={GeneratePage}
|
|
exact
|
|
path={getGenerateTemplateFormURL()}
|
|
/>
|
|
</Switch>
|
|
</PaneDrawer>
|
|
</Wrapper>
|
|
);
|
|
}
|
|
}
|
|
type PaneDrawerProps = {
|
|
isVisible: boolean;
|
|
isActionPath: Record<any, any> | null;
|
|
onClick: (e: React.MouseEvent) => void;
|
|
children: ReactNode;
|
|
};
|
|
function PaneDrawer(props: PaneDrawerProps) {
|
|
const showPropertyPane = useShowPropertyPane();
|
|
const { focusWidget, selectWidget } = useWidgetSelection();
|
|
const dispatch = useDispatch();
|
|
useEffect(() => {
|
|
// This pane drawer is only open when NOT on canvas.
|
|
// De-select all widgets
|
|
// Un-focus all widgets
|
|
// Hide property pane
|
|
// Close all modals
|
|
if (props.isVisible) {
|
|
showPropertyPane();
|
|
selectWidget(undefined);
|
|
focusWidget(undefined);
|
|
dispatch(closeAllModals());
|
|
}
|
|
}, [dispatch, props.isVisible, selectWidget, showPropertyPane, focusWidget]);
|
|
return <DrawerWrapper {...props}>{props.children}</DrawerWrapper>;
|
|
}
|
|
|
|
PaneDrawer.displayName = "PaneDrawer";
|
|
|
|
export default withRouter(EditorsRouter);
|