PromucFlow_constructor/app/client/src/components/ads/Icon.tsx
Pranav Kanade f414285201
[Feature] Unified New Nav (#5558)
* temp commit

* using onsubmit to continue using action on form

* added recaptcha site key to env example file

* moved the recaptcha lib loading logic to signup page

* removed unnecessary edit

* handle the case where the recaptcha token is not provided as env var

* added proper env var config for client

* recaptcha config for ansible

* recaptcha config for heroku

* recaptcha config for k8s

* updated app.json

* fixed the typos

* added more description for env vars

* removed api key

* minor typo fix

* added new integration button

* updated the add int default link

* added active and create new tabs

* added the empty components to tabs. will control the section manually.

* added proper grid for integrations page

* added vertical tabs

* Added secondary tabs to integrations page

* added separate page for new apis

* classname changes

* added new components for active queries, new queries etc.

* added a separate component for data source list

* adding screen component conditionally, to be showing upon user's choice

* 1. Added grid styling to datasource home
2. Added connect buttons to em

* fixed data source security banner

* updated the styling for new api page

* added tertiary menu for active integrations

* updated styling for active connections

* updated collapse component to work properly

* added show more option to active data sources

* Slash commands feature init commit

* Added more commands

* Introduced JSX to render custom commands

* Merge conflict fix

* Spacing changes

* removed apis/db tabs and replaced em with integrations tab

* removed the unnecessary + integrations btn

* Added slash commands button

* Adjust styles for better ui

* Ordered the action entries under integrations

* Added new datasource command

* updated the getURL with proper params

* updated the link of create datasource btn

* updated the back btn link from data source editor

* Show connect data cta in property pane

* Styling fixes

* Fix margin

* added scrollable content to create new

* added on click scroll to create new page

* fixed a bug, creating new datasource twice

* added new action creator for integrations.

* Minor changes to add new bindings command.
Changed ui behaviour of / button

* UI style change

* updated the query editor to match the over all theme

* updated the query editor tabs

* Added the run btn to empty response screens

* minor fix

* updated the bg color of api type drop down

* updated the url being visited after delete api/query

* removed log

* Insert binding command UI change

* More UI changes

* removed unnecessary junk from integrations editor index

* clean up, removed unnecessary files

* removed useless routes

* for debugger only checking if integrations editor

* Removed all the links for api/query home pages

* Move command actions to a saga
Added support to binding the data back to the widget when are new API is created from widget

* Added reverse binding for DB queries

* Show / button only on hover

* not routing to integrations on create query/api

* Hide actions from suggestions in action pages

* removed the query/datasource/api home pages

* Changes widget.data to widget in slash commands

* Show dependencies in property pane

* Fix warning

* fixed scrolling issue

* will show a list of queries and apis for action picker

* showing icons for each action under integrations

* Fix dropdown not showing up

* Minor refactoring.
Changed commands

* added a way to list data sources in action creators

* Update query page url

* cam show icons for datasources

* Removed unused code

* Feature/slash commands (#5002)

* Slash commands feature init commit

* Added more commands

* Introduced JSX to render custom commands

* Merge conflict fix

* Spacing changes

* Added slash commands button

* Adjust styles for better ui

* Added new datasource command

* Minor changes to add new bindings command.
Changed ui behaviour of / button

* UI style change

* Insert binding command UI change

* More UI changes

* Move command actions to a saga
Added support to binding the data back to the widget when are new API is created from widget

* Added reverse binding for DB queries

* Show / button only on hover

* Hide actions from suggestions in action pages

* Changes widget.data to widget in slash commands

* Minor refactoring.
Changed commands

* Removed unused code

* remove more unusued code

* Added support to generate new api from a datasource in quick commands

* Code correction to use types

* Refactored commands code

* Minor bug fixes

* Remove new integrations command for actions.
Fixed autocomplete not showing up

* Changes to prevent autocomplete trigger for navigation commands

* Prevent hinter execution when show hint is open already.

* Show hinter on focus

* Update text to be called in the omnibar

* updated the copy for empty active datasources

* Update url

* Fix text decoration

* updated the redirection for back btns

* Use themes

* Add cypress test

* fixed back btn nav

* fetching form configs for datasources

* a callback fixed

* Fix slash command not executed on click (#5540)

* Replace the value if not a string else append

* Log commands menu events

* updated mock data base navigation

* updated mock data base navigation

* updated the close editors and back buttons

* All back btns from editors will go back to data sources and back from data source will go back to canvas

* fixed bg colors

* minor styled updates

* removed margin from header of generic datasource

* warnings fixes

* If user is already on the location not redirecting em

* when editing, will check if the coming from data source and redirect accordingly

* updated redirection for newly created api/queries

* updated back btn for newly created datasources

* back for new curl goes to data sources

* Revert "[Fix] revert new nav (#5533)"

This reverts commit 1647815d

* remaining original reverted chagnes

* fixed the width of incoming/outgoing entity bar in property pane

* removing residue from resolved merge conflicts

* Fix widget icons not visible in dropdown menu

* minor fix to use proper integration URL

* updated the URLs for unified datasources

* converted back and close to btns from banners

* on accessing data source from sidebar, it'll always go to view mode

* updated the edit path for saas editors

* Added saved state for google sheet

* on google sheet delete redirecting to create new

* minor fix

* fixed the redirection call on saving a datasource

* removed save and test cmd as it wasn't needed

* Removing test cases to be fixed by Arun

* commenting more tests to be fixed by Arun

* updated call api cy command

* Fix extra margin issue

* fixed the update datasource saga

* fixed video spec

* Revert "commenting more tests to be fixed by Arun"

This reverts commit 42087a95ad77107401a1619e4c2d4c541a81d6c3.

* Revert "Removing test cases to be fixed by Arun"

This reverts commit f6fad67e558d22045114a90409428ef9b737478f.

* fixed the entity explorer query datasource spec

* cautious fix

* update widget locators

* fixed leave org test

* fixes for FormWidgets

* updated the image spec

* Use memo

* Fix debugger url checks

* for copy and delete widget pointing directly to svgs

* Fix entity text

* Fix styling and show tooltip for property pane dependencies

* removed the unnecessary callback

* added a separate saga to to redirect to new integrations using onSuccess

* Bug Fixes - New nav (#5629)

* will show scrollbar only on hover

* made mock data cards clickable

* fixed the grid view

* fixed the cursor position when clicking on / btn

* updated the hint for `/` command

* binding prompt will close on focus change

* hiding / command for api body

* hiding / command for query pane

* Added 2 new icons

* Fix cursor position on selecting a binding and clicking on the slash menu button

* trying out fix to copyWidget cy command

* removing zero width space characters from the property pane text

Co-authored-by: arunvjn <arun@appsmith.com>
Co-authored-by: Akash N <akash@codemonk.in>
Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
Co-authored-by: Rishabh Saxena <rishabh.robben@gmail.com>
2021-07-07 09:16:16 +05:30

525 lines
15 KiB
TypeScript

import React, { forwardRef, Ref } from "react";
import { ReactComponent as DeleteIcon } from "assets/icons/ads/delete.svg";
import { ReactComponent as BookIcon } from "assets/icons/ads/book.svg";
import { ReactComponent as BugIcon } from "assets/icons/ads/bug.svg";
import { ReactComponent as CancelIcon } from "assets/icons/ads/cancel.svg";
import { ReactComponent as ExpandMore } from "assets/icons/ads/expand-more.svg";
import { ReactComponent as CrossIcon } from "assets/icons/ads/cross.svg";
import { ReactComponent as OpenIcon } from "assets/icons/ads/open.svg";
import { ReactComponent as UserIcon } from "assets/icons/ads/user.svg";
import { ReactComponent as GeneralIcon } from "assets/icons/ads/general.svg";
import { ReactComponent as BillingIcon } from "assets/icons/ads/billing.svg";
import { ReactComponent as EditIcon } from "assets/icons/ads/edit.svg";
import { ReactComponent as ErrorIcon } from "assets/icons/ads/error.svg";
import { ReactComponent as ShineIcon } from "assets/icons/ads/shine.svg";
import { ReactComponent as SuccessIcon } from "assets/icons/ads/success.svg";
import { ReactComponent as SearchIcon } from "assets/icons/ads/search.svg";
import { ReactComponent as CloseIcon } from "assets/icons/ads/close.svg";
import { ReactComponent as WarningIcon } from "assets/icons/ads/warning.svg";
import { ReactComponent as WarningTriangleIcon } from "assets/icons/ads/warning-triangle.svg";
import { ReactComponent as DownArrow } from "assets/icons/ads/down_arrow.svg";
import { ReactComponent as ShareIcon } from "assets/icons/ads/share.svg";
import { ReactComponent as RocketIcon } from "assets/icons/ads/launch.svg";
import { ReactComponent as WorkspaceIcon } from "assets/icons/ads/workspace.svg";
import { ReactComponent as CreateNewIcon } from "assets/icons/ads/create-new.svg";
import { ReactComponent as InviteUserIcon } from "assets/icons/ads/invite-users.svg";
import { ReactComponent as ViewAllIcon } from "assets/icons/ads/view-all.svg";
import { ReactComponent as ViewLessIcon } from "assets/icons/ads/view-less.svg";
import { ReactComponent as ContextMenuIcon } from "assets/icons/ads/context-menu.svg";
import { ReactComponent as DuplicateIcon } from "assets/icons/ads/duplicate.svg";
import { ReactComponent as LogoutIcon } from "assets/icons/ads/logout.svg";
import { ReactComponent as ManageIcon } from "assets/icons/ads/manage.svg";
import { ReactComponent as ArrowLeft } from "assets/icons/ads/arrow-left.svg";
import { ReactComponent as Fork } from "assets/icons/ads/fork.svg";
import { ReactComponent as ChevronLeft } from "assets/icons/ads/chevron_left.svg";
import { ReactComponent as ChevronRight } from "assets/icons/ads/chevron_right.svg";
import { ReactComponent as LinkIcon } from "assets/icons/ads/link.svg";
import { ReactComponent as HelpIcon } from "assets/icons/help/help.svg";
import { ReactComponent as CloseModalIcon } from "assets/icons/ads/close-modal.svg";
import { ReactComponent as NoResponseIcon } from "assets/icons/ads/no-response.svg";
import { ReactComponent as LightningIcon } from "assets/icons/ads/lightning.svg";
import { ReactComponent as AddMoreIcon } from "assets/icons/ads/add-more.svg";
import { ReactComponent as RightArrowIcon } from "assets/icons/ads/right-arrow.svg";
import { ReactComponent as TrendingFlat } from "assets/icons/ads/trending-flat.svg";
import { ReactComponent as DatasourceIcon } from "assets/icons/ads/datasource.svg";
import { ReactComponent as PlayIcon } from "assets/icons/ads/play.svg";
import { ReactComponent as DesktopIcon } from "assets/icons/ads/desktop.svg";
import { ReactComponent as WandIcon } from "assets/icons/ads/wand.svg";
import { ReactComponent as MobileIcon } from "assets/icons/ads/mobile.svg";
import { ReactComponent as TabletIcon } from "assets/icons/ads/tablet.svg";
import { ReactComponent as FluidIcon } from "assets/icons/ads/fluid.svg";
import { ReactComponent as CardContextMenu } from "assets/icons/ads/card-context-menu.svg";
import { ReactComponent as SendButton } from "assets/icons/comments/send-button.svg";
import { ReactComponent as Emoji } from "assets/icons/comments/emoji.svg";
import { ReactComponent as Pin } from "assets/icons/comments/pin.svg";
import { ReactComponent as OvalCheck } from "assets/icons/comments/check-oval.svg";
import { ReactComponent as ContextMenu } from "assets/icons/ads/context-menu.svg";
import { ReactComponent as Trash } from "assets/icons/comments/trash.svg";
import { ReactComponent as ReadPin } from "assets/icons/comments/read-pin.svg";
import { ReactComponent as UnreadPin } from "assets/icons/comments/unread-pin.svg";
import { ReactComponent as Link2 } from "assets/icons/comments/link.svg";
import { ReactComponent as CommentContextMenu } from "assets/icons/comments/context-menu.svg";
import { ReactComponent as DownArrow2 } from "assets/icons/comments/down-arrow.svg";
import { ReactComponent as Filter } from "assets/icons/comments/filter.svg";
import { ReactComponent as Chat } from "assets/icons/comments/chat.svg";
import { ReactComponent as Pin3 } from "assets/icons/comments/pin_3.svg";
import { ReactComponent as Unpin } from "assets/icons/comments/unpin.svg";
import { ReactComponent as Reaction } from "assets/icons/comments/reaction.svg";
import { ReactComponent as Reaction2 } from "assets/icons/comments/reaction-2.svg";
import { ReactComponent as Upload } from "assets/icons/ads/upload.svg";
import { ReactComponent as Download } from "assets/icons/ads/download.svg";
import styled from "styled-components";
import { CommonComponentProps, Classes } from "./common";
import { noop } from "lodash";
import { theme } from "constants/DefaultTheme";
import Spinner from "./Spinner";
import { ControlIcons } from "icons/ControlIcons";
export enum IconSize {
XXS = "extraExtraSmall",
XS = "extraSmall",
SMALL = "small",
MEDIUM = "medium",
LARGE = "large",
XL = "extraLarge",
XXL = "extraExtraLarge",
XXXL = "extraExtraExtraLarge",
}
export const sizeHandler = (size?: IconSize) => {
let iconSize = 0;
switch (size) {
case IconSize.XXS:
iconSize = theme.iconSizes.XXS;
break;
case IconSize.XS:
iconSize = theme.iconSizes.XS;
break;
case IconSize.SMALL:
iconSize = theme.iconSizes.SMALL;
break;
case IconSize.MEDIUM:
iconSize = theme.iconSizes.MEDIUM;
break;
case IconSize.LARGE:
iconSize = theme.iconSizes.LARGE;
break;
case IconSize.XL:
iconSize = theme.iconSizes.XL;
break;
case IconSize.XXL:
iconSize = theme.iconSizes.XXL;
break;
case IconSize.XXXL:
iconSize = theme.iconSizes.XXXL;
break;
default:
iconSize = theme.iconSizes.SMALL;
break;
}
return iconSize;
};
export const IconCollection = [
"upload",
"download",
"book",
"bug",
"cancel",
"cross",
"delete",
"expand-more",
"open",
"user",
"general",
"billing",
"edit",
"error",
"shine",
"danger",
"success",
"search",
"close",
"share",
"rocket",
"workspace",
"plus",
"invite-user",
"view-all",
"view-less",
"warning",
"warning-triangle",
"downArrow",
"context-menu",
"duplicate",
"logout",
"manage",
"arrow-left",
"fork",
"chevron-left",
"chevron-right",
"link",
"help",
"close-modal",
"no-response",
"lightning",
"add-more",
"right-arrow",
"trending-flat",
"datasource",
"play",
"desktop",
"wand",
"mobile",
"tablet",
"fluid",
"card-context-menu",
"send-button",
"emoji",
"pin",
"oval-check",
"HEADING_ONE",
"HEADING_TWO",
"HEADING_THREE",
"PARAGRAPH",
"PARAGRAPH_TWO",
"context-menu",
"trash",
"link-2",
"close-x",
"comment-context-menu",
"down-arrow-2",
"read-pin",
"unread-pin",
"filter",
"chat",
"pin-3",
"unpin",
"reaction",
"reaction-2",
] as const;
export type IconName = typeof IconCollection[number];
export const IconWrapper = styled.span<IconProps>`
&:focus {
outline: none;
}
display: flex;
align-items: center;
svg {
width: ${(props) => sizeHandler(props.size)}px;
height: ${(props) => sizeHandler(props.size)}px;
${(props) =>
!props.keepColors
? `
path {
fill: ${props.fillColor || props.theme.colors.icon.normal};
}
circle {
fill: ${props.fillColor || props.theme.colors.icon.normal};
}
`
: ""}
${(props) => (props.invisible ? `visibility: hidden;` : null)};
&:hover {
cursor: pointer;
${(props) =>
!props.keepColors
? `
path {
fill: ${props.hoverFillColor || props.theme.colors.icon.hover};
}
`
: ""}
}
&:hover {
cursor: pointer;
${(props) =>
!props.keepColors
? `
path {
fill: ${props.hoverFillColor || props.theme.colors.icon.hover};
}
`
: ""}
}
`;
export type IconProps = {
size?: IconSize;
name?: IconName;
invisible?: boolean;
className?: string;
onClick?: (e: React.MouseEvent) => void;
fillColor?: string;
hoverFillColor?: string;
keepColors?: boolean;
};
const Icon = forwardRef(
(props: IconProps & CommonComponentProps, ref: Ref<HTMLSpanElement>) => {
let returnIcon;
switch (props.name) {
case "book":
returnIcon = <BookIcon />;
break;
case "bug":
returnIcon = <BugIcon />;
break;
case "cancel":
returnIcon = <CancelIcon />;
break;
case "cross":
returnIcon = <CrossIcon />;
break;
case "delete":
returnIcon = <DeleteIcon />;
break;
case "expand-more":
returnIcon = <ExpandMore />;
break;
case "open":
returnIcon = <OpenIcon />;
break;
case "user":
returnIcon = <UserIcon />;
break;
case "general":
returnIcon = <GeneralIcon />;
break;
case "billing":
returnIcon = <BillingIcon />;
break;
case "edit":
returnIcon = <EditIcon />;
break;
case "error":
returnIcon = <ErrorIcon />;
break;
case "danger":
returnIcon = <ErrorIcon />;
break;
case "shine":
returnIcon = <ShineIcon />;
break;
case "success":
returnIcon = <SuccessIcon />;
break;
case "search":
returnIcon = <SearchIcon />;
break;
case "close":
returnIcon = <CloseIcon />;
break;
case "downArrow":
returnIcon = <DownArrow />;
break;
case "share":
returnIcon = <ShareIcon />;
break;
case "rocket":
returnIcon = <RocketIcon />;
break;
case "wand":
returnIcon = <WandIcon />;
break;
case "workspace":
returnIcon = <WorkspaceIcon />;
break;
case "plus":
returnIcon = <CreateNewIcon />;
break;
case "invite-user":
returnIcon = <InviteUserIcon />;
break;
case "view-all":
returnIcon = <ViewAllIcon />;
break;
case "view-less":
returnIcon = <ViewLessIcon />;
break;
case "context-menu":
returnIcon = <ContextMenuIcon />;
break;
case "duplicate":
returnIcon = <DuplicateIcon />;
break;
case "logout":
returnIcon = <LogoutIcon />;
break;
case "manage":
returnIcon = <ManageIcon />;
break;
case "warning":
returnIcon = <WarningIcon />;
break;
case "warning-triangle":
returnIcon = <WarningTriangleIcon />;
break;
case "arrow-left":
returnIcon = <ArrowLeft />;
break;
case "fork":
returnIcon = <Fork />;
break;
case "chevron-left":
returnIcon = <ChevronLeft />;
break;
case "chevron-right":
returnIcon = <ChevronRight />;
break;
case "link":
returnIcon = <LinkIcon />;
break;
case "help":
returnIcon = <HelpIcon />;
break;
case "close-modal":
case "close-x":
returnIcon = <CloseModalIcon />;
break;
case "no-response":
returnIcon = <NoResponseIcon />;
break;
case "lightning":
returnIcon = <LightningIcon />;
break;
case "add-more":
returnIcon = <AddMoreIcon />;
break;
case "right-arrow":
returnIcon = <RightArrowIcon />;
break;
case "trending-flat":
returnIcon = <TrendingFlat />;
break;
case "datasource":
returnIcon = <DatasourceIcon />;
break;
case "play":
returnIcon = <PlayIcon />;
break;
case "desktop":
returnIcon = <DesktopIcon />;
break;
case "mobile":
returnIcon = <MobileIcon />;
break;
case "tablet":
returnIcon = <TabletIcon />;
break;
case "fluid":
returnIcon = <FluidIcon />;
break;
case "card-context-menu":
returnIcon = <CardContextMenu />;
break;
case "send-button":
returnIcon = <SendButton />;
break;
case "emoji":
returnIcon = <Emoji />;
break;
case "pin":
returnIcon = <Pin />;
break;
case "oval-check":
returnIcon = <OvalCheck />;
break;
case "HEADING_ONE":
case "HEADING_TWO":
case "HEADING_THREE":
case "PARAGRAPH":
case "PARAGRAPH_TWO":
const ControlIcon = ControlIcons[props.name];
returnIcon = <ControlIcon height={24} width={24} />;
break;
case "context-menu":
returnIcon = <ContextMenu />;
break;
case "read-pin":
returnIcon = <ReadPin />;
break;
case "unread-pin":
returnIcon = <UnreadPin />;
break;
case "link-2":
returnIcon = <Link2 />;
break;
case "trash":
returnIcon = <Trash />;
break;
case "comment-context-menu":
returnIcon = <CommentContextMenu />;
break;
case "down-arrow-2":
returnIcon = <DownArrow2 />;
break;
case "filter":
returnIcon = <Filter />;
break;
case "chat":
returnIcon = <Chat />;
break;
case "pin-3":
returnIcon = <Pin3 />;
break;
case "unpin":
returnIcon = <Unpin />;
break;
case "reaction":
returnIcon = <Reaction />;
break;
case "reaction-2":
returnIcon = <Reaction2 />;
break;
case "upload":
returnIcon = <Upload />;
break;
case "download":
returnIcon = <Download />;
break;
default:
returnIcon = null;
break;
}
return returnIcon && !props.isLoading ? (
<IconWrapper
className={Classes.ICON}
data-cy={props.cypressSelector}
ref={ref}
{...props}
onClick={props.onClick || noop}
>
{returnIcon}
</IconWrapper>
) : props.isLoading ? (
<Spinner size={props.size} />
) : null;
},
);
Icon.displayName = "Icon";
export default Icon;