diff --git a/packages/studio-components/src/EmptyCanvas/image.tsx b/packages/studio-components/src/EmptyCanvas/image.tsx index 58b003154..cc1ce516b 100644 --- a/packages/studio-components/src/EmptyCanvas/image.tsx +++ b/packages/studio-components/src/EmptyCanvas/image.tsx @@ -1,14 +1,16 @@ import React from 'react'; +import { theme } from 'antd'; -export default ({ isDark }: { isDark: boolean }) => { - const stroke = isDark ? '#272727' : '#E6E9EE'; +export default () => { + const { token } = theme.useToken(); + const stroke = token.colorBgBase; return ( diff --git a/packages/studio-components/src/EmptyCanvas/index.tsx b/packages/studio-components/src/EmptyCanvas/index.tsx index b99d20c6e..2cb4c5188 100644 --- a/packages/studio-components/src/EmptyCanvas/index.tsx +++ b/packages/studio-components/src/EmptyCanvas/index.tsx @@ -1,18 +1,19 @@ import * as React from 'react'; -import { Typography } from 'antd'; +import { Typography, theme, Flex } from 'antd'; import Image from './image'; -import { isDarkTheme } from '../Utils'; + interface IEmptyProps { description?: string | React.ReactNode; - isLight?: boolean; } const Empty: React.FunctionComponent = props => { - const { description, isLight } = props; - const isDark = isLight || isDarkTheme(); + const { description } = props; return ( -
= props => { alignItems: 'center', }} > - + = props => { > {description} -
+ ); }; diff --git a/packages/studio-components/src/Icons/FileYaml.tsx b/packages/studio-components/src/Icons/FileYaml.tsx index 927a07afc..05501525b 100644 --- a/packages/studio-components/src/Icons/FileYaml.tsx +++ b/packages/studio-components/src/Icons/FileYaml.tsx @@ -1,6 +1,8 @@ import React from 'react'; +import { theme } from 'antd'; const FileYaml = ({ style = {} }: { style?: React.CSSProperties }) => { - const { fontSize = '16px', color = '#000' } = style as { fontSize: string; color: string }; + const { token } = theme.useToken(); + const { fontSize = 16, color = token.colorText } = style; return ( = props => { sideStyle = {}, github = 'https://github.com/GraphScope/portal', sideMenu, - style, + style = {}, collapsedConfig = {}, onMenuClick, } = props; const { width = 220, collapsedWidth = 56 } = sideStyle; const activeKey = getCurrentNav(); + const { token } = theme.useToken(); const leftSideCollapsed = collapsedConfig[activeKey] || false; return (
diff --git a/packages/studio-importor/src/app/elements/arrow-marker/index.tsx b/packages/studio-importor/src/app/elements/arrow-marker/index.tsx index 920821836..74b689c49 100644 --- a/packages/studio-importor/src/app/elements/arrow-marker/index.tsx +++ b/packages/studio-importor/src/app/elements/arrow-marker/index.tsx @@ -1,7 +1,6 @@ import React, { useEffect } from 'react'; -import ReactDOM from 'react-dom'; + import { theme } from 'antd'; -const { useToken } = theme; interface IArrowMarkerProps { selectedColor?: string; @@ -9,7 +8,8 @@ interface IArrowMarkerProps { } const ArrowMarker: React.FunctionComponent = props => { - const { selectedColor = 'red', color = '#000' } = props; + const { token } = theme.useToken(); + const { selectedColor = token.colorPrimary, color = token.colorText } = props; return ( { const GraphEditor: React.FunctionComponent = props => { const { store, onDoubleClick, onEdgesChange, onNodesChange, onConnectStart, onConnectEnd, onReactFlowInit } = useInteractive(); - const { nodes, edges, theme, collapsed, appMode, nodePositionChange } = store; + const { nodes, edges, collapsed, appMode, nodePositionChange } = store; const [state, updateState] = useState({ isLocked: false, }); - const { isLight } = useStudioProvier(); + const { token } = theme.useToken(); + const isEmpty = nodes.length === 0; - const rfBG = !isLight ? '#161616' : collapsed.left && collapsed.right ? '#fff' : '#f4f5f5'; + const description = ( = props => { return (
-
+
= props => { minZoom={0.01} onInit={onReactFlowInit} > - - - {!IS_PURE && ( - - )} - {isEmpty && } - {!IS_PURE && } + + {!IS_PURE && } + {isEmpty && } + {!IS_PURE && }
diff --git a/packages/studio-website/src/app.tsx b/packages/studio-website/src/app.tsx index 518d10baf..24f8947cf 100644 --- a/packages/studio-website/src/app.tsx +++ b/packages/studio-website/src/app.tsx @@ -1,19 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; -import Pages from './pages'; -import { installSlot, unInstallSlot } from './slots'; - -import { Utils } from '@graphscope/studio-components'; - -import { ROUTES, SIDE_MENU } from '@graphscope/graphy-website'; - -if (Utils.storage.get('PORTAL_PLUGIN_GRAPHY')) { - installSlot('SIDE_MEU', 'graphy', SIDE_MENU); - installSlot('ROUTES', 'graphy', ROUTES); -} else { - unInstallSlot('SIDE_MEU', 'graphy'); - unInstallSlot('ROUTES', 'graphy'); -} +import PortalSite from './index'; const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); -root.render(); +root.render(); diff --git a/packages/studio-website/src/index.tsx b/packages/studio-website/src/index.tsx index 84e451a32..feadc863c 100644 --- a/packages/studio-website/src/index.tsx +++ b/packages/studio-website/src/index.tsx @@ -1,4 +1,29 @@ import GraphScopePortal from './pages'; export { installSlot, unInstallSlot, getSlots } from './slots'; +import { installSlot, unInstallSlot } from './slots'; + +import { Utils } from '@graphscope/studio-components'; + +import { ROUTES as GRAPHY_ROUTES, SIDE_MENU as GRAPGY_SIDE_MENU } from '@graphscope/graphy-website'; +import { ROUTES } from './pages/index'; +import { SIDE_MENU } from './layouts/const'; +import { togglePlugin } from './pages/explore/slot'; + +/** Portal 内置模块 */ +installSlot('SIDE_MEU', 'studio', SIDE_MENU); +installSlot('ROUTES', 'studio', ROUTES); + +/** Explore 模块 */ +togglePlugin(); + +/** 实验性质的模块:Graphy */ +if (Utils.storage.get('PORTAL_PLUGIN_GRAPHY')) { + installSlot('SIDE_MEU', 'graphy', GRAPGY_SIDE_MENU); + installSlot('ROUTES', 'graphy', GRAPHY_ROUTES); +} else { + unInstallSlot('SIDE_MEU', 'graphy'); + unInstallSlot('ROUTES', 'graphy'); +} + export default GraphScopePortal; diff --git a/packages/studio-website/src/layouts/const.tsx b/packages/studio-website/src/layouts/const.tsx index 44a7ac733..886598315 100644 --- a/packages/studio-website/src/layouts/const.tsx +++ b/packages/studio-website/src/layouts/const.tsx @@ -8,9 +8,7 @@ import { faDiagramProject, faListCheck, faPuzzlePiece, - faBell, faCoins, - faMagnifyingGlassChart, } from '@fortawesome/free-solid-svg-icons'; import { MenuProps } from 'antd'; @@ -41,12 +39,6 @@ export const TOOLS_MENU = [ value: '/querying', icon: , }, - { - label: , - key: '/explore', - value: '/explore', - icon: , - }, ]; export const SYSTEM_MENU = [ diff --git a/packages/studio-website/src/layouts/index.tsx b/packages/studio-website/src/layouts/index.tsx index 41e22f99a..324c78a74 100644 --- a/packages/studio-website/src/layouts/index.tsx +++ b/packages/studio-website/src/layouts/index.tsx @@ -102,7 +102,6 @@ export default function StudioLayout() { const _SIDE = getSlots('SIDE_MEU'); - const { layoutBackground } = useCustomToken(); const handleMenuClick = key => { if (key === '/querying' || key === '/importing' || key === '/modeling') { updateStore(draft => { @@ -121,7 +120,6 @@ export default function StudioLayout() { { - const { store, id } = useContext(); - const { token } = theme.useToken(); return (
, + key: '/explore', + value: '/explore', + icon: , + }, +]; + +export const ROUTES = [{ path: '/explore', component: React.lazy(() => import('./index')) }].map((item, index) => { + const { path, component: Component } = item; + return ( + }> + {/** @ts-ignore */} + + + } + /> + ); +}); + +export const PLUGIN_ID = 'EXPLORE'; +export const PLUGIN_LOCAL_STORAGE_KEY = `PORTAL_PLUGIN_${PLUGIN_ID}`; + +/** 实验性质的模块:Explore */ + +export function togglePlugin(enable?: boolean) { + let _enable = enable; + if (enable === undefined) { + _enable = Utils.storage.get(PLUGIN_LOCAL_STORAGE_KEY) || false; + } + + if (_enable) { + installSlot('SIDE_MEU', PLUGIN_ID, SIDE_MENU); + installSlot('ROUTES', PLUGIN_ID, ROUTES); + } else { + unInstallSlot('SIDE_MEU', PLUGIN_ID); + unInstallSlot('ROUTES', PLUGIN_ID); + } + Utils.storage.set(PLUGIN_LOCAL_STORAGE_KEY, _enable); + return _enable; +} diff --git a/packages/studio-website/src/pages/index.tsx b/packages/studio-website/src/pages/index.tsx index 6f47310fa..4fab69b48 100644 --- a/packages/studio-website/src/pages/index.tsx +++ b/packages/studio-website/src/pages/index.tsx @@ -4,8 +4,8 @@ import { StudioProvier, GlobalSpin } from '@graphscope/studio-components'; import Layout from '../layouts'; import StoreProvider from '@graphscope/use-zustand'; import { initialStore } from '../layouts/useContext'; -import { getSlots, installSlot } from '../slots'; -import { SIDE_MENU } from '../layouts/const'; +import { getSlots } from '../slots'; + import locales from '../locales'; interface IPagesProps { @@ -20,7 +20,6 @@ const routes = [ { path: '/modeling', component: React.lazy(() => import('./modeling')) }, { path: '/importing', component: React.lazy(() => import('./importing')) }, { path: '/querying', component: React.lazy(() => import('./query')) }, - { path: '/explore', component: React.lazy(() => import('./explore')) }, { path: '/setting', component: React.lazy(() => import('./setting')) }, { path: '/job', component: React.lazy(() => import('./job')) }, @@ -46,9 +45,6 @@ export const ROUTES = routes.map(({ path, redirect, component: Component }, inde /> ); }); -/** 注册默认的 */ -installSlot('SIDE_MEU', 'studio', SIDE_MENU); -installSlot('ROUTES', 'studio', ROUTES); const Pages: React.FunctionComponent = props => { const { children } = props; diff --git a/packages/studio-website/src/pages/setting/index.tsx b/packages/studio-website/src/pages/setting/index.tsx index 7f168c5fb..f7d07fb3c 100644 --- a/packages/studio-website/src/pages/setting/index.tsx +++ b/packages/studio-website/src/pages/setting/index.tsx @@ -10,6 +10,7 @@ import QuerySetting from './query-setting'; import { FormattedMessage } from 'react-intl'; import Coordinator from './coordinator'; import GraphyPlugin from './plugins/graphy'; +import ExplorePlugin from './plugins/explore'; const Setting: React.FunctionComponent = () => { return ( @@ -69,7 +70,11 @@ const Setting: React.FunctionComponent = () => { } > - + + + + + diff --git a/packages/studio-website/src/pages/setting/plugins/explore.tsx b/packages/studio-website/src/pages/setting/plugins/explore.tsx new file mode 100644 index 000000000..ed1ca4cde --- /dev/null +++ b/packages/studio-website/src/pages/setting/plugins/explore.tsx @@ -0,0 +1,37 @@ +import * as React from 'react'; +import { Typography, Tooltip, Switch, Input, Flex, Space, Card } from 'antd'; +import { QuestionCircleOutlined } from '@ant-design/icons'; +import { togglePlugin } from '../../explore/slot'; +export const PLUGIN_ID = 'EXPLORE'; +export const PLUGIN_LOCAL_STORAGE_KEY = `PORTAL_PLUGIN_${PLUGIN_ID}`; + +const ExplorePlugin = () => { + const defaultChecked = togglePlugin(); + const onChange = (checked: boolean) => { + togglePlugin(checked); + window.location.reload(); + }; + + return ( + + + + Explore + + + + + + + Explor is a tool that allows you to explore the graph data in a more visual way. + + + Enable: + + + + + ); +}; + +export default ExplorePlugin; diff --git a/packages/studio-website/src/pages/setting/plugins/graphy.tsx b/packages/studio-website/src/pages/setting/plugins/graphy.tsx index 8ebaddf1a..e68dfbf46 100644 --- a/packages/studio-website/src/pages/setting/plugins/graphy.tsx +++ b/packages/studio-website/src/pages/setting/plugins/graphy.tsx @@ -4,7 +4,6 @@ import { QuestionCircleOutlined } from '@ant-design/icons'; import { Utils, Illustration } from '@graphscope/studio-components'; import { ROUTES, SIDE_MENU } from '@graphscope/graphy-website'; import { installSlot, unInstallSlot } from '../../../slots'; -import { useContext } from '../../../layouts/useContext'; interface IGraphyPluginProps {} @@ -27,12 +26,7 @@ const GraphyPlugin: React.FunctionComponent = props => { }; return ( - - {/* */} - + Graphy'ourData