add CollaborationEnabled for comment shortcut

This commit is contained in:
hjlarry 2025-10-22 09:59:43 +08:00
parent 83df78d0c8
commit fa09c88f5c
3 changed files with 17 additions and 10 deletions

View File

@ -37,6 +37,7 @@ export const useShortcuts = (): void => {
handleModeHand, handleModeHand,
handleModePointer, handleModePointer,
handleModeComment, handleModeComment,
isCommentModeAvailable,
} = useWorkflowMoveMode() } = useWorkflowMoveMode()
const { handleLayout } = useWorkflowOrganize() const { handleLayout } = useWorkflowOrganize()
const { handleToggleMaximizeCanvas } = useWorkflowCanvasMaximize() const { handleToggleMaximizeCanvas } = useWorkflowCanvasMaximize()
@ -146,7 +147,7 @@ export const useShortcuts = (): void => {
}) })
useKeyPress('c', (e) => { useKeyPress('c', (e) => {
if (shouldHandleShortcut(e)) { if (shouldHandleShortcut(e) && isCommentModeAvailable) {
e.preventDefault() e.preventDefault()
handleModeComment() handleModeComment()
} }

View File

@ -30,6 +30,8 @@ import { useNodesSyncDraft } from './use-nodes-sync-draft'
import { WorkflowHistoryEvent, useWorkflowHistory } from './use-workflow-history' import { WorkflowHistoryEvent, useWorkflowHistory } from './use-workflow-history'
import { useEventEmitterContextContext } from '@/context/event-emitter' import { useEventEmitterContextContext } from '@/context/event-emitter'
import { useCollaborativeWorkflow } from '@/app/components/workflow/hooks/use-collaborative-workflow' import { useCollaborativeWorkflow } from '@/app/components/workflow/hooks/use-collaborative-workflow'
import { useStore as useAppStore } from '@/app/components/app/store'
import { useGlobalPublicStore } from '@/context/global-public-context'
export const useWorkflowInteractions = () => { export const useWorkflowInteractions = () => {
const workflowStore = useWorkflowStore() const workflowStore = useWorkflowStore()
@ -56,6 +58,9 @@ export const useWorkflowMoveMode = () => {
getNodesReadOnly, getNodesReadOnly,
} = useNodesReadOnly() } = useNodesReadOnly()
const { handleSelectionCancel } = useSelectionInteractions() const { handleSelectionCancel } = useSelectionInteractions()
const isCollaborationEnabled = useGlobalPublicStore(s => s.systemFeatures.enable_collaboration_mode)
const appDetail = useAppStore(state => state.appDetail)
const isCommentModeAvailable = isCollaborationEnabled && (appDetail?.mode === 'workflow' || appDetail?.mode === 'advanced-chat')
const handleModePointer = useCallback(() => { const handleModePointer = useCallback(() => {
if (getNodesReadOnly()) if (getNodesReadOnly())
@ -73,17 +78,18 @@ export const useWorkflowMoveMode = () => {
}, [getNodesReadOnly, setControlMode, handleSelectionCancel]) }, [getNodesReadOnly, setControlMode, handleSelectionCancel])
const handleModeComment = useCallback(() => { const handleModeComment = useCallback(() => {
if (getNodesReadOnly()) if (getNodesReadOnly() || !isCommentModeAvailable)
return return
setControlMode(ControlMode.Comment) setControlMode(ControlMode.Comment)
handleSelectionCancel() handleSelectionCancel()
}, [getNodesReadOnly, setControlMode, handleSelectionCancel]) }, [getNodesReadOnly, setControlMode, handleSelectionCancel, isCommentModeAvailable])
return { return {
handleModePointer, handleModePointer,
handleModeHand, handleModeHand,
handleModeComment, handleModeComment,
isCommentModeAvailable,
} }
} }

View File

@ -28,14 +28,17 @@ import TipPopup from './tip-popup'
import ExportImage from './export-image' import ExportImage from './export-image'
import { useOperator } from './hooks' import { useOperator } from './hooks'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useStore as useAppStore } from '@/app/components/app/store'
import { useGlobalPublicStore } from '@/context/global-public-context'
const Control = () => { const Control = () => {
const { t } = useTranslation() const { t } = useTranslation()
const controlMode = useStore(s => s.controlMode) const controlMode = useStore(s => s.controlMode)
const maximizeCanvas = useStore(s => s.maximizeCanvas) const maximizeCanvas = useStore(s => s.maximizeCanvas)
const { handleModePointer, handleModeHand, handleModeComment } = useWorkflowMoveMode() const {
handleModePointer,
handleModeHand,
handleModeComment,
isCommentModeAvailable,
} = useWorkflowMoveMode()
const { handleLayout } = useWorkflowOrganize() const { handleLayout } = useWorkflowOrganize()
const { handleAddNote } = useOperator() const { handleAddNote } = useOperator()
const { const {
@ -43,9 +46,6 @@ const Control = () => {
getNodesReadOnly, getNodesReadOnly,
} = useNodesReadOnly() } = useNodesReadOnly()
const { handleToggleMaximizeCanvas } = useWorkflowCanvasMaximize() const { handleToggleMaximizeCanvas } = useWorkflowCanvasMaximize()
const isCollaborationEnabled = useGlobalPublicStore(s => s.systemFeatures.enable_collaboration_mode)
const appDetail = useAppStore(state => state.appDetail)
const isCommentVisible = isCollaborationEnabled && (appDetail?.mode === 'workflow' || appDetail?.mode === 'advanced-chat')
const addNote = (e: MouseEvent<HTMLDivElement>) => { const addNote = (e: MouseEvent<HTMLDivElement>) => {
if (getNodesReadOnly()) if (getNodesReadOnly())
@ -94,7 +94,7 @@ const Control = () => {
<RiHand className='h-4 w-4' /> <RiHand className='h-4 w-4' />
</div> </div>
</TipPopup> </TipPopup>
{isCommentVisible && ( {isCommentModeAvailable && (
<TipPopup title={t('workflow.common.commentMode')} shortcuts={['c']}> <TipPopup title={t('workflow.common.commentMode')} shortcuts={['c']}>
<div <div
className={cn( className={cn(