2019-12-23 12:16:33 +00:00
|
|
|
import React from "react";
|
2020-05-29 06:07:18 +00:00
|
|
|
import {
|
|
|
|
|
Intent,
|
|
|
|
|
BlueprintButtonIntentsCSS,
|
|
|
|
|
Skin,
|
|
|
|
|
} from "constants/DefaultTheme";
|
2019-12-23 12:16:33 +00:00
|
|
|
import styled, { css } from "styled-components";
|
|
|
|
|
import {
|
|
|
|
|
AnchorButton as BlueprintAnchorButton,
|
|
|
|
|
Button as BlueprintButton,
|
|
|
|
|
Intent as BlueprintIntent,
|
|
|
|
|
IconName,
|
2020-08-06 11:06:53 +00:00
|
|
|
MaybeElement,
|
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
|
|
|
IButtonProps,
|
2019-12-23 12:16:33 +00:00
|
|
|
} from "@blueprintjs/core";
|
|
|
|
|
import { Direction, Directions } from "utils/helpers";
|
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 { omit } from "lodash";
|
2019-12-23 12:16:33 +00:00
|
|
|
|
|
|
|
|
const outline = css`
|
|
|
|
|
&&&&&& {
|
|
|
|
|
border-width: 1px;
|
|
|
|
|
border-style: solid;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
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 buttonStyles = css<Partial<ButtonProps>>`
|
2019-12-23 12:16:33 +00:00
|
|
|
${BlueprintButtonIntentsCSS}
|
|
|
|
|
&&&& {
|
|
|
|
|
padding: ${props =>
|
|
|
|
|
props.filled || props.outline
|
2020-01-28 08:21:22 +00:00
|
|
|
? props.theme.spaces[2] + "px " + props.theme.spaces[3] + "px"
|
2019-12-23 12:16:33 +00:00
|
|
|
: 0};
|
2020-02-03 10:37:03 +00:00
|
|
|
|
2019-12-23 12:16:33 +00:00
|
|
|
background: ${props =>
|
2020-03-06 09:33:20 +00:00
|
|
|
props.filled || props.outline ? "inherit" : "transparent"};
|
2020-03-27 09:02:11 +00:00
|
|
|
|
|
|
|
|
width: ${props => (props.fluid ? "100%" : "auto")};
|
2019-12-23 12:16:33 +00:00
|
|
|
}
|
2020-05-20 04:15:19 +00:00
|
|
|
&&&&&& {
|
|
|
|
|
&.bp3-button span {
|
2020-05-29 06:07:18 +00:00
|
|
|
font-weight: ${props => (props.skin !== undefined ? 400 : 700)};
|
2020-05-20 04:15:19 +00:00
|
|
|
}
|
|
|
|
|
.bp3-icon svg {
|
2020-05-29 06:07:18 +00:00
|
|
|
width: ${props => (props.skin !== undefined ? 14 : 16)}px;
|
|
|
|
|
height: ${props => (props.skin !== undefined ? 14 : 16)}px;
|
2020-05-20 15:44:52 +00:00
|
|
|
}
|
|
|
|
|
&.bp3-button {
|
2020-05-28 09:18:08 +00:00
|
|
|
display: flex;
|
|
|
|
|
justify-content: ${props =>
|
2020-05-29 11:33:08 +00:00
|
|
|
props.skin === undefined
|
|
|
|
|
? "center"
|
|
|
|
|
: props.iconAlignment === Directions.RIGHT
|
2020-05-29 06:07:18 +00:00
|
|
|
? "space-between"
|
|
|
|
|
: "flex-start"};
|
2020-05-20 04:15:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-12-23 12:16:33 +00:00
|
|
|
${props => (props.outline ? outline : "")}
|
|
|
|
|
`;
|
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 StyledButton = styled((props: IButtonProps & Partial<ButtonProps>) => (
|
|
|
|
|
<BlueprintButton
|
|
|
|
|
{...omit(props, ["iconAlignment", "fluid", "filled", "outline"])}
|
|
|
|
|
/>
|
|
|
|
|
))`
|
2019-12-23 12:16:33 +00:00
|
|
|
${buttonStyles}
|
|
|
|
|
`;
|
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 StyledAnchorButton = styled(
|
|
|
|
|
(props: IButtonProps & Partial<ButtonProps>) => (
|
|
|
|
|
<BlueprintAnchorButton
|
|
|
|
|
{...omit(props, ["iconAlignment", "fluid", "filled", "outline"])}
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
)`
|
2019-12-23 12:16:33 +00:00
|
|
|
${buttonStyles}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export type ButtonProps = {
|
|
|
|
|
outline?: boolean;
|
|
|
|
|
filled?: boolean;
|
|
|
|
|
intent?: Intent;
|
|
|
|
|
text?: string;
|
|
|
|
|
onClick?: () => void;
|
|
|
|
|
href?: string;
|
2020-08-06 11:06:53 +00:00
|
|
|
icon?: string | MaybeElement;
|
2019-12-23 12:16:33 +00:00
|
|
|
iconAlignment?: Direction;
|
2020-01-20 08:07:00 +00:00
|
|
|
loading?: boolean;
|
|
|
|
|
disabled?: boolean;
|
2020-01-28 08:21:22 +00:00
|
|
|
size?: "large" | "small";
|
2020-02-03 10:37:03 +00:00
|
|
|
type?: "button" | "submit" | "reset";
|
2020-02-25 11:33:07 +00:00
|
|
|
className?: string;
|
2020-03-27 09:02:11 +00:00
|
|
|
fluid?: boolean;
|
2020-05-29 06:07:18 +00:00
|
|
|
skin?: Skin;
|
2020-08-07 06:56:47 +00:00
|
|
|
target?: string;
|
2019-12-23 12:16:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Button = (props: ButtonProps) => {
|
|
|
|
|
const icon: IconName | undefined =
|
|
|
|
|
props.icon &&
|
|
|
|
|
(props.iconAlignment === Directions.LEFT ||
|
|
|
|
|
props.iconAlignment === undefined)
|
|
|
|
|
? (props.icon as IconName)
|
|
|
|
|
: undefined;
|
|
|
|
|
const rightIcon: IconName | undefined =
|
|
|
|
|
props.icon && props.iconAlignment === Directions.RIGHT
|
|
|
|
|
? (props.icon as IconName)
|
|
|
|
|
: undefined;
|
|
|
|
|
|
|
|
|
|
const baseProps = {
|
|
|
|
|
text: props.text,
|
|
|
|
|
minimal: !props.filled,
|
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
|
|
|
outline: !!props.outline,
|
|
|
|
|
filled: !!props.filled,
|
2019-12-23 12:16:33 +00:00
|
|
|
intent: props.intent as BlueprintIntent,
|
2020-01-28 08:21:22 +00:00
|
|
|
large: props.size === "large",
|
|
|
|
|
small: props.size === "small",
|
2020-01-20 08:07:00 +00:00
|
|
|
loading: props.loading,
|
|
|
|
|
disabled: props.disabled,
|
2020-02-24 09:35:11 +00:00
|
|
|
type: props.type,
|
2020-02-25 11:33:07 +00:00
|
|
|
className: props.className,
|
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
|
|
|
fluid: !!props.fluid,
|
2020-05-29 06:07:18 +00:00
|
|
|
skin: props.skin,
|
2020-05-20 15:44:52 +00:00
|
|
|
iconAlignment: props.iconAlignment ? props.iconAlignment : undefined,
|
2019-12-23 12:16:33 +00:00
|
|
|
};
|
|
|
|
|
if (props.href) {
|
|
|
|
|
return (
|
|
|
|
|
<StyledAnchorButton
|
|
|
|
|
icon={icon}
|
|
|
|
|
rightIcon={rightIcon}
|
|
|
|
|
{...baseProps}
|
|
|
|
|
href={props.href}
|
2020-08-07 06:56:47 +00:00
|
|
|
target={props.target}
|
2019-12-23 12:16:33 +00:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
} else
|
|
|
|
|
return (
|
|
|
|
|
<StyledButton
|
|
|
|
|
rightIcon={rightIcon}
|
|
|
|
|
icon={icon}
|
|
|
|
|
{...baseProps}
|
|
|
|
|
onClick={props.onClick}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Button;
|