2020-10-14 10:35:19 +00:00
|
|
|
import React, { forwardRef, Ref } from "react";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as DeleteIcon } from "assets/icons/ads/delete.svg";
|
2021-08-23 06:17:28 +00:00
|
|
|
import { ReactComponent as BookLineIcon } from "assets/icons/ads/book-open-line.svg";
|
2021-04-23 13:50:55 +00:00
|
|
|
import { ReactComponent as BugIcon } from "assets/icons/ads/bug.svg";
|
|
|
|
|
import { ReactComponent as CancelIcon } from "assets/icons/ads/cancel.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as ExpandMore } from "assets/icons/ads/expand-more.svg";
|
2021-04-23 13:50:55 +00:00
|
|
|
import { ReactComponent as CrossIcon } from "assets/icons/ads/cross.svg";
|
2022-03-03 10:56:53 +00:00
|
|
|
import { ReactComponent as Fork2Icon } from "assets/icons/ads/fork-2.svg";
|
2021-04-23 13:50:55 +00:00
|
|
|
import { ReactComponent as OpenIcon } from "assets/icons/ads/open.svg";
|
2020-08-10 04:54:33 +00:00
|
|
|
import { ReactComponent as UserIcon } from "assets/icons/ads/user.svg";
|
2020-08-14 07:11:38 +00:00
|
|
|
import { ReactComponent as GeneralIcon } from "assets/icons/ads/general.svg";
|
|
|
|
|
import { ReactComponent as BillingIcon } from "assets/icons/ads/billing.svg";
|
2020-08-26 09:04:58 +00:00
|
|
|
import { ReactComponent as ErrorIcon } from "assets/icons/ads/error.svg";
|
2021-02-11 06:36:07 +00:00
|
|
|
import { ReactComponent as ShineIcon } from "assets/icons/ads/shine.svg";
|
2020-08-26 09:04:58 +00:00
|
|
|
import { ReactComponent as SuccessIcon } from "assets/icons/ads/success.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
import SearchIcon from "remixicon-react/SearchLineIcon";
|
2020-08-26 07:25:27 +00:00
|
|
|
import { ReactComponent as CloseIcon } from "assets/icons/ads/close.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as WarningIcon } from "assets/icons/ads/warning.svg";
|
2021-04-23 13:50:55 +00:00
|
|
|
import { ReactComponent as WarningTriangleIcon } from "assets/icons/ads/warning-triangle.svg";
|
2021-09-07 09:15:11 +00:00
|
|
|
import { ReactComponent as ShareIcon2 } from "assets/icons/ads/share-2.svg";
|
2020-08-31 04:59:18 +00:00
|
|
|
import { ReactComponent as InviteUserIcon } from "assets/icons/ads/invite-users.svg";
|
2021-11-22 06:09:16 +00:00
|
|
|
// import { ReactComponent as ViewAllIcon } from "assets/icons/ads/view-all.svg";
|
|
|
|
|
// import { ReactComponent as ViewLessIcon } from "assets/icons/ads/view-less.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as DuplicateIcon } from "assets/icons/ads/duplicate.svg";
|
|
|
|
|
// import { ReactComponent as LogoutIcon } from "assets/icons/ads/logout.svg";
|
2020-10-12 07:15:35 +00:00
|
|
|
import { ReactComponent as ManageIcon } from "assets/icons/ads/manage.svg";
|
2021-02-04 07:02:36 +00:00
|
|
|
import { ReactComponent as ArrowLeft } from "assets/icons/ads/arrow-left.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as Fork } from "assets/icons/ads/fork.svg";
|
2021-02-04 07:02:36 +00:00
|
|
|
import { ReactComponent as ChevronLeft } from "assets/icons/ads/chevron_left.svg";
|
2021-03-08 08:24:12 +00:00
|
|
|
import { ReactComponent as LinkIcon } from "assets/icons/ads/link.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as CloseModalIcon } from "assets/icons/ads/close-modal.svg";
|
2021-02-11 12:54:00 +00:00
|
|
|
import { ReactComponent as NoResponseIcon } from "assets/icons/ads/no-response.svg";
|
|
|
|
|
import { ReactComponent as LightningIcon } from "assets/icons/ads/lightning.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as AddMoreIcon } from "assets/icons/ads/add-more.svg";
|
|
|
|
|
// import { ReactComponent as RightArrowIcon } from "assets/icons/ads/right-arrow.svg";
|
2021-07-07 03:46:16 +00:00
|
|
|
import { ReactComponent as TrendingFlat } from "assets/icons/ads/trending-flat.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as DatasourceIcon } from "assets/icons/ads/datasource.svg";
|
2021-02-11 12:54:00 +00:00
|
|
|
import { ReactComponent as PlayIcon } from "assets/icons/ads/play.svg";
|
2021-03-03 05:26:47 +00:00
|
|
|
import { ReactComponent as DesktopIcon } from "assets/icons/ads/desktop.svg";
|
2021-04-23 13:50:55 +00:00
|
|
|
import { ReactComponent as WandIcon } from "assets/icons/ads/wand.svg";
|
2021-03-03 05:26:47 +00:00
|
|
|
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";
|
Initialise comments (#3328)
* Initial scaffolding for comments CRUD APIs
* add actions
* add assets
* state management for existing comments and creating new
* add ui components
* add overlay comments wrapper to baseWidget
* add toggle comment mode button at editor header
* trigger tests
* Disallow commenting as someone else
* Add applicationId for comments
* lint
* Add overlay blacklist to prevent component interaction while adding comments
* Comment thread style updates
* Placeholder comment context menu
* Controlled comment thread visibility for making new comments visible by default
* Update comment type description
* Reset input on save
* Resolve comment thread button ui
* fix close on esc key, dont create new comment on outside click
* Submit on enter
* add emoji picker
* Attempt at adding a websocket server in Java
* CRUD APIs for comment threads
* Add API for getting all threads in application
* Move types to a separate file
* Initial commit for real time server (RTS)
* Add script to start RTS
* Fix position property
* Use create comment thread API
* Use add comment to thread API
* Add custom cursor
* Dispatch logout init on 401 errors
* Allow CORS for real time connection
* Add more logs to RTS
* Fix construction of MongoClient
* WIP: Real time comments
* Enable comments
* Minor updates
* Read backend API base URL from environment
* Escape to reset comments mode
* Set popover position as auto and boundary as scroll parent
* Disable warning
* Added permissions for comment threads
* Add resolved API for comment threads
* Migration to set commenting permission on existing apps
* Fix updates bringing the RTS down
* Show view latest button, scroll to bottom on creating a new comment
* Cleanup comment reducer
* Move to typescript for RTS
* Add missing server.ts and tsconfig files
* Resolve / unresolve comment
* Scaffold app comments
* Minor fixes: comment on top of all widgets, add toggle button at viewer header
* Reconnect socket on creating a new app, set connected status in store
* Retry socket connection flow
* Integration tests for comments with api mocks using msw
* Fix circular depependency
* rm file
* Minor cleanup and comments
* Minor refactors: move isScrolledToBottom to common hooks, decouple prevent interactions overlay from comments wrapper
* Use policies when pushing updates in RTS
* ENV var to set if comments are enabled
* Fix: check if editor/viewer is initialised before waiting for init action
* Add tests for comments reducer
* Revert "ENV var to set if comments are enabled"
This reverts commit 988efeaa69d378d943a387e1e73510334958adc5.
* Enable comments for users with appsmith email
* lint
* fix
* Try running a socket.io server inside backend
* Update comment reducer tests
* Init mentions within comments
* Fix comment thread updates with email rooms
* Minor fixes
* Refactors / review suggestions
* lint
* increase cache limit for builds
* Comment out tests for feature that's under development
* Add Dockerfile for RTS
* Fix policies missing for first comment in threads
* Use draftJS for comments input with mentions support
* fix fixtures
* Use thread's policies when querying for threads
* Update socket.io to v4
* Add support for richer body with mentions
* Update comment body type to RawDraftContentState
* fix stale method
* Fix mentions search
* Minor cleanups
* Comment context menu and thread UI updates
* revert: Scaffold app comments
* Yarn dependencies
* Delete comment using id api added
* Init app comments
* Add test for creating thread
* Api for delete comment with id
* Test comment creation response and policies
* Copy comment links
* Fix reset editor state
* Delete valid comment testcase added
* Delete comment TC : code refactor
* Don't allow creating comments with an empty body
* Pin comments WIP[]
* Ignore dependency-reduced-pom.xml files from VCS
* Cleanup of some dev-only files, for review
* Delete comment
* Update socket.io to v4 in RTS
* Pin and resolve comment thread object added in commentThread
* Pin and resolve comment thread object added in commentThread
* Update comment thread API
* Added creationTime and updationTime in comment thread response
* Added creationTime and updationTime in comment thread response
* Added human readable id to comment threads, fallback to username for null name in user document
* Refactor
* lint
* fix test, rm duplicate selector
* comment out saga used for dev
* CommentThread viewed status, username fallback for getName=null, username field added in pin & resolve status
* lint
* trigger tests
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: Abhijeet <abhi.nagarnaik@gmail.com>
2021-04-29 10:33:51 +00:00
|
|
|
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 Pin } from "assets/icons/comments/pin.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
import { ReactComponent as TrashOutline } from "assets/icons/form/trash.svg";
|
2021-05-20 12:03:08 +00:00
|
|
|
import { ReactComponent as ReadPin } from "assets/icons/comments/read-pin.svg";
|
|
|
|
|
import { ReactComponent as UnreadPin } from "assets/icons/comments/unread-pin.svg";
|
2021-12-14 16:30:59 +00:00
|
|
|
// import { ReactComponent as DownArrow2 } from "assets/icons/comments/down-arrow.svg";
|
2021-05-20 12:03:08 +00:00
|
|
|
import { ReactComponent as Chat } from "assets/icons/comments/chat.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
import { ReactComponent as Unpin } from "assets/icons/comments/unpinIcon.svg";
|
2021-05-20 12:03:08 +00:00
|
|
|
import { ReactComponent as Reaction } from "assets/icons/comments/reaction.svg";
|
|
|
|
|
import { ReactComponent as Reaction2 } from "assets/icons/comments/reaction-2.svg";
|
2021-06-03 06:18:08 +00:00
|
|
|
import { ReactComponent as Upload } from "assets/icons/ads/upload.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
// import { ReactComponent as Download } from "assets/icons/ads/download.svg";
|
2021-07-07 09:30:06 +00:00
|
|
|
import { ReactComponent as ArrowForwardIcon } from "assets/icons/control/arrow_forward.svg";
|
2022-01-18 07:10:58 +00:00
|
|
|
import { ReactComponent as DoubleArrowRightIcon } from "assets/icons/ads/double-arrow-right.svg";
|
2021-07-07 09:30:06 +00:00
|
|
|
import { ReactComponent as CapSolidIcon } from "assets/icons/control/cap_solid.svg";
|
|
|
|
|
import { ReactComponent as CapDotIcon } from "assets/icons/control/cap_dot.svg";
|
|
|
|
|
import { ReactComponent as LineDottedIcon } from "assets/icons/control/line_dotted.svg";
|
|
|
|
|
import { ReactComponent as LineDashedIcon } from "assets/icons/control/line_dashed.svg";
|
2021-07-29 08:13:10 +00:00
|
|
|
import { ReactComponent as TableIcon } from "assets/icons/ads/tables.svg";
|
|
|
|
|
import { ReactComponent as ColumnIcon } from "assets/icons/ads/column.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
import { ReactComponent as GearIcon } from "assets/icons/ads/gear.svg";
|
|
|
|
|
import { ReactComponent as UserV2Icon } from "assets/icons/ads/user-v2.svg";
|
2021-09-07 09:15:11 +00:00
|
|
|
import { ReactComponent as SupportIcon } from "assets/icons/ads/support.svg";
|
2021-09-22 16:59:47 +00:00
|
|
|
import { ReactComponent as Snippet } from "assets/icons/ads/snippet.svg";
|
2021-10-04 15:34:37 +00:00
|
|
|
import { ReactComponent as WorkspaceIcon } from "assets/icons/ads/organizationIcon.svg";
|
2021-10-18 07:47:55 +00:00
|
|
|
import { ReactComponent as SettingIcon } from "assets/icons/control/settings.svg";
|
2021-11-16 09:27:38 +00:00
|
|
|
import { ReactComponent as DropdownIcon } from "assets/icons/ads/dropdown.svg";
|
2021-07-29 08:13:10 +00:00
|
|
|
|
2020-08-10 04:54:33 +00:00
|
|
|
import styled from "styled-components";
|
2020-09-01 07:24:53 +00:00
|
|
|
import { CommonComponentProps, Classes } from "./common";
|
2020-08-28 18:51:16 +00:00
|
|
|
import { noop } from "lodash";
|
2020-08-31 04:59:18 +00:00
|
|
|
import { theme } from "constants/DefaultTheme";
|
2020-10-14 10:35:19 +00:00
|
|
|
import Spinner from "./Spinner";
|
2021-03-17 20:36:26 +00:00
|
|
|
import { ControlIcons } from "icons/ControlIcons";
|
2020-08-10 04:54:33 +00:00
|
|
|
|
2021-10-04 15:34:37 +00:00
|
|
|
// remix icons
|
|
|
|
|
import AddMoreIcon from "remixicon-react/AddCircleLineIcon";
|
2022-01-05 18:59:24 +00:00
|
|
|
import AddMoreFillIcon from "remixicon-react/AddCircleFillIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import ArrowLeftRightIcon from "remixicon-react/ArrowLeftRightLineIcon";
|
2021-12-14 16:30:59 +00:00
|
|
|
import ArrowDownLineIcon from "remixicon-react/ArrowDownLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import BookIcon from "remixicon-react/BookOpenLineIcon";
|
|
|
|
|
import ChevronRight from "remixicon-react/ArrowRightSFillIcon";
|
2022-02-16 10:15:35 +00:00
|
|
|
import CheckLineIcon from "remixicon-react/CheckLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import CloseLineIcon from "remixicon-react/CloseLineIcon";
|
|
|
|
|
import CloseCircleIcon from "remixicon-react/CloseCircleFillIcon";
|
|
|
|
|
import CommentContextMenu from "remixicon-react/More2FillIcon";
|
|
|
|
|
import ContextMenuIcon from "remixicon-react/MoreFillIcon";
|
|
|
|
|
import CreateNewIcon from "remixicon-react/AddLineIcon";
|
2022-01-25 13:56:52 +00:00
|
|
|
import Database2Line from "remixicon-react/Database2LineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import DatasourceIcon from "remixicon-react/CloudFillIcon";
|
|
|
|
|
import DeleteBin7 from "remixicon-react/DeleteBin7LineIcon";
|
|
|
|
|
import DiscordIcon from "remixicon-react/DiscordLineIcon";
|
|
|
|
|
import DownArrow from "remixicon-react/ArrowDownSFillIcon";
|
|
|
|
|
import Download from "remixicon-react/DownloadCloud2LineIcon";
|
|
|
|
|
import DuplicateIcon from "remixicon-react/FileCopyLineIcon";
|
|
|
|
|
import EditIcon from "remixicon-react/PencilFillIcon";
|
2021-10-11 06:01:05 +00:00
|
|
|
import EditLineIcon from "remixicon-react/EditLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import Emoji from "remixicon-react/EmotionLineIcon";
|
|
|
|
|
import ExpandMore from "remixicon-react/ArrowDownSLineIcon";
|
|
|
|
|
import ExpandLess from "remixicon-react/ArrowUpSLineIcon";
|
|
|
|
|
import EyeOn from "remixicon-react/EyeLineIcon";
|
|
|
|
|
import EyeOff from "remixicon-react/EyeOffLineIcon";
|
|
|
|
|
import FileTransfer from "remixicon-react/FileTransferLineIcon";
|
|
|
|
|
import Filter from "remixicon-react/Filter2FillIcon";
|
|
|
|
|
import GitMerge from "remixicon-react/GitMergeLineIcon";
|
2021-11-16 10:24:38 +00:00
|
|
|
import GitCommit from "remixicon-react/GitCommitLineIcon";
|
|
|
|
|
import GitPullRequst from "remixicon-react/GitPullRequestLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import GuideIcon from "remixicon-react/GuideFillIcon";
|
|
|
|
|
import HelpIcon from "remixicon-react/QuestionMarkIcon";
|
2022-01-25 13:56:52 +00:00
|
|
|
import LightbulbFlashLine from "remixicon-react/LightbulbFlashLineIcon";
|
2021-12-07 07:59:32 +00:00
|
|
|
import InfoIcon from "remixicon-react/InformationLineIcon";
|
2022-01-07 06:08:17 +00:00
|
|
|
import KeyIcon from "remixicon-react/Key2LineIcon";
|
2021-11-08 05:41:42 +00:00
|
|
|
import LeftArrowIcon2 from "remixicon-react/ArrowLeftSLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import Link2 from "remixicon-react/LinkIcon";
|
2021-11-22 06:09:16 +00:00
|
|
|
import LeftArrowIcon from "remixicon-react/ArrowLeftLineIcon";
|
2022-02-16 10:15:35 +00:00
|
|
|
import More2FillIcon from "remixicon-react/More2FillIcon";
|
2021-11-22 06:09:16 +00:00
|
|
|
import NewsPaperLine from "remixicon-react/NewspaperLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import OvalCheck from "remixicon-react/CheckboxCircleLineIcon";
|
|
|
|
|
import OvalCheckFill from "remixicon-react/CheckboxCircleFillIcon";
|
|
|
|
|
import Pin3 from "remixicon-react/Pushpin2FillIcon";
|
2021-11-16 10:24:38 +00:00
|
|
|
import QueryIcon from "remixicon-react/CodeSSlashLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import RightArrowIcon from "remixicon-react/ArrowRightLineIcon";
|
2021-11-08 05:41:42 +00:00
|
|
|
import RightArrowIcon2 from "remixicon-react/ArrowRightSLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import RocketIcon from "remixicon-react/RocketLineIcon";
|
|
|
|
|
import ShareBoxFillIcon from "remixicon-react/ShareBoxFillIcon";
|
|
|
|
|
import ShareForwardIcon from "remixicon-react/ShareForwardFillIcon";
|
|
|
|
|
import Trash from "remixicon-react/DeleteBinLineIcon";
|
|
|
|
|
import UpArrow from "remixicon-react/ArrowUpSFillIcon";
|
|
|
|
|
import WarningIcon from "remixicon-react/ErrorWarningFillIcon";
|
2022-02-11 18:08:46 +00:00
|
|
|
import WarningLineIcon from "remixicon-react/ErrorWarningLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
import EditUnderlineIcon from "remixicon-react/EditLineIcon";
|
|
|
|
|
import LogoutIcon from "remixicon-react/LogoutBoxRLineIcon";
|
|
|
|
|
import ShareLineIcon from "remixicon-react/ShareLineIcon";
|
|
|
|
|
import DownArrowIcon from "remixicon-react/ArrowDownSLineIcon";
|
|
|
|
|
import LoaderLineIcon from "remixicon-react/LoaderLineIcon";
|
2021-11-16 10:24:38 +00:00
|
|
|
import WidgetIcon from "remixicon-react/FunctionLineIcon";
|
2021-11-11 07:49:25 +00:00
|
|
|
import RefreshLineIcon from "remixicon-react/RefreshLineIcon";
|
|
|
|
|
import GitBranchLineIcon from "remixicon-react/GitBranchLineIcon";
|
2022-01-25 13:56:52 +00:00
|
|
|
import EditBoxLineIcon from "remixicon-react/EditBoxLineIcon";
|
|
|
|
|
import StarLineIcon from "remixicon-react/StarLineIcon";
|
|
|
|
|
import StarFillIcon from "remixicon-react/StarFillIcon";
|
2021-12-14 16:30:59 +00:00
|
|
|
import Settings2LineIcon from "remixicon-react/Settings2LineIcon";
|
2022-02-18 09:51:02 +00:00
|
|
|
import FileListLineIcon from "remixicon-react/FileListLineIcon";
|
2022-02-17 16:38:36 +00:00
|
|
|
import HamburgerIcon from "remixicon-react/MenuLineIcon";
|
2022-02-16 10:15:35 +00:00
|
|
|
import MagicLineIcon from "remixicon-react/MagicLineIcon";
|
2021-10-04 15:34:37 +00:00
|
|
|
|
2020-08-31 04:59:18 +00:00
|
|
|
export enum IconSize {
|
2020-09-16 11:50:47 +00:00
|
|
|
XXS = "extraExtraSmall",
|
|
|
|
|
XS = "extraSmall",
|
2020-08-31 04:59:18 +00:00
|
|
|
SMALL = "small",
|
|
|
|
|
MEDIUM = "medium",
|
|
|
|
|
LARGE = "large",
|
|
|
|
|
XL = "extraLarge",
|
|
|
|
|
XXL = "extraExtraLarge",
|
|
|
|
|
XXXL = "extraExtraExtraLarge",
|
2021-10-20 07:38:17 +00:00
|
|
|
XXXXL = "extraExtraExtraExtraLarge",
|
2020-08-31 04:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-17 12:19:39 +00:00
|
|
|
const ICON_SIZE_LOOKUP = {
|
|
|
|
|
[IconSize.XXS]: theme.iconSizes.XXS,
|
|
|
|
|
[IconSize.XS]: theme.iconSizes.XS,
|
|
|
|
|
[IconSize.SMALL]: theme.iconSizes.SMALL,
|
|
|
|
|
[IconSize.MEDIUM]: theme.iconSizes.MEDIUM,
|
|
|
|
|
[IconSize.LARGE]: theme.iconSizes.LARGE,
|
|
|
|
|
[IconSize.XL]: theme.iconSizes.XL,
|
|
|
|
|
[IconSize.XXL]: theme.iconSizes.XXL,
|
|
|
|
|
[IconSize.XXXL]: theme.iconSizes.XXXL,
|
|
|
|
|
[IconSize.XXXXL]: theme.iconSizes.XXXXL,
|
|
|
|
|
undefined: theme.iconSizes.SMALL,
|
2020-08-31 04:59:18 +00:00
|
|
|
};
|
|
|
|
|
|
2022-02-17 12:19:39 +00:00
|
|
|
export const sizeHandler = (size?: IconSize): number => {
|
|
|
|
|
return (
|
|
|
|
|
ICON_SIZE_LOOKUP[size as keyof typeof ICON_SIZE_LOOKUP] ||
|
|
|
|
|
theme.iconSizes.SMALL
|
|
|
|
|
);
|
|
|
|
|
};
|
2020-08-10 04:54:33 +00:00
|
|
|
|
2021-02-04 07:02:36 +00:00
|
|
|
export const IconWrapper = styled.span<IconProps>`
|
2020-08-10 04:54:33 +00:00
|
|
|
&:focus {
|
|
|
|
|
outline: none;
|
|
|
|
|
}
|
2022-02-17 12:19:39 +00:00
|
|
|
|
2020-08-14 07:11:38 +00:00
|
|
|
display: flex;
|
2020-10-12 07:15:35 +00:00
|
|
|
align-items: center;
|
2022-02-17 12:19:39 +00:00
|
|
|
|
2020-08-10 04:54:33 +00:00
|
|
|
svg {
|
2020-12-24 04:32:25 +00:00
|
|
|
width: ${(props) => sizeHandler(props.size)}px;
|
|
|
|
|
height: ${(props) => sizeHandler(props.size)}px;
|
2021-04-23 13:50:55 +00:00
|
|
|
${(props) =>
|
|
|
|
|
!props.keepColors
|
|
|
|
|
? `
|
2021-10-12 05:44:47 +00:00
|
|
|
fill: ${props.fillColor || ""};
|
|
|
|
|
circle {
|
|
|
|
|
fill: ${props.fillColor || ""};
|
|
|
|
|
}
|
|
|
|
|
path {
|
|
|
|
|
fill: ${props.fillColor || ""};
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
: ""};
|
|
|
|
|
${(props) => (props.invisible ? `visibility: hidden;` : null)};
|
2022-02-17 12:19:39 +00:00
|
|
|
|
2021-10-12 05:44:47 +00:00
|
|
|
&:hover {
|
|
|
|
|
cursor: ${(props) => (props.clickable ? "pointer" : "default")};
|
|
|
|
|
${(props) =>
|
|
|
|
|
!props.keepColors
|
|
|
|
|
? `
|
|
|
|
|
fill: ${props.hoverFillColor || ""};
|
|
|
|
|
path {
|
|
|
|
|
fill: ${props.hoverFillColor || ""};
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
: ""}
|
2021-04-23 13:50:55 +00:00
|
|
|
}
|
2020-08-17 03:25:35 +00:00
|
|
|
}
|
2020-08-10 04:54:33 +00:00
|
|
|
`;
|
|
|
|
|
|
2022-02-17 12:19:39 +00:00
|
|
|
function getControlIcon(iconName: string) {
|
|
|
|
|
const ControlIcon = ControlIcons[iconName];
|
|
|
|
|
return <ControlIcon height={24} width={24} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ICON_LOOKUP = {
|
|
|
|
|
undefined: null,
|
|
|
|
|
HEADING_ONE: getControlIcon("HEADING_ONE"),
|
|
|
|
|
HEADING_THREE: getControlIcon("HEADING_THREE"),
|
|
|
|
|
HEADING_TWO: getControlIcon("HEADING_TWO"),
|
|
|
|
|
PARAGRAPH: getControlIcon("PARAGRAPH"),
|
|
|
|
|
PARAGRAPH_TWO: getControlIcon("PARAGRAPH_TWO"),
|
|
|
|
|
"add-more": <AddMoreIcon />,
|
|
|
|
|
"add-more-fill": <AddMoreFillIcon />,
|
|
|
|
|
"arrow-forward": <ArrowForwardIcon />,
|
|
|
|
|
"arrow-left": <ArrowLeft />,
|
|
|
|
|
"book-line": <BookLineIcon />,
|
|
|
|
|
"cap-dot": <CapDotIcon />,
|
|
|
|
|
"cap-solid": <CapSolidIcon />,
|
|
|
|
|
"card-context-menu": <CardContextMenu />,
|
|
|
|
|
"check-line": <CheckLineIcon />,
|
|
|
|
|
"chevron-left": <ChevronLeft />,
|
|
|
|
|
"chevron-right": <ChevronRight />,
|
|
|
|
|
"close-circle": <CloseCircleIcon />,
|
|
|
|
|
"close-modal": <CloseLineIcon />,
|
|
|
|
|
"close-x": <CloseLineIcon />,
|
|
|
|
|
"comment-context-menu": <CommentContextMenu />,
|
|
|
|
|
"context-menu": <ContextMenuIcon />,
|
|
|
|
|
"database-2-line": <Database2Line />,
|
|
|
|
|
"delete-blank": <DeleteBin7 />,
|
|
|
|
|
"double-arrow-right": <DoubleArrowRightIcon />,
|
|
|
|
|
"down-arrow": <DownArrowIcon />,
|
|
|
|
|
"down-arrow-2": <ArrowDownLineIcon />,
|
|
|
|
|
"edit-box-line": <EditBoxLineIcon />,
|
|
|
|
|
"edit-line": <EditLineIcon />,
|
|
|
|
|
"edit-underline": <EditUnderlineIcon />,
|
|
|
|
|
"expand-less": <ExpandLess />,
|
|
|
|
|
"expand-more": <ExpandMore />,
|
|
|
|
|
"eye-off": <EyeOff />,
|
|
|
|
|
"eye-on": <EyeOn />,
|
2022-03-03 10:56:53 +00:00
|
|
|
"fork-2": <Fork2Icon />,
|
2022-02-17 12:19:39 +00:00
|
|
|
"file-transfer": <FileTransfer />,
|
|
|
|
|
"git-branch": <GitBranchLineIcon />,
|
|
|
|
|
"git-commit": <GitCommit />,
|
|
|
|
|
"git-pull-request": <GitPullRequst />,
|
|
|
|
|
"invite-user": <InviteUserIcon />,
|
|
|
|
|
"left-arrow-2": <LeftArrowIcon2 />,
|
|
|
|
|
"lightbulb-flash-line": <LightbulbFlashLine />,
|
|
|
|
|
"line-dashed": <LineDashedIcon />,
|
|
|
|
|
"line-dotted": <LineDottedIcon />,
|
|
|
|
|
"link-2": <Link2 />,
|
|
|
|
|
"magic-line": <MagicLineIcon />,
|
|
|
|
|
"more-2-fill": <More2FillIcon />,
|
|
|
|
|
"news-paper": <NewsPaperLine />,
|
|
|
|
|
"no-response": <NoResponseIcon />,
|
|
|
|
|
"oval-check": <OvalCheck />,
|
|
|
|
|
"oval-check-fill": <OvalCheckFill />,
|
|
|
|
|
"pin-3": <Pin3 />,
|
|
|
|
|
"reaction-2": <Reaction2 />,
|
|
|
|
|
"read-pin": <ReadPin />,
|
|
|
|
|
"right-arrow": <RightArrowIcon />,
|
|
|
|
|
"right-arrow-2": <RightArrowIcon2 />,
|
|
|
|
|
"send-button": <SendButton />,
|
|
|
|
|
"settings-2-line": <Settings2LineIcon />,
|
|
|
|
|
"share-2": <ShareIcon2 />,
|
|
|
|
|
"share-box": <ShareBoxFillIcon />,
|
|
|
|
|
"share-line": <ShareLineIcon />,
|
|
|
|
|
"star-fill": <StarFillIcon />,
|
|
|
|
|
"star-line": <StarLineIcon />,
|
|
|
|
|
"swap-horizontal": <ArrowLeftRightIcon />,
|
|
|
|
|
"trash-outline": <TrashOutline />,
|
|
|
|
|
"trending-flat": <TrendingFlat />,
|
|
|
|
|
"unread-pin": <UnreadPin />,
|
|
|
|
|
"user-2": <UserV2Icon />,
|
|
|
|
|
"view-all": <RightArrowIcon />,
|
|
|
|
|
"view-less": <LeftArrowIcon />,
|
|
|
|
|
"warning-line": <WarningLineIcon />,
|
|
|
|
|
"warning-triangle": <WarningTriangleIcon />,
|
|
|
|
|
billing: <BillingIcon />,
|
|
|
|
|
book: <BookIcon />,
|
|
|
|
|
bug: <BugIcon />,
|
|
|
|
|
cancel: <CancelIcon />,
|
|
|
|
|
chat: <Chat />,
|
|
|
|
|
close: <CloseIcon />,
|
|
|
|
|
column: <ColumnIcon />,
|
|
|
|
|
cross: <CrossIcon />,
|
|
|
|
|
danger: <ErrorIcon />,
|
|
|
|
|
datasource: <DatasourceIcon />,
|
|
|
|
|
delete: <Trash />,
|
|
|
|
|
desktop: <DesktopIcon />,
|
|
|
|
|
discord: <DiscordIcon />,
|
|
|
|
|
downArrow: <DownArrow />,
|
|
|
|
|
download: <Download />,
|
|
|
|
|
dropdown: <DropdownIcon />,
|
|
|
|
|
duplicate: <DuplicateIcon />,
|
|
|
|
|
edit: <EditIcon />,
|
|
|
|
|
emoji: <Emoji />,
|
|
|
|
|
enterprise: <MagicLineIcon />,
|
|
|
|
|
error: <ErrorIcon />,
|
|
|
|
|
filter: <Filter />,
|
|
|
|
|
fluid: <FluidIcon />,
|
|
|
|
|
fork: <GitMerge />,
|
|
|
|
|
gear: <GearIcon />,
|
|
|
|
|
general: <GeneralIcon />,
|
|
|
|
|
guide: <GuideIcon />,
|
|
|
|
|
help: <HelpIcon />,
|
|
|
|
|
info: <InfoIcon />,
|
|
|
|
|
key: <KeyIcon />,
|
|
|
|
|
lightning: <LightningIcon />,
|
|
|
|
|
link: <LinkIcon />,
|
|
|
|
|
loader: <LoaderLineIcon />,
|
|
|
|
|
logout: <LogoutIcon />,
|
|
|
|
|
manage: <ManageIcon />,
|
|
|
|
|
mobile: <MobileIcon />,
|
|
|
|
|
open: <OpenIcon />,
|
|
|
|
|
pin: <Pin />,
|
|
|
|
|
play: <PlayIcon />,
|
|
|
|
|
plus: <CreateNewIcon />,
|
|
|
|
|
query: <QueryIcon />,
|
|
|
|
|
reaction: <Reaction />,
|
|
|
|
|
refresh: <RefreshLineIcon />,
|
|
|
|
|
rocket: <RocketIcon />,
|
|
|
|
|
search: <SearchIcon />,
|
|
|
|
|
setting: <SettingIcon />,
|
|
|
|
|
share: <ShareForwardIcon />,
|
|
|
|
|
shine: <ShineIcon />,
|
|
|
|
|
snippet: <Snippet />,
|
|
|
|
|
success: <SuccessIcon />,
|
|
|
|
|
support: <SupportIcon />,
|
|
|
|
|
tables: <TableIcon />,
|
|
|
|
|
tablet: <TabletIcon />,
|
|
|
|
|
trash: <Trash />,
|
|
|
|
|
unpin: <Unpin />,
|
|
|
|
|
upArrow: <UpArrow />,
|
|
|
|
|
upload: <Upload />,
|
|
|
|
|
user: <UserIcon />,
|
|
|
|
|
wand: <WandIcon />,
|
|
|
|
|
warning: <WarningIcon />,
|
|
|
|
|
widget: <WidgetIcon />,
|
|
|
|
|
workspace: <WorkspaceIcon />,
|
2022-02-18 09:51:02 +00:00
|
|
|
"file-list-line": <FileListLineIcon />,
|
2022-02-17 16:38:36 +00:00
|
|
|
hamburger: <HamburgerIcon />,
|
2022-02-17 12:19:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const IconCollection = Object.keys(ICON_LOOKUP);
|
|
|
|
|
|
|
|
|
|
export type IconName = typeof IconCollection[number];
|
|
|
|
|
|
2020-08-10 04:54:33 +00:00
|
|
|
export type IconProps = {
|
2020-08-31 04:59:18 +00:00
|
|
|
size?: IconSize;
|
2020-08-10 04:54:33 +00:00
|
|
|
name?: IconName;
|
|
|
|
|
invisible?: boolean;
|
2020-08-26 07:18:04 +00:00
|
|
|
className?: string;
|
2021-02-11 12:54:00 +00:00
|
|
|
onClick?: (e: React.MouseEvent) => void;
|
2021-01-19 06:17:15 +00:00
|
|
|
fillColor?: string;
|
2021-05-20 12:03:08 +00:00
|
|
|
hoverFillColor?: string;
|
2021-04-23 13:50:55 +00:00
|
|
|
keepColors?: boolean;
|
2021-07-29 08:13:10 +00:00
|
|
|
loaderWithIconWrapper?: boolean;
|
|
|
|
|
clickable?: boolean;
|
2020-08-10 04:54:33 +00:00
|
|
|
};
|
|
|
|
|
|
2020-10-14 10:35:19 +00:00
|
|
|
const Icon = forwardRef(
|
|
|
|
|
(props: IconProps & CommonComponentProps, ref: Ref<HTMLSpanElement>) => {
|
2022-02-17 12:19:39 +00:00
|
|
|
const iconName = props.name;
|
|
|
|
|
const returnIcon =
|
|
|
|
|
ICON_LOOKUP[iconName as keyof typeof ICON_LOOKUP] || null;
|
2021-07-29 08:13:10 +00:00
|
|
|
|
|
|
|
|
const clickable = props.clickable === undefined ? true : props.clickable;
|
|
|
|
|
|
|
|
|
|
let loader = <Spinner size={props.size} />;
|
|
|
|
|
if (props.loaderWithIconWrapper) {
|
|
|
|
|
loader = (
|
|
|
|
|
<IconWrapper className={Classes.ICON} clickable={clickable} {...props}>
|
|
|
|
|
<Spinner size={props.size} />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-14 10:35:19 +00:00
|
|
|
return returnIcon && !props.isLoading ? (
|
|
|
|
|
<IconWrapper
|
2021-10-04 15:34:37 +00:00
|
|
|
className={`${Classes.ICON} ${props.className}`}
|
2021-07-29 08:13:10 +00:00
|
|
|
clickable={clickable}
|
2020-10-14 10:35:19 +00:00
|
|
|
data-cy={props.cypressSelector}
|
|
|
|
|
ref={ref}
|
|
|
|
|
{...props}
|
|
|
|
|
onClick={props.onClick || noop}
|
|
|
|
|
>
|
|
|
|
|
{returnIcon}
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
) : props.isLoading ? (
|
2021-07-29 08:13:10 +00:00
|
|
|
loader
|
2020-10-14 10:35:19 +00:00
|
|
|
) : null;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Icon.displayName = "Icon";
|
2020-08-26 07:18:04 +00:00
|
|
|
|
|
|
|
|
export default Icon;
|