2019-10-29 12:02:58 +00:00
|
|
|
import styled from "styled-components";
|
2021-08-13 11:38:26 +00:00
|
|
|
import * as Sentry from "@sentry/react";
|
2021-11-23 08:01:46 +00:00
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
|
import React, { useState, useCallback, useMemo } from "react";
|
|
|
|
|
import { Route, Switch, matchPath, useLocation } from "react-router";
|
|
|
|
|
|
2021-08-13 11:38:26 +00:00
|
|
|
import EditorsRouter from "./routes";
|
2021-09-06 09:29:35 +00:00
|
|
|
import BottomBar from "./BottomBar";
|
2021-11-23 08:01:46 +00:00
|
|
|
import {
|
|
|
|
|
DEFAULT_ENTITY_EXPLORER_WIDTH,
|
|
|
|
|
DEFAULT_PROPERTY_PANE_WIDTH,
|
|
|
|
|
} from "constants/AppConstants";
|
|
|
|
|
import WidgetsEditor from "./WidgetsEditor";
|
|
|
|
|
import { updateExplorerWidthAction } from "actions/explorerActions";
|
2021-09-13 07:22:51 +00:00
|
|
|
import { BUILDER_CHECKLIST_URL, BUILDER_URL } from "constants/routes";
|
|
|
|
|
import OnboardingChecklist from "./FirstTimeUserOnboarding/Checklist";
|
2021-11-23 08:01:46 +00:00
|
|
|
import EntityExplorerSidebar from "components/editorComponents/Sidebar";
|
|
|
|
|
import PropertyPaneSidebar from "components/editorComponents/PropertyPaneSidebar";
|
|
|
|
|
|
2020-09-24 16:05:18 +00:00
|
|
|
const SentryRoute = Sentry.withSentryRouting(Route);
|
|
|
|
|
|
2019-10-29 12:02:58 +00:00
|
|
|
const Container = styled.div`
|
|
|
|
|
display: flex;
|
2021-09-06 09:29:35 +00:00
|
|
|
height: calc(
|
|
|
|
|
100vh - ${(props) => props.theme.smallHeaderHeight} -
|
2021-10-04 08:01:46 +00:00
|
|
|
${(props) => props.theme.bottomBarHeight}
|
2021-09-06 09:29:35 +00:00
|
|
|
);
|
2021-02-08 07:30:01 +00:00
|
|
|
background-color: ${(props) => props.theme.appBackground};
|
2019-10-29 12:02:58 +00:00
|
|
|
`;
|
2021-11-23 08:01:46 +00:00
|
|
|
function MainContainer() {
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
const [sidebarWidth, setSidebarWidth] = useState(
|
|
|
|
|
DEFAULT_ENTITY_EXPLORER_WIDTH,
|
|
|
|
|
);
|
|
|
|
|
const [propertyPaneWidth, setPropertyPaneWidth] = useState(
|
|
|
|
|
DEFAULT_PROPERTY_PANE_WIDTH,
|
|
|
|
|
);
|
2019-10-29 12:02:58 +00:00
|
|
|
|
2021-11-23 08:01:46 +00:00
|
|
|
/**
|
|
|
|
|
* on entity explorer sidebar width change
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
const onLeftSidebarWidthChange = useCallback((newWidth) => {
|
|
|
|
|
setSidebarWidth(newWidth);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* on entity explorer sidebar drag end
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
const onLeftSidebarDragEnd = useCallback(() => {
|
|
|
|
|
dispatch(updateExplorerWidthAction(sidebarWidth));
|
|
|
|
|
}, [sidebarWidth]);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* on property pane sidebar drag end
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
const onRightSidebarDragEnd = useCallback(() => {
|
|
|
|
|
dispatch(updateExplorerWidthAction(propertyPaneWidth));
|
|
|
|
|
}, [propertyPaneWidth]);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* on property pane sidebar width change
|
|
|
|
|
*/
|
|
|
|
|
const onRightSidebarWidthChange = useCallback((newWidth) => {
|
|
|
|
|
setPropertyPaneWidth(newWidth);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* checks if property pane should be rendered or not
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
const shouldRenderPropertyPane = useMemo(() => {
|
|
|
|
|
const match = matchPath(location.pathname, {
|
|
|
|
|
path: BUILDER_URL,
|
|
|
|
|
exact: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// match is found, that means current URL is BUILDER_URL i.e our editor
|
|
|
|
|
if (match) return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}, [location]);
|
2019-10-29 12:02:58 +00:00
|
|
|
|
|
|
|
|
return (
|
2021-09-06 09:29:35 +00:00
|
|
|
<>
|
2021-11-23 08:01:46 +00:00
|
|
|
<Container className="w-full overflow-x-hidden">
|
|
|
|
|
<EntityExplorerSidebar
|
|
|
|
|
onDragEnd={onLeftSidebarDragEnd}
|
|
|
|
|
onWidthChange={onLeftSidebarWidthChange}
|
|
|
|
|
width={sidebarWidth}
|
|
|
|
|
/>
|
|
|
|
|
<div className="relative flex flex-col w-full overflow-auto">
|
2021-09-06 09:29:35 +00:00
|
|
|
<Switch>
|
|
|
|
|
<SentryRoute component={WidgetsEditor} exact path={BUILDER_URL} />
|
2021-09-13 07:22:51 +00:00
|
|
|
<SentryRoute
|
|
|
|
|
component={OnboardingChecklist}
|
|
|
|
|
exact
|
|
|
|
|
path={BUILDER_CHECKLIST_URL}
|
|
|
|
|
/>
|
2021-09-06 09:29:35 +00:00
|
|
|
<SentryRoute component={EditorsRouter} />
|
|
|
|
|
</Switch>
|
2021-11-23 08:01:46 +00:00
|
|
|
</div>
|
|
|
|
|
{shouldRenderPropertyPane && (
|
|
|
|
|
<PropertyPaneSidebar
|
|
|
|
|
onDragEnd={onRightSidebarDragEnd}
|
|
|
|
|
onWidthChange={onRightSidebarWidthChange}
|
|
|
|
|
width={propertyPaneWidth}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2021-09-06 09:29:35 +00:00
|
|
|
</Container>
|
2021-10-04 08:01:46 +00:00
|
|
|
<BottomBar />
|
2021-09-06 09:29:35 +00:00
|
|
|
</>
|
2019-10-29 12:02:58 +00:00
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2019-10-29 12:02:58 +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
|
|
|
MainContainer.displayName = "MainContainer";
|
|
|
|
|
|
2019-10-29 12:02:58 +00:00
|
|
|
export default MainContainer;
|