Added background toggle functionality across multiple components (AgentflowCanvas, MarketplaceCanvas, Canvas) with new icons for enabling/disabling background.

This commit is contained in:
Henry 2025-10-06 13:52:07 +01:00
parent a38d37f4b5
commit 46abfa26c2
5 changed files with 52 additions and 10 deletions

View File

@ -72,7 +72,6 @@ const AccountSettings = () => {
const [isLoading, setLoading] = useState(true) const [isLoading, setLoading] = useState(true)
const [profileName, setProfileName] = useState('') const [profileName, setProfileName] = useState('')
const [email, setEmail] = useState('') const [email, setEmail] = useState('')
const [migrateEmail, setMigrateEmail] = useState('')
const [newPassword, setNewPassword] = useState('') const [newPassword, setNewPassword] = useState('')
const [confirmPassword, setConfirmPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('')
const [usage, setUsage] = useState(null) const [usage, setUsage] = useState(null)
@ -125,7 +124,6 @@ const AccountSettings = () => {
if (getUserByIdApi.data) { if (getUserByIdApi.data) {
setProfileName(getUserByIdApi.data?.name || '') setProfileName(getUserByIdApi.data?.name || '')
setEmail(getUserByIdApi.data?.email || '') setEmail(getUserByIdApi.data?.email || '')
setMigrateEmail(getUserByIdApi.data?.email || '')
} }
} catch (e) { } catch (e) {
console.error(e) console.error(e)

View File

@ -42,7 +42,7 @@ import useApi from '@/hooks/useApi'
import useConfirm from '@/hooks/useConfirm' import useConfirm from '@/hooks/useConfirm'
// icons // icons
import { IconX, IconRefreshAlert, IconMagnetFilled, IconMagnetOff } from '@tabler/icons-react' import { IconX, IconRefreshAlert, IconMagnetFilled, IconMagnetOff, IconArtboard, IconArtboardOff } from '@tabler/icons-react'
// utils // utils
import { import {
@ -101,6 +101,7 @@ const AgentflowCanvas = () => {
const [editNodeDialogOpen, setEditNodeDialogOpen] = useState(false) const [editNodeDialogOpen, setEditNodeDialogOpen] = useState(false)
const [editNodeDialogProps, setEditNodeDialogProps] = useState({}) const [editNodeDialogProps, setEditNodeDialogProps] = useState({})
const [isSnappingEnabled, setIsSnappingEnabled] = useState(false) const [isSnappingEnabled, setIsSnappingEnabled] = useState(false)
const [isBackgroundEnabled, setIsBackgroundEnabled] = useState(true)
const reactFlowWrapper = useRef(null) const reactFlowWrapper = useRef(null)
@ -742,6 +743,16 @@ const AgentflowCanvas = () => {
> >
{isSnappingEnabled ? <IconMagnetFilled /> : <IconMagnetOff />} {isSnappingEnabled ? <IconMagnetFilled /> : <IconMagnetOff />}
</button> </button>
<button
className='react-flow__controls-button react-flow__controls-interactive'
onClick={() => {
setIsBackgroundEnabled(!isBackgroundEnabled)
}}
title='toggle background'
aria-label='toggle background'
>
{isBackgroundEnabled ? <IconArtboard /> : <IconArtboardOff />}
</button>
</Controls> </Controls>
<MiniMap <MiniMap
nodeStrokeWidth={3} nodeStrokeWidth={3}
@ -752,7 +763,7 @@ const AgentflowCanvas = () => {
backgroundColor: customization.isDarkMode ? theme.palette.background.default : '#fff' backgroundColor: customization.isDarkMode ? theme.palette.background.default : '#fff'
}} }}
/> />
<Background color='#aaa' gap={16} /> {isBackgroundEnabled && <Background color='#aaa' gap={16} />}
<AddNodes <AddNodes
isAgentCanvas={true} isAgentCanvas={true}
isAgentflowv2={true} isAgentflowv2={true}

View File

@ -20,7 +20,7 @@ import EditNodeDialog from '@/views/agentflowsv2/EditNodeDialog'
import { flowContext } from '@/store/context/ReactFlowContext' import { flowContext } from '@/store/context/ReactFlowContext'
// icons // icons
import { IconMagnetFilled, IconMagnetOff } from '@tabler/icons-react' import { IconMagnetFilled, IconMagnetOff, IconArtboard, IconArtboardOff } from '@tabler/icons-react'
const nodeTypes = { agentFlow: AgentFlowNode, stickyNote: StickyNote, iteration: IterationNode } const nodeTypes = { agentFlow: AgentFlowNode, stickyNote: StickyNote, iteration: IterationNode }
const edgeTypes = { agentFlow: AgentFlowEdge } const edgeTypes = { agentFlow: AgentFlowEdge }
@ -42,6 +42,7 @@ const MarketplaceCanvasV2 = () => {
const [editNodeDialogOpen, setEditNodeDialogOpen] = useState(false) const [editNodeDialogOpen, setEditNodeDialogOpen] = useState(false)
const [editNodeDialogProps, setEditNodeDialogProps] = useState({}) const [editNodeDialogProps, setEditNodeDialogProps] = useState({})
const [isSnappingEnabled, setIsSnappingEnabled] = useState(false) const [isSnappingEnabled, setIsSnappingEnabled] = useState(false)
const [isBackgroundEnabled, setIsBackgroundEnabled] = useState(true)
const reactFlowWrapper = useRef(null) const reactFlowWrapper = useRef(null)
const { setReactFlowInstance } = useContext(flowContext) const { setReactFlowInstance } = useContext(flowContext)
@ -136,8 +137,18 @@ const MarketplaceCanvasV2 = () => {
> >
{isSnappingEnabled ? <IconMagnetFilled /> : <IconMagnetOff />} {isSnappingEnabled ? <IconMagnetFilled /> : <IconMagnetOff />}
</button> </button>
<button
className='react-flow__controls-button react-flow__controls-interactive'
onClick={() => {
setIsBackgroundEnabled(!isBackgroundEnabled)
}}
title='toggle background'
aria-label='toggle background'
>
{isBackgroundEnabled ? <IconArtboard /> : <IconArtboardOff />}
</button>
</Controls> </Controls>
<Background color='#aaa' gap={16} /> {isBackgroundEnabled && <Background color='#aaa' gap={16} />}
<EditNodeDialog <EditNodeDialog
show={editNodeDialogOpen} show={editNodeDialogOpen}
dialogProps={editNodeDialogProps} dialogProps={editNodeDialogProps}

View File

@ -38,7 +38,7 @@ import useConfirm from '@/hooks/useConfirm'
import { useAuth } from '@/hooks/useAuth' import { useAuth } from '@/hooks/useAuth'
// icons // icons
import { IconX, IconRefreshAlert, IconMagnetFilled, IconMagnetOff } from '@tabler/icons-react' import { IconX, IconRefreshAlert, IconMagnetFilled, IconMagnetOff, IconArtboard, IconArtboardOff } from '@tabler/icons-react'
// utils // utils
import { import {
@ -98,6 +98,7 @@ const Canvas = () => {
const [isUpsertButtonEnabled, setIsUpsertButtonEnabled] = useState(false) const [isUpsertButtonEnabled, setIsUpsertButtonEnabled] = useState(false)
const [isSyncNodesButtonEnabled, setIsSyncNodesButtonEnabled] = useState(false) const [isSyncNodesButtonEnabled, setIsSyncNodesButtonEnabled] = useState(false)
const [isSnappingEnabled, setIsSnappingEnabled] = useState(false) const [isSnappingEnabled, setIsSnappingEnabled] = useState(false)
const [isBackgroundEnabled, setIsBackgroundEnabled] = useState(true)
const reactFlowWrapper = useRef(null) const reactFlowWrapper = useRef(null)
@ -621,8 +622,18 @@ const Canvas = () => {
> >
{isSnappingEnabled ? <IconMagnetFilled /> : <IconMagnetOff />} {isSnappingEnabled ? <IconMagnetFilled /> : <IconMagnetOff />}
</button> </button>
<button
className='react-flow__controls-button react-flow__controls-interactive'
onClick={() => {
setIsBackgroundEnabled(!isBackgroundEnabled)
}}
title='toggle background'
aria-label='toggle background'
>
{isBackgroundEnabled ? <IconArtboard /> : <IconArtboardOff />}
</button>
</Controls> </Controls>
<Background color='#aaa' gap={16} /> {isBackgroundEnabled && <Background color='#aaa' gap={16} />}
<AddNodes isAgentCanvas={isAgentCanvas} nodesData={getNodesApi.data} node={selectedNode} /> <AddNodes isAgentCanvas={isAgentCanvas} nodesData={getNodesApi.data} node={selectedNode} />
{isSyncNodesButtonEnabled && ( {isSyncNodesButtonEnabled && (
<Fab <Fab

View File

@ -16,7 +16,7 @@ import MarketplaceCanvasHeader from './MarketplaceCanvasHeader'
import StickyNote from '../canvas/StickyNote' import StickyNote from '../canvas/StickyNote'
// icons // icons
import { IconMagnetFilled, IconMagnetOff } from '@tabler/icons-react' import { IconMagnetFilled, IconMagnetOff, IconArtboard, IconArtboardOff } from '@tabler/icons-react'
const nodeTypes = { customNode: MarketplaceCanvasNode, stickyNote: StickyNote } const nodeTypes = { customNode: MarketplaceCanvasNode, stickyNote: StickyNote }
const edgeTypes = { buttonedge: '' } const edgeTypes = { buttonedge: '' }
@ -36,6 +36,7 @@ const MarketplaceCanvas = () => {
const [nodes, setNodes, onNodesChange] = useNodesState() const [nodes, setNodes, onNodesChange] = useNodesState()
const [edges, setEdges, onEdgesChange] = useEdgesState() const [edges, setEdges, onEdgesChange] = useEdgesState()
const [isSnappingEnabled, setIsSnappingEnabled] = useState(false) const [isSnappingEnabled, setIsSnappingEnabled] = useState(false)
const [isBackgroundEnabled, setIsBackgroundEnabled] = useState(true)
const reactFlowWrapper = useRef(null) const reactFlowWrapper = useRef(null)
@ -114,8 +115,18 @@ const MarketplaceCanvas = () => {
> >
{isSnappingEnabled ? <IconMagnetFilled /> : <IconMagnetOff />} {isSnappingEnabled ? <IconMagnetFilled /> : <IconMagnetOff />}
</button> </button>
<button
className='react-flow__controls-button react-flow__controls-interactive'
onClick={() => {
setIsBackgroundEnabled(!isBackgroundEnabled)
}}
title='toggle background'
aria-label='toggle background'
>
{isBackgroundEnabled ? <IconArtboard /> : <IconArtboardOff />}
</button>
</Controls> </Controls>
<Background color='#aaa' gap={16} /> {isBackgroundEnabled && <Background color='#aaa' gap={16} />}
</ReactFlow> </ReactFlow>
</div> </div>
</div> </div>