2021-10-04 15:34:37 +00:00
|
|
|
import React, { memo, useEffect, useState } from "react";
|
2019-10-18 08:16:26 +00:00
|
|
|
import styled from "styled-components";
|
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 ExplorerSidebar from "pages/Editor/Explorer";
|
2020-09-02 06:44:01 +00:00
|
|
|
import { PanelStack, Classes } from "@blueprintjs/core";
|
|
|
|
|
import { Colors } from "constants/Colors";
|
2020-09-24 04:47:37 +00:00
|
|
|
import * as Sentry from "@sentry/react";
|
2020-09-24 16:05:18 +00:00
|
|
|
import PerformanceTracker, {
|
|
|
|
|
PerformanceTransactionName,
|
|
|
|
|
} from "utils/PerformanceTracker";
|
2021-05-18 18:29:39 +00:00
|
|
|
import { Layers } from "constants/Layers";
|
2021-09-13 07:22:51 +00:00
|
|
|
import { useSelector } from "store";
|
|
|
|
|
import {
|
|
|
|
|
getFirstTimeUserOnboardingComplete,
|
|
|
|
|
getIsFirstTimeUserOnboardingEnabled,
|
|
|
|
|
} from "selectors/onboardingSelectors";
|
|
|
|
|
import OnboardingStatusbar from "pages/Editor/FirstTimeUserOnboarding/Statusbar";
|
2021-10-04 15:34:37 +00:00
|
|
|
import Switcher from "components/ads/Switcher";
|
|
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
|
import { forceOpenWidgetPanel } from "actions/widgetSidebarActions";
|
|
|
|
|
import { AppState } from "reducers";
|
|
|
|
|
import {
|
|
|
|
|
getCurrentApplicationId,
|
|
|
|
|
getCurrentPageId,
|
|
|
|
|
} from "selectors/editorSelectors";
|
|
|
|
|
import { BUILDER_PAGE_URL } from "constants/routes";
|
|
|
|
|
import history from "utils/history";
|
2021-10-18 14:03:44 +00:00
|
|
|
|
|
|
|
|
import { trimQueryString } from "utils/helpers";
|
2021-10-06 06:47:59 +00:00
|
|
|
import { toggleInOnboardingWidgetSelection } from "actions/onboardingActions";
|
2019-10-18 08:16:26 +00:00
|
|
|
|
2021-09-20 09:25:37 +00:00
|
|
|
const SidebarWrapper = styled.div<{ inOnboarding: boolean }>`
|
2021-10-04 15:34:37 +00:00
|
|
|
background-color: ${Colors.WHITE};
|
2021-01-27 11:38:21 +00:00
|
|
|
padding: 0;
|
2020-12-24 04:32:25 +00:00
|
|
|
width: ${(props) => props.theme.sidebarWidth};
|
2021-05-18 18:29:39 +00:00
|
|
|
z-index: ${Layers.sideBar};
|
2021-10-04 15:34:37 +00:00
|
|
|
box-shadow: 1px 0px 0px ${Colors.MERCURY_1};
|
|
|
|
|
color: ${(props) => props.theme.colors.textOnWhiteBG};
|
2019-11-22 14:02:55 +00:00
|
|
|
overflow-y: auto;
|
2020-09-02 06:44:01 +00:00
|
|
|
& .${Classes.PANEL_STACK} {
|
2021-09-20 09:25:37 +00:00
|
|
|
height: ${(props) =>
|
|
|
|
|
props.inOnboarding
|
2021-10-04 15:34:37 +00:00
|
|
|
? `calc(100% - ${props.theme.onboarding.statusBarHeight}px - 48px)`
|
|
|
|
|
: `calc(100% - 48px)`};
|
2020-09-02 06:44:01 +00:00
|
|
|
.${Classes.PANEL_STACK_VIEW} {
|
|
|
|
|
background: none;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-18 08:16:26 +00:00
|
|
|
`;
|
|
|
|
|
|
2021-10-04 15:34:37 +00:00
|
|
|
const SwitchWrapper = styled.div`
|
|
|
|
|
padding: 8px;
|
|
|
|
|
`;
|
|
|
|
|
|
2020-09-02 06:44:01 +00:00
|
|
|
const initialPanel = { component: ExplorerSidebar };
|
|
|
|
|
|
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
|
|
|
export const Sidebar = memo(() => {
|
2021-10-04 15:34:37 +00:00
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const applicationId = useSelector(getCurrentApplicationId);
|
|
|
|
|
const pageId = useSelector(getCurrentPageId);
|
2021-10-06 06:47:59 +00:00
|
|
|
const isFirstTimeUserOnboardingEnabled = useSelector(
|
|
|
|
|
getIsFirstTimeUserOnboardingEnabled,
|
|
|
|
|
);
|
2021-10-04 15:34:37 +00:00
|
|
|
const switches = [
|
|
|
|
|
{
|
|
|
|
|
id: "explorer",
|
|
|
|
|
text: "Explorer",
|
|
|
|
|
action: () => dispatch(forceOpenWidgetPanel(false)),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "widgets",
|
|
|
|
|
text: "Widgets",
|
|
|
|
|
action: () => {
|
|
|
|
|
!(
|
2021-10-18 14:03:44 +00:00
|
|
|
trimQueryString(
|
|
|
|
|
BUILDER_PAGE_URL({
|
|
|
|
|
applicationId,
|
|
|
|
|
pageId,
|
|
|
|
|
}),
|
|
|
|
|
) === window.location.pathname
|
|
|
|
|
) &&
|
|
|
|
|
history.push(
|
|
|
|
|
BUILDER_PAGE_URL({
|
|
|
|
|
applicationId,
|
|
|
|
|
pageId,
|
|
|
|
|
}),
|
|
|
|
|
);
|
2021-10-04 15:34:37 +00:00
|
|
|
setTimeout(() => dispatch(forceOpenWidgetPanel(true)), 0);
|
2021-10-06 06:47:59 +00:00
|
|
|
if (isFirstTimeUserOnboardingEnabled) {
|
|
|
|
|
dispatch(toggleInOnboardingWidgetSelection(true));
|
|
|
|
|
}
|
2021-10-04 15:34:37 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
const [activeSwitch, setActiveSwitch] = useState(switches[0]);
|
|
|
|
|
|
|
|
|
|
const isForceOpenWidgetPanel = useSelector(
|
|
|
|
|
(state: AppState) => state.ui.onBoarding.forceOpenWidgetPanel,
|
|
|
|
|
);
|
|
|
|
|
|
2021-09-13 07:22:51 +00:00
|
|
|
const enableFirstTimeUserOnboarding = useSelector(
|
|
|
|
|
getIsFirstTimeUserOnboardingEnabled,
|
|
|
|
|
);
|
|
|
|
|
const isFirstTimeUserOnboardingComplete = useSelector(
|
|
|
|
|
getFirstTimeUserOnboardingComplete,
|
|
|
|
|
);
|
2020-09-24 16:05:18 +00:00
|
|
|
PerformanceTracker.startTracking(PerformanceTransactionName.SIDE_BAR_MOUNT);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
PerformanceTracker.stopTracking();
|
|
|
|
|
});
|
2021-10-04 15:34:37 +00:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (isForceOpenWidgetPanel) {
|
|
|
|
|
setActiveSwitch(switches[1]);
|
|
|
|
|
} else {
|
|
|
|
|
setActiveSwitch(switches[0]);
|
|
|
|
|
}
|
|
|
|
|
}, [isForceOpenWidgetPanel]);
|
|
|
|
|
|
2019-11-22 14:02:55 +00:00
|
|
|
return (
|
2021-09-20 09:25:37 +00:00
|
|
|
<SidebarWrapper
|
|
|
|
|
className="t--sidebar"
|
|
|
|
|
inOnboarding={
|
|
|
|
|
enableFirstTimeUserOnboarding || isFirstTimeUserOnboardingComplete
|
|
|
|
|
}
|
|
|
|
|
>
|
2021-09-13 07:22:51 +00:00
|
|
|
{(enableFirstTimeUserOnboarding || isFirstTimeUserOnboardingComplete) && (
|
|
|
|
|
<OnboardingStatusbar />
|
|
|
|
|
)}
|
2021-10-04 15:34:37 +00:00
|
|
|
<SwitchWrapper>
|
|
|
|
|
<Switcher activeObj={activeSwitch} switches={switches} />
|
|
|
|
|
</SwitchWrapper>
|
2020-09-02 06:44:01 +00:00
|
|
|
<PanelStack initialPanel={initialPanel} showPanelHeader={false} />
|
2019-11-22 14:02:55 +00:00
|
|
|
</SidebarWrapper>
|
|
|
|
|
);
|
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
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Sidebar.displayName = "Sidebar";
|
2019-10-18 08:16:26 +00:00
|
|
|
|
2020-09-24 04:47:37 +00:00
|
|
|
export default Sentry.withProfiler(Sidebar);
|