2019-11-21 10:52:49 +00:00
|
|
|
import React, { ReactNode } from "react";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { ItemRenderer, Select } from "@blueprintjs/select";
|
2020-01-24 09:54:40 +00:00
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
MenuItem,
|
|
|
|
|
Intent as BlueprintIntent,
|
|
|
|
|
PopoverPosition,
|
2020-01-27 13:53:33 +00:00
|
|
|
PopoverInteractionKind,
|
2020-01-24 09:54:40 +00:00
|
|
|
} from "@blueprintjs/core";
|
2019-11-21 10:52:49 +00:00
|
|
|
import { ControlIconName, ControlIcons } from "icons/ControlIcons";
|
|
|
|
|
import { noop } from "utils/AppsmithUtils";
|
|
|
|
|
import { Intent } from "constants/DefaultTheme";
|
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 { IconProps } from "constants/IconConstants";
|
|
|
|
|
import { Colors } from "constants/Colors";
|
2021-09-09 15:10:22 +00:00
|
|
|
import { DropdownOption } from "components/constants";
|
2019-11-21 10:52:49 +00:00
|
|
|
|
|
|
|
|
export type ContextDropdownOption = DropdownOption & {
|
|
|
|
|
onSelect: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
|
|
|
intent?: Intent;
|
2020-01-24 09:54:40 +00:00
|
|
|
children?: ContextDropdownOption[];
|
2019-11-21 10:52:49 +00:00
|
|
|
};
|
|
|
|
|
const Dropdown = Select.ofType<ContextDropdownOption>();
|
|
|
|
|
|
|
|
|
|
const StyledMenuItem = styled(MenuItem)`
|
|
|
|
|
&&&&.bp3-menu-item:hover {
|
2020-12-24 04:32:25 +00:00
|
|
|
background: ${(props) => props.theme.colors.primaryOld};
|
|
|
|
|
color: ${(props) => props.theme.colors.textOnDarkBG};
|
2019-11-21 10:52:49 +00:00
|
|
|
}
|
|
|
|
|
&&&.bp3-menu-item.bp3-intent-danger:hover {
|
2020-12-24 04:32:25 +00:00
|
|
|
background: ${(props) => props.theme.colors.error};
|
2019-11-21 10:52:49 +00:00
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
type ContextDropdownProps = {
|
|
|
|
|
options: ContextDropdownOption[];
|
|
|
|
|
className: string;
|
|
|
|
|
toggle: {
|
|
|
|
|
type: "icon" | "button";
|
|
|
|
|
icon?: ControlIconName;
|
2019-11-22 14:02:55 +00:00
|
|
|
iconSize?: number;
|
2019-11-21 10:52:49 +00:00
|
|
|
text?: string;
|
|
|
|
|
placeholder?: string;
|
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
|
|
|
color?: string;
|
2019-11-21 10:52:49 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
function DropdownItem(option: ContextDropdownOption) {
|
|
|
|
|
return (
|
|
|
|
|
<StyledMenuItem
|
|
|
|
|
intent={option.intent as BlueprintIntent}
|
|
|
|
|
key={option.value}
|
|
|
|
|
onClick={option.onSelect}
|
|
|
|
|
popoverProps={{
|
|
|
|
|
minimal: true,
|
|
|
|
|
hoverCloseDelay: 0,
|
|
|
|
|
hoverOpenDelay: 300,
|
|
|
|
|
interactionKind: PopoverInteractionKind.CLICK,
|
|
|
|
|
position: PopoverPosition.RIGHT,
|
|
|
|
|
modifiers: {
|
|
|
|
|
arrow: {
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
offset: {
|
|
|
|
|
enabled: true,
|
|
|
|
|
offset: "-16px, 0",
|
|
|
|
|
},
|
2020-01-24 09:54:40 +00:00
|
|
|
},
|
2021-04-28 10:28:39 +00:00
|
|
|
}}
|
|
|
|
|
shouldDismissPopover
|
|
|
|
|
text={option.label || option.value}
|
|
|
|
|
>
|
|
|
|
|
{option.children && option.children.map(DropdownItem)}
|
|
|
|
|
</StyledMenuItem>
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-01-24 09:54:40 +00:00
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
export function ContextDropdown(props: ContextDropdownProps) {
|
2019-11-21 10:52:49 +00:00
|
|
|
let trigger: ReactNode;
|
2020-03-27 09:02:11 +00:00
|
|
|
if (props.toggle.type === "icon" && props.toggle.icon) {
|
|
|
|
|
const TriggerElement = ControlIcons[props.toggle.icon];
|
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 TriggerElementProps: IconProps = {
|
2019-11-22 14:02:55 +00:00
|
|
|
width: props.toggle.iconSize,
|
|
|
|
|
height: props.toggle.iconSize,
|
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
|
|
|
color: props.toggle.color || Colors.SLATE_GRAY,
|
2020-03-27 09:02:11 +00:00
|
|
|
};
|
|
|
|
|
trigger = <TriggerElement {...TriggerElementProps} />;
|
|
|
|
|
}
|
2019-11-21 10:52:49 +00:00
|
|
|
if (props.toggle.type === "button" && props.toggle.text)
|
|
|
|
|
trigger = <Button text={props.toggle.text} />;
|
|
|
|
|
|
|
|
|
|
const renderer: ItemRenderer<ContextDropdownOption> = (
|
|
|
|
|
option: ContextDropdownOption,
|
2020-02-14 07:48:33 +00:00
|
|
|
) => <DropdownItem key={option.value} {...option} />;
|
2020-01-27 08:24:58 +00:00
|
|
|
|
2019-11-21 10:52:49 +00:00
|
|
|
return (
|
|
|
|
|
<Dropdown
|
2021-04-28 10:28:39 +00:00
|
|
|
className={props.className}
|
|
|
|
|
filterable={false}
|
2019-11-21 10:52:49 +00:00
|
|
|
itemRenderer={renderer}
|
2021-04-28 10:28:39 +00:00
|
|
|
items={props.options}
|
2019-11-21 10:52:49 +00:00
|
|
|
onItemSelect={noop}
|
|
|
|
|
>
|
|
|
|
|
{trigger}
|
|
|
|
|
</Dropdown>
|
|
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2019-11-21 10:52:49 +00:00
|
|
|
|
|
|
|
|
export default ContextDropdown;
|