diff --git a/package-lock.json b/package-lock.json index 8760cd96e..77426a12e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1149,14 +1149,15 @@ "to-fast-properties": "^2.0.0" } }, - "@bastinjafari/react-flow-chart": { + "@bastinjafari/react-flow-chart-with-tooltips-and-multi-select": { "version": "0.0.14", - "resolved": "https://registry.npmjs.org/@bastinjafari/react-flow-chart/-/react-flow-chart-0.0.14.tgz", - "integrity": "sha512-VM48gHmswwXP46Ci6gelOawhA25fQ4/RHPpkG072fa8GQFYjzLL7kYwuPbBL7VCdzp/JMz1aGOBjXu/NsXXErA==", + "resolved": "https://registry.npmjs.org/@bastinjafari/react-flow-chart-with-tooltips-and-multi-select/-/react-flow-chart-with-tooltips-and-multi-select-0.0.14.tgz", + "integrity": "sha512-10Bz6+JbIJGDu1L2+HLtXuKEZuh6g8Z7/dmycMwyY/OytmcRbd2mZTAfMKKRm7lYqs4uGW2W9qAofo+GtOxhbQ==", "requires": { "pathfinding": "^0.4.18", "react-draggable": "^4.4.3", "react-resize-observer": "^1.1.1", + "react-tooltip": "^4.2.10", "react-zoom-pan-pinch": "^1.6.1", "uuid": "^3.3.2" } @@ -15001,6 +15002,22 @@ "refractor": "^2.4.1" } }, + "react-tooltip": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/react-tooltip/-/react-tooltip-4.2.10.tgz", + "integrity": "sha512-D7ZLx6/QwpUl0SZRek3IZy/HWpsEEp0v3562tcT8IwZgu8IgV7hY5ZzniTkHyRcuL+IQnljpjj7A7zCgl2+T3w==", + "requires": { + "prop-types": "^15.7.2", + "uuid": "^7.0.3" + }, + "dependencies": { + "uuid": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", + "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==" + } + } + }, "react-transition-group": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.1.tgz", diff --git a/package.json b/package.json index 271735af3..9bbf70dbc 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "homepage": "https://dashboard.jina.ai", "dependencies": { - "@bastinjafari/react-flow-chart": "0.0.14", + "@bastinjafari/react-flow-chart-with-tooltips-and-multi-select": "0.0.14", "@emotion/core": "^10.0.35", "@emotion/styled": "^10.0.27", "@projectstorm/react-diagrams": "^6.0.1-beta.7", @@ -93,7 +93,7 @@ } }, "lint-staged": { - "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [ + "src/**/*.{js,jsx,ts,tsx,json,md}": [ "prettier --write", "eslint --max-warnings=0" ] diff --git a/src/App.css b/src/App.css index 5aa6b39af..fbd19ca96 100644 --- a/src/App.css +++ b/src/App.css @@ -743,4 +743,20 @@ code { height: 100%; width: 100%; border-radius: 0.625rem; -} \ No newline at end of file +} + +.tooltip-container { + display: flex; + align-items: center; + justify-content: center; +} + +.tooltip-icon { + height: 50px; + width: auto; + margin-right: 15px; +} + +.tooltip-text { + width: 150px; +} diff --git a/src/components/FlowChart/Sidebar.tsx b/src/components/FlowChart/Sidebar.tsx index 3b4c55533..b8cf34671 100644 --- a/src/components/FlowChart/Sidebar.tsx +++ b/src/components/FlowChart/Sidebar.tsx @@ -2,7 +2,11 @@ import React, { useState, useEffect } from "react"; import SidebarItem from "./SidebarItem"; import defaultPods from "../../data/defaultPods.json"; import _ from "lodash"; -import { IChart, ILink, INode } from "@bastinjafari/react-flow-chart"; +import { + IChart, + ILink, + INode, +} from "@bastinjafari/react-flow-chart-with-tooltips-and-multi-select"; import { Button, FormControl, Card } from "react-bootstrap"; interface Node extends INode { diff --git a/src/components/FlowChart/SidebarItem.tsx b/src/components/FlowChart/SidebarItem.tsx index ed0a78831..bcd1e7283 100644 --- a/src/components/FlowChart/SidebarItem.tsx +++ b/src/components/FlowChart/SidebarItem.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { REACT_FLOW_CHART } from "@bastinjafari/react-flow-chart"; +import { REACT_FLOW_CHART } from "@bastinjafari/react-flow-chart-with-tooltips-and-multi-select"; import ChartNode from "./ChartNode"; type Props = { diff --git a/src/components/FlowChart/Tooltip.tsx b/src/components/FlowChart/Tooltip.tsx new file mode 100644 index 000000000..a5ead31be --- /dev/null +++ b/src/components/FlowChart/Tooltip.tsx @@ -0,0 +1,11 @@ +import React from "react"; +import { ITooltipComponentDefaultProps } from "@bastinjafari/react-flow-chart-with-tooltips-and-multi-select"; + +export default function Tooltip(props: ITooltipComponentDefaultProps) { + return ( +
+ Tooltip Icon + {props.tooltip} +
+ ); +} diff --git a/src/data/tooltipConfig.ts b/src/data/tooltipConfig.ts new file mode 100644 index 000000000..1776e7be9 --- /dev/null +++ b/src/data/tooltipConfig.ts @@ -0,0 +1,7 @@ +export const tooltipConfig = { + tooltipsGlobal: { + showTooltip: true, + toogleOffWhenClicked: "global", + text: "Hold Shift and click to select multiple nodes", + }, +}; diff --git a/src/views/FlowView.tsx b/src/views/FlowView.tsx index 72ae081c5..db2d27736 100644 --- a/src/views/FlowView.tsx +++ b/src/views/FlowView.tsx @@ -1,7 +1,7 @@ import React from "react"; import { cloneDeep } from "lodash"; -import { FlowChart } from "@bastinjafari/react-flow-chart"; -import * as actions from "@bastinjafari/react-flow-chart/src/container/actions"; +import { FlowChart } from "@bastinjafari/react-flow-chart-with-tooltips-and-multi-select"; +import * as actions from "@bastinjafari/react-flow-chart-with-tooltips-and-multi-select/src/container/actions"; import { Container, Row, Card } from "shards-react"; import { Dispatcher, Constants, Store } from "../flux"; import { PageTitle } from "../components/Common/PageTitle"; @@ -14,6 +14,9 @@ import CustomPort from "../components/FlowChart/NodePort"; import FlowSelection from "../components/FlowChart/FlowSelection"; import { formatAsYAML, copyToClipboard } from "../helpers"; +import Tooltip from "../components/FlowChart/Tooltip"; +import { tooltipConfig } from "../data/tooltipConfig"; + const syncEvents = [ "onDragNodeStop", "onCanvasDrop", @@ -28,6 +31,10 @@ class FlowView extends React.Component { constructor(props: any) { super(props); const { flow: chart, type: flowType } = Store.getFlowchart(); + const chartWithTooltips = { + ...chart, + ...tooltipConfig, + }; const selectedFlowId = Store.getSelectedFlowId(); const flows = Store.getFlows(); const connected = Store.getConnectionStatus(); @@ -36,7 +43,7 @@ class FlowView extends React.Component { availableProperties, flowType, connected, - chart, + chart: { ...chartWithTooltips }, selectedFlowId, flows, showOverlay: false, @@ -270,6 +277,7 @@ class FlowView extends React.Component {