2021-08-12 05:45:38 +00:00
|
|
|
import React from "react";
|
2019-11-25 05:07:27 +00:00
|
|
|
import { WidgetCardProps } from "widgets/BaseWidget";
|
2019-09-09 10:30:22 +00:00
|
|
|
import styled from "styled-components";
|
2021-06-17 13:26:54 +00:00
|
|
|
import { useWidgetDragResize } from "utils/hooks/dragResizeHooks";
|
2020-03-03 07:02:53 +00:00
|
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
2020-03-27 09:02:11 +00:00
|
|
|
import { generateReactKey } from "utils/generators";
|
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 { Colors } from "constants/Colors";
|
2021-06-17 13:26:54 +00:00
|
|
|
import { useWidgetSelection } from "utils/hooks/useWidgetSelection";
|
2021-09-09 15:10:22 +00:00
|
|
|
import { IconWrapper } from "constants/IconConstants";
|
2019-08-29 11:22:09 +00:00
|
|
|
|
2019-09-06 09:30:22 +00:00
|
|
|
type CardProps = {
|
|
|
|
|
details: WidgetCardProps;
|
2019-09-09 10:30:22 +00:00
|
|
|
};
|
2019-08-26 12:41:21 +00:00
|
|
|
|
2019-08-29 11:22:09 +00:00
|
|
|
export const Wrapper = styled.div`
|
2019-08-26 12:41:21 +00:00
|
|
|
padding: 10px 5px 10px 5px;
|
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
|
|
|
border-radius: 0px;
|
|
|
|
|
border: none;
|
2021-04-23 05:43:13 +00:00
|
|
|
position: relative;
|
2021-10-04 15:34:37 +00:00
|
|
|
color: ${Colors.CHARCOAL};
|
2019-11-13 11:34:11 +00:00
|
|
|
height: 72px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
2019-09-06 09:30:22 +00:00
|
|
|
& > div {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
2019-09-09 10:30:22 +00:00
|
|
|
&:hover {
|
2021-10-04 15:34:37 +00:00
|
|
|
background: ${Colors.Gallery};
|
2019-08-26 12:41:21 +00:00
|
|
|
cursor: grab;
|
2019-09-06 09:30:22 +00:00
|
|
|
}
|
|
|
|
|
& i {
|
2020-12-24 04:32:25 +00:00
|
|
|
font-family: ${(props) => props.theme.fonts.text};
|
|
|
|
|
font-size: ${(props) => props.theme.fontSizes[7]}px;
|
2019-08-26 12:41:21 +00:00
|
|
|
}
|
|
|
|
|
`;
|
2019-09-06 09:30:22 +00:00
|
|
|
|
2021-04-23 05:43:13 +00:00
|
|
|
export const BetaLabel = styled.div`
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
background: ${Colors.TUNDORA};
|
|
|
|
|
margin-top: 3px;
|
|
|
|
|
padding: 2px 4px;
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
right: -2%;
|
|
|
|
|
`;
|
|
|
|
|
|
2019-08-29 11:22:09 +00:00
|
|
|
export const IconLabel = styled.h5`
|
2021-10-04 15:34:37 +00:00
|
|
|
min-height: 32px;
|
2019-08-26 12:41:21 +00:00
|
|
|
text-align: center;
|
|
|
|
|
margin: 0;
|
|
|
|
|
text-transform: uppercase;
|
2020-12-24 04:32:25 +00:00
|
|
|
font-weight: ${(props) => props.theme.fontWeights[1]};
|
2019-08-26 12:41:21 +00:00
|
|
|
flex-shrink: 1;
|
2020-12-24 04:32:25 +00:00
|
|
|
font-size: ${(props) => props.theme.fontSizes[1]}px;
|
|
|
|
|
line-height: ${(props) => props.theme.lineHeights[2]}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
|
|
|
&::selection {
|
|
|
|
|
background: none;
|
|
|
|
|
}
|
2019-08-26 12:41:21 +00:00
|
|
|
`;
|
|
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
function WidgetCard(props: CardProps) {
|
2021-08-12 05:45:38 +00:00
|
|
|
const { setDraggingNewWidget } = useWidgetDragResize();
|
2021-05-18 18:29:39 +00:00
|
|
|
const { deselectAll } = useWidgetSelection();
|
2019-09-26 11:11:28 +00:00
|
|
|
|
2021-08-12 05:45:38 +00:00
|
|
|
const onDragStart = (e: any) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
deselectAll();
|
|
|
|
|
AnalyticsUtil.logEvent("WIDGET_CARD_DRAG", {
|
|
|
|
|
widgetType: props.details.type,
|
2021-09-09 15:10:22 +00:00
|
|
|
widgetName: props.details.displayName,
|
2021-08-12 05:45:38 +00:00
|
|
|
});
|
|
|
|
|
setDraggingNewWidget &&
|
|
|
|
|
setDraggingNewWidget(true, {
|
|
|
|
|
...props.details,
|
|
|
|
|
widgetId: generateReactKey(),
|
|
|
|
|
});
|
|
|
|
|
};
|
2021-09-09 15:10:22 +00:00
|
|
|
|
2022-01-25 13:56:52 +00:00
|
|
|
const type = `${props.details.type
|
2020-02-25 07:23:59 +00:00
|
|
|
.split("_")
|
|
|
|
|
.join("")
|
|
|
|
|
.toLowerCase()}`;
|
2022-01-25 13:56:52 +00:00
|
|
|
const className = `t--widget-card-draggable-${type}`;
|
2019-08-26 12:41:21 +00:00
|
|
|
return (
|
2022-01-25 13:56:52 +00:00
|
|
|
<Wrapper
|
|
|
|
|
className={className}
|
|
|
|
|
data-guided-tour-id={`widget-card-${type}`}
|
|
|
|
|
draggable
|
|
|
|
|
onDragStart={onDragStart}
|
|
|
|
|
>
|
2021-08-12 05:45:38 +00:00
|
|
|
<div>
|
2021-09-09 15:10:22 +00:00
|
|
|
<IconWrapper>
|
2021-11-23 08:01:46 +00:00
|
|
|
<img className="w-6 h-6" src={props.details.icon} />
|
2021-09-09 15:10:22 +00:00
|
|
|
</IconWrapper>
|
|
|
|
|
<IconLabel>{props.details.displayName}</IconLabel>
|
2021-08-12 05:45:38 +00:00
|
|
|
{props.details.isBeta && <BetaLabel>Beta</BetaLabel>}
|
|
|
|
|
</div>
|
|
|
|
|
</Wrapper>
|
2019-09-09 10:30:22 +00:00
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2019-08-26 12:41:21 +00:00
|
|
|
|
2019-09-09 10:30:22 +00:00
|
|
|
export default WidgetCard;
|