Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
import React, { useEffect, ReactNode } from "react";
|
2020-03-11 13:59:46 +00:00
|
|
|
import { Switch, withRouter, RouteComponentProps } from "react-router-dom";
|
2019-11-25 09:15:11 +00:00
|
|
|
import ApiEditor from "./APIEditor";
|
2020-05-05 07:50:30 +00:00
|
|
|
import QueryEditor from "./QueryEditor";
|
2020-04-28 06:52:53 +00:00
|
|
|
import DataSourceEditor from "./DataSourceEditor";
|
|
|
|
|
|
2020-04-14 12:34:14 +00:00
|
|
|
import CurlImportForm from "./APIEditor/CurlImportForm";
|
|
|
|
|
import ProviderTemplates from "./APIEditor/ProviderTemplates";
|
2019-10-21 15:12:45 +00:00
|
|
|
import {
|
|
|
|
|
API_EDITOR_ID_URL,
|
|
|
|
|
API_EDITOR_URL,
|
2020-05-05 07:50:30 +00:00
|
|
|
QUERIES_EDITOR_URL,
|
|
|
|
|
QUERIES_EDITOR_ID_URL,
|
2020-04-28 06:52:53 +00:00
|
|
|
DATA_SOURCES_EDITOR_URL,
|
|
|
|
|
DATA_SOURCES_EDITOR_ID_URL,
|
2019-11-22 14:02:55 +00:00
|
|
|
BUILDER_BASE_URL,
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
BUILDER_PAGE_URL,
|
2019-11-22 14:02:55 +00:00
|
|
|
BuilderRouteParams,
|
|
|
|
|
APIEditorRouteParams,
|
2020-04-14 12:34:14 +00:00
|
|
|
getCurlImportPageURL,
|
|
|
|
|
API_EDITOR_URL_WITH_SELECTED_PAGE_ID,
|
|
|
|
|
getProviderTemplatesURL,
|
2019-11-25 05:07:27 +00:00
|
|
|
} from "constants/routes";
|
2019-10-18 08:16:26 +00:00
|
|
|
import styled from "styled-components";
|
2020-03-11 13:59:46 +00:00
|
|
|
import AppRoute from "pages/common/AppRoute";
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
import {
|
|
|
|
|
useShowPropertyPane,
|
|
|
|
|
useWidgetSelection,
|
|
|
|
|
} from "utils/hooks/dragResizeHooks";
|
|
|
|
|
import { closeAllModals } from "actions/widgetActions";
|
|
|
|
|
import { useDispatch } from "react-redux";
|
2019-10-18 08:16:26 +00:00
|
|
|
|
2020-01-27 08:24:58 +00:00
|
|
|
const Wrapper = styled.div<{ isVisible: boolean; showOnlySidebar?: boolean }>`
|
2019-10-18 08:16:26 +00:00
|
|
|
position: absolute;
|
2019-12-11 10:35:07 +00:00
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
2020-01-27 08:24:58 +00:00
|
|
|
width: ${props => (props.showOnlySidebar ? "0px" : "100%")};
|
2019-10-18 08:16:26 +00:00
|
|
|
height: calc(100vh - ${props => props.theme.headerHeight});
|
2019-10-29 12:02:58 +00:00
|
|
|
background-color: ${props =>
|
|
|
|
|
props.isVisible ? "rgba(0, 0, 0, 0.26)" : "transparent"};
|
2020-01-27 11:39:27 +00:00
|
|
|
z-index: ${props => (props.isVisible ? 2 : -1)};
|
2019-10-29 12:02:58 +00:00
|
|
|
`;
|
|
|
|
|
|
2020-01-27 08:24:58 +00:00
|
|
|
const DrawerWrapper = styled.div<{
|
|
|
|
|
isVisible: boolean;
|
|
|
|
|
showOnlySidebar?: boolean;
|
|
|
|
|
}>`
|
2019-10-29 12:02:58 +00:00
|
|
|
background-color: white;
|
2020-01-27 08:24:58 +00:00
|
|
|
width: ${props => (props.showOnlySidebar ? "0px" : "75%")};
|
2019-10-29 12:02:58 +00:00
|
|
|
height: 100%;
|
2019-10-18 08:16:26 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
interface RouterState {
|
2019-10-29 12:02:58 +00:00
|
|
|
isVisible: boolean;
|
2020-01-27 08:24:58 +00:00
|
|
|
showOnlySidebar: boolean;
|
2019-10-18 08:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-22 14:02:55 +00:00
|
|
|
class EditorsRouter extends React.Component<
|
|
|
|
|
RouteComponentProps<BuilderRouteParams>,
|
|
|
|
|
RouterState
|
|
|
|
|
> {
|
|
|
|
|
constructor(props: RouteComponentProps<APIEditorRouteParams>) {
|
2019-10-18 08:16:26 +00:00
|
|
|
super(props);
|
2019-11-22 14:02:55 +00:00
|
|
|
const { applicationId, pageId } = this.props.match.params;
|
2019-10-18 08:16:26 +00:00
|
|
|
this.state = {
|
2019-11-22 14:02:55 +00:00
|
|
|
isVisible:
|
|
|
|
|
this.props.location.pathname !== BUILDER_BASE_URL(applicationId) &&
|
|
|
|
|
this.props.location.pathname !==
|
|
|
|
|
BUILDER_PAGE_URL(applicationId, pageId),
|
2020-01-27 08:24:58 +00:00
|
|
|
showOnlySidebar:
|
2020-04-28 06:52:53 +00:00
|
|
|
// TODO: Please optimise this
|
|
|
|
|
!(
|
|
|
|
|
this.props.location.pathname.indexOf(
|
|
|
|
|
DATA_SOURCES_EDITOR_URL(applicationId, pageId),
|
|
|
|
|
) !== -1 ||
|
|
|
|
|
this.props.location.pathname.indexOf(
|
|
|
|
|
API_EDITOR_URL(applicationId, pageId),
|
2020-05-05 07:50:30 +00:00
|
|
|
) !== -1 ||
|
|
|
|
|
this.props.location.pathname.indexOf(
|
|
|
|
|
QUERIES_EDITOR_URL(applicationId, pageId),
|
2020-04-28 06:52:53 +00:00
|
|
|
) !== -1
|
|
|
|
|
),
|
2019-10-18 08:16:26 +00:00
|
|
|
};
|
|
|
|
|
}
|
2020-01-27 08:24:58 +00:00
|
|
|
|
2019-10-18 08:16:26 +00:00
|
|
|
componentDidUpdate(prevProps: Readonly<RouteComponentProps>): void {
|
|
|
|
|
if (this.props.location.pathname !== prevProps.location.pathname) {
|
2019-11-22 14:02:55 +00:00
|
|
|
const { applicationId, pageId } = this.props.match.params;
|
2019-10-18 08:16:26 +00:00
|
|
|
this.setState({
|
2019-11-22 14:02:55 +00:00
|
|
|
isVisible:
|
|
|
|
|
this.props.location.pathname !== BUILDER_BASE_URL(applicationId) &&
|
|
|
|
|
this.props.location.pathname !==
|
|
|
|
|
BUILDER_PAGE_URL(applicationId, pageId),
|
2020-01-27 08:24:58 +00:00
|
|
|
showOnlySidebar:
|
2020-04-28 06:52:53 +00:00
|
|
|
// TODO: Please optimise this
|
|
|
|
|
!(
|
|
|
|
|
this.props.location.pathname.indexOf(
|
|
|
|
|
DATA_SOURCES_EDITOR_URL(applicationId, pageId),
|
|
|
|
|
) !== -1 ||
|
|
|
|
|
this.props.location.pathname.indexOf(
|
|
|
|
|
API_EDITOR_URL(applicationId, pageId),
|
2020-05-05 07:50:30 +00:00
|
|
|
) !== -1 ||
|
|
|
|
|
this.props.location.pathname.indexOf(
|
|
|
|
|
QUERIES_EDITOR_URL(applicationId, pageId),
|
2020-04-28 06:52:53 +00:00
|
|
|
) !== -1
|
|
|
|
|
),
|
2019-10-18 08:16:26 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-29 12:02:58 +00:00
|
|
|
handleClose = (e: React.MouseEvent) => {
|
|
|
|
|
e.stopPropagation();
|
2019-11-22 14:02:55 +00:00
|
|
|
const { applicationId, pageId } = this.props.match.params;
|
2019-10-29 12:02:58 +00:00
|
|
|
this.setState({
|
|
|
|
|
isVisible: false,
|
|
|
|
|
});
|
2019-11-22 14:02:55 +00:00
|
|
|
this.props.history.replace(BUILDER_PAGE_URL(applicationId, pageId));
|
2019-10-29 12:02:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
preventClose = (e: React.MouseEvent) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-18 08:16:26 +00:00
|
|
|
render(): React.ReactNode {
|
|
|
|
|
return (
|
2020-01-27 08:24:58 +00:00
|
|
|
<Wrapper
|
|
|
|
|
isVisible={this.state.isVisible}
|
|
|
|
|
onClick={
|
|
|
|
|
!this.state.showOnlySidebar ? this.handleClose : this.preventClose
|
|
|
|
|
}
|
|
|
|
|
showOnlySidebar={this.state.showOnlySidebar}
|
|
|
|
|
>
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
<PaneDrawer
|
2019-10-29 12:02:58 +00:00
|
|
|
isVisible={this.state.isVisible}
|
2020-01-27 08:24:58 +00:00
|
|
|
showOnlySidebar={this.state.showOnlySidebar}
|
2019-10-29 12:02:58 +00:00
|
|
|
onClick={this.preventClose}
|
2019-10-18 08:16:26 +00:00
|
|
|
>
|
|
|
|
|
<Switch>
|
2020-03-11 13:59:46 +00:00
|
|
|
<AppRoute
|
|
|
|
|
exact
|
|
|
|
|
path={API_EDITOR_URL()}
|
|
|
|
|
component={ApiEditor}
|
|
|
|
|
name={"ApiEditor"}
|
|
|
|
|
/>
|
|
|
|
|
<AppRoute
|
|
|
|
|
exact
|
|
|
|
|
path={API_EDITOR_ID_URL()}
|
|
|
|
|
component={ApiEditor}
|
|
|
|
|
name={"ApiEditor"}
|
|
|
|
|
/>
|
2020-04-14 12:34:14 +00:00
|
|
|
<AppRoute
|
|
|
|
|
exact
|
|
|
|
|
path={API_EDITOR_URL_WITH_SELECTED_PAGE_ID()}
|
|
|
|
|
component={ApiEditor}
|
|
|
|
|
name={"ApiEditor"}
|
|
|
|
|
/>
|
2020-05-05 07:50:30 +00:00
|
|
|
<AppRoute
|
|
|
|
|
exact
|
|
|
|
|
path={QUERIES_EDITOR_URL()}
|
|
|
|
|
component={QueryEditor}
|
|
|
|
|
name={"QueryEditor"}
|
|
|
|
|
/>
|
|
|
|
|
<AppRoute
|
|
|
|
|
exact
|
|
|
|
|
path={QUERIES_EDITOR_ID_URL()}
|
|
|
|
|
component={QueryEditor}
|
|
|
|
|
name={"QueryEditor"}
|
|
|
|
|
/>
|
|
|
|
|
|
2020-04-14 12:34:14 +00:00
|
|
|
<AppRoute
|
|
|
|
|
exact
|
|
|
|
|
path={getCurlImportPageURL()}
|
|
|
|
|
component={CurlImportForm}
|
|
|
|
|
name={"ApiEditor"}
|
|
|
|
|
/>
|
2020-04-28 06:52:53 +00:00
|
|
|
<AppRoute
|
|
|
|
|
exact
|
|
|
|
|
path={DATA_SOURCES_EDITOR_URL()}
|
|
|
|
|
component={DataSourceEditor}
|
|
|
|
|
name={"DataSourceEditor"}
|
|
|
|
|
/>
|
|
|
|
|
<AppRoute
|
|
|
|
|
exact
|
|
|
|
|
path={DATA_SOURCES_EDITOR_ID_URL()}
|
|
|
|
|
component={DataSourceEditor}
|
|
|
|
|
name={"DataSourceEditor"}
|
|
|
|
|
/>
|
2020-04-14 12:34:14 +00:00
|
|
|
<AppRoute
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
exact
|
2020-04-14 12:34:14 +00:00
|
|
|
path={getProviderTemplatesURL()}
|
|
|
|
|
component={ProviderTemplates}
|
|
|
|
|
name={"ApiEditor"}
|
|
|
|
|
/>
|
2019-10-18 08:16:26 +00:00
|
|
|
</Switch>
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
</PaneDrawer>
|
2019-10-29 12:02:58 +00:00
|
|
|
</Wrapper>
|
2019-10-18 08:16:26 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
type PaneDrawerProps = {
|
|
|
|
|
isVisible: boolean;
|
|
|
|
|
showOnlySidebar: boolean;
|
|
|
|
|
onClick: (e: React.MouseEvent) => void;
|
|
|
|
|
children: ReactNode;
|
|
|
|
|
};
|
|
|
|
|
const PaneDrawer = (props: PaneDrawerProps) => {
|
|
|
|
|
const showPropertyPane = useShowPropertyPane();
|
|
|
|
|
const { selectWidget, focusWidget } = 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";
|
2019-10-18 08:16:26 +00:00
|
|
|
|
|
|
|
|
export default withRouter(EditorsRouter);
|