2020-09-02 06:44:01 +00:00
|
|
|
import React, { useRef, useEffect, useState } from "react";
|
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 { useSelector } from "react-redux";
|
2019-10-18 08:16:26 +00:00
|
|
|
import WidgetCard from "./WidgetCard";
|
|
|
|
|
import styled from "styled-components";
|
2019-11-25 05:07:27 +00:00
|
|
|
import { WidgetCardProps } from "widgets/BaseWidget";
|
2021-02-11 06:36:07 +00:00
|
|
|
import {
|
|
|
|
|
getCurrentApplicationId,
|
|
|
|
|
getCurrentPageId,
|
|
|
|
|
getWidgetCards,
|
|
|
|
|
} from "selectors/editorSelectors";
|
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 { getColorWithOpacity } from "constants/DefaultTheme";
|
2020-09-02 06:44:01 +00:00
|
|
|
import { IPanelProps, Icon, Classes } from "@blueprintjs/core";
|
|
|
|
|
import { Colors } from "constants/Colors";
|
|
|
|
|
import ExplorerSearch from "./Explorer/ExplorerSearch";
|
|
|
|
|
import { debounce } from "lodash";
|
|
|
|
|
import produce from "immer";
|
2021-03-13 14:24:45 +00:00
|
|
|
import { createMessage, WIDGET_SIDEBAR_CAPTION } from "constants/messages";
|
2020-12-30 07:31:20 +00:00
|
|
|
import Boxed from "components/editorComponents/Onboarding/Boxed";
|
|
|
|
|
import { OnboardingStep } from "constants/OnboardingConstants";
|
2021-02-11 06:36:07 +00:00
|
|
|
import { getCurrentStep, getCurrentSubStep } from "sagas/OnboardingSagas";
|
|
|
|
|
import { BUILDER_PAGE_URL } from "constants/routes";
|
|
|
|
|
import OnboardingIndicator from "components/editorComponents/Onboarding/Indicator";
|
2019-10-18 08:16:26 +00:00
|
|
|
|
|
|
|
|
const MainWrapper = styled.div`
|
|
|
|
|
text-transform: capitalize;
|
2021-02-11 06:36:07 +00:00
|
|
|
padding: 10px 10px 20px 10px;
|
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
|
|
|
height: 100%;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
2020-12-24 04:32:25 +00:00
|
|
|
scrollbar-color: ${(props) => props.theme.colors.paneCard}
|
|
|
|
|
${(props) => props.theme.colors.paneBG};
|
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
|
|
|
scrollbar-width: thin;
|
|
|
|
|
&::-webkit-scrollbar {
|
|
|
|
|
width: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&::-webkit-scrollbar-track {
|
|
|
|
|
box-shadow: inset 0 0 6px
|
2020-12-24 04:32:25 +00:00
|
|
|
${(props) => getColorWithOpacity(props.theme.colors.paneBG, 0.3)};
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&::-webkit-scrollbar-thumb {
|
2020-12-24 04:32:25 +00:00
|
|
|
background-color: ${(props) => props.theme.colors.paneCard};
|
|
|
|
|
outline: 1px solid ${(props) => props.theme.paneText};
|
|
|
|
|
border-radius: ${(props) => props.theme.radii[1]}px;
|
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
|
|
|
}
|
2019-10-18 08:16:26 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const CardsWrapper = styled.div`
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: 1fr 1fr 1fr;
|
2020-12-24 04:32:25 +00:00
|
|
|
grid-gap: ${(props) => props.theme.spaces[1]}px;
|
2019-10-18 08:16:26 +00:00
|
|
|
justify-items: stretch;
|
|
|
|
|
align-items: stretch;
|
|
|
|
|
`;
|
|
|
|
|
|
2020-09-02 06:44:01 +00:00
|
|
|
const CloseIcon = styled(Icon)`
|
|
|
|
|
&&.${Classes.ICON} {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
opacity: 0.6;
|
|
|
|
|
&:hover {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const Header = styled.div`
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: 7fr 1fr;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const Info = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: space-around;
|
|
|
|
|
text-transform: none;
|
|
|
|
|
h4 {
|
|
|
|
|
margin-top: 0px;
|
|
|
|
|
}
|
|
|
|
|
p {
|
|
|
|
|
opacity: 0.6;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
function WidgetSidebar(props: IPanelProps) {
|
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
|
|
|
const cards = useSelector(getWidgetCards);
|
2020-09-02 06:44:01 +00:00
|
|
|
const [filteredCards, setFilteredCards] = useState(cards);
|
|
|
|
|
const searchInputRef = useRef<HTMLInputElement | null>(null);
|
2020-09-03 14:22:08 +00:00
|
|
|
const filterCards = (keyword: string) => {
|
2020-09-02 06:44:01 +00:00
|
|
|
let filteredCards = cards;
|
|
|
|
|
if (keyword.trim().length > 0) {
|
2020-12-24 04:32:25 +00:00
|
|
|
filteredCards = produce(cards, (draft) => {
|
2020-12-23 11:32:30 +00:00
|
|
|
cards.forEach((card, index) => {
|
|
|
|
|
if (card.widgetCardName.toLowerCase().indexOf(keyword) === -1) {
|
|
|
|
|
delete draft[index];
|
2020-09-02 06:44:01 +00:00
|
|
|
}
|
2020-12-23 11:32:30 +00:00
|
|
|
});
|
2020-09-02 06:44:01 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
setFilteredCards(filteredCards);
|
2020-09-03 14:22:08 +00:00
|
|
|
};
|
|
|
|
|
const clearSearchInput = () => {
|
|
|
|
|
if (searchInputRef.current) {
|
|
|
|
|
searchInputRef.current.value = "";
|
|
|
|
|
}
|
|
|
|
|
filterCards("");
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-11 06:36:07 +00:00
|
|
|
// For onboarding
|
|
|
|
|
const currentStep = useSelector(getCurrentStep);
|
|
|
|
|
const currentSubStep = useSelector(getCurrentSubStep);
|
|
|
|
|
const applicationId = useSelector(getCurrentApplicationId);
|
|
|
|
|
const pageId = useSelector(getCurrentPageId);
|
|
|
|
|
const onCanvas =
|
|
|
|
|
BUILDER_PAGE_URL(applicationId, pageId) === window.location.pathname;
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (currentStep === OnboardingStep.DEPLOY && !onCanvas) {
|
|
|
|
|
props.closePanel();
|
|
|
|
|
}
|
|
|
|
|
}, [currentStep, onCanvas]);
|
|
|
|
|
|
2020-09-03 14:22:08 +00:00
|
|
|
const search = debounce((e: any) => {
|
|
|
|
|
filterCards(e.target.value.toLowerCase());
|
2020-09-02 06:44:01 +00:00
|
|
|
}, 300);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const el: HTMLInputElement | null = searchInputRef.current;
|
|
|
|
|
|
|
|
|
|
el?.addEventListener("keydown", search);
|
|
|
|
|
el?.addEventListener("cleared", search);
|
|
|
|
|
return () => {
|
|
|
|
|
el?.removeEventListener("keydown", search);
|
|
|
|
|
el?.removeEventListener("cleared", search);
|
|
|
|
|
};
|
|
|
|
|
}, [searchInputRef, search]);
|
2021-02-11 06:36:07 +00:00
|
|
|
|
|
|
|
|
const showTableWidget = currentStep >= OnboardingStep.RUN_QUERY_SUCCESS;
|
|
|
|
|
const showInputWidget = currentStep >= OnboardingStep.ADD_INPUT_WIDGET;
|
|
|
|
|
|
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
|
|
|
return (
|
2020-09-02 06:44:01 +00:00
|
|
|
<>
|
2021-02-11 06:36:07 +00:00
|
|
|
<Boxed step={OnboardingStep.DEPLOY}>
|
|
|
|
|
<ExplorerSearch
|
2021-04-28 10:28:39 +00:00
|
|
|
autoFocus
|
2021-02-11 06:36:07 +00:00
|
|
|
clear={clearSearchInput}
|
|
|
|
|
placeholder="Search widgets..."
|
2021-04-28 10:28:39 +00:00
|
|
|
ref={searchInputRef}
|
2021-02-11 06:36:07 +00:00
|
|
|
/>
|
|
|
|
|
</Boxed>
|
2020-09-02 06:44:01 +00:00
|
|
|
|
|
|
|
|
<MainWrapper>
|
|
|
|
|
<Header>
|
|
|
|
|
<Info>
|
2021-03-13 14:24:45 +00:00
|
|
|
<p>{createMessage(WIDGET_SIDEBAR_CAPTION)}</p>
|
2020-09-02 06:44:01 +00:00
|
|
|
</Info>
|
|
|
|
|
<CloseIcon
|
|
|
|
|
className="t--close-widgets-sidebar"
|
2021-04-28 10:28:39 +00:00
|
|
|
color={Colors.WHITE}
|
2020-09-02 06:44:01 +00:00
|
|
|
icon="cross"
|
|
|
|
|
iconSize={16}
|
|
|
|
|
onClick={props.closePanel}
|
|
|
|
|
/>
|
|
|
|
|
</Header>
|
2020-12-23 11:32:30 +00:00
|
|
|
<CardsWrapper>
|
|
|
|
|
{filteredCards.map((card: WidgetCardProps) => (
|
2020-12-30 07:31:20 +00:00
|
|
|
<Boxed
|
2021-04-28 10:28:39 +00:00
|
|
|
key={card.key}
|
2021-02-11 06:36:07 +00:00
|
|
|
show={
|
|
|
|
|
(card.type === "TABLE_WIDGET" && showTableWidget) ||
|
|
|
|
|
(card.type === "INPUT_WIDGET" && showInputWidget)
|
|
|
|
|
}
|
2021-04-28 10:28:39 +00:00
|
|
|
step={OnboardingStep.DEPLOY}
|
2020-12-30 07:31:20 +00:00
|
|
|
>
|
2021-02-11 06:36:07 +00:00
|
|
|
<OnboardingIndicator
|
2021-02-15 05:14:42 +00:00
|
|
|
className="onboarding-widget-menu"
|
2021-04-28 10:28:39 +00:00
|
|
|
hasButton={false}
|
2021-02-11 06:36:07 +00:00
|
|
|
show={
|
|
|
|
|
(card.type === "TABLE_WIDGET" &&
|
|
|
|
|
currentStep === OnboardingStep.RUN_QUERY_SUCCESS) ||
|
|
|
|
|
(card.type === "INPUT_WIDGET" &&
|
|
|
|
|
currentSubStep === 0 &&
|
|
|
|
|
currentStep === OnboardingStep.ADD_INPUT_WIDGET)
|
|
|
|
|
}
|
2021-04-28 10:28:39 +00:00
|
|
|
step={
|
|
|
|
|
OnboardingStep.RUN_QUERY_SUCCESS ||
|
|
|
|
|
OnboardingStep.ADD_INPUT_WIDGET
|
|
|
|
|
}
|
|
|
|
|
width={100}
|
2021-02-11 06:36:07 +00:00
|
|
|
>
|
|
|
|
|
<WidgetCard details={card} />
|
|
|
|
|
</OnboardingIndicator>
|
2020-12-30 07:31:20 +00:00
|
|
|
</Boxed>
|
2020-12-23 11:32:30 +00:00
|
|
|
))}
|
|
|
|
|
</CardsWrapper>
|
2020-09-02 06:44:01 +00:00
|
|
|
</MainWrapper>
|
|
|
|
|
</>
|
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
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
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
|
|
|
WidgetSidebar.displayName = "WidgetSidebar";
|
|
|
|
|
|
|
|
|
|
export default WidgetSidebar;
|