mirror of
https://github.com/langgenius/dify.git
synced 2026-06-24 13:01:16 +08:00
feat(web): hide snippet import app action
This commit is contained in:
parent
e1c419f122
commit
6a48939e0c
@ -1,5 +1,6 @@
|
||||
import { ContextMenu } from '@langgenius/dify-ui/context-menu'
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import { FlowType } from '@/types/common'
|
||||
import { fullWorkflowAccessControl } from '../hooks-store'
|
||||
import { PanelContextmenu } from '../panel-contextmenu'
|
||||
import { BlockEnum } from '../types'
|
||||
@ -147,6 +148,24 @@ describe('PanelContextmenu', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('should hide import app on snippet canvases', async () => {
|
||||
renderPanelContextmenu({
|
||||
initialStoreState: {
|
||||
contextMenuTarget: { type: 'panel' },
|
||||
},
|
||||
hooksStoreProps: {
|
||||
configsMap: {
|
||||
flowId: 'snippet-1',
|
||||
flowType: FlowType.snippet,
|
||||
fileSettings: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
expect(await screen.findByText('export')).toBeInTheDocument()
|
||||
expect(screen.queryByText('importApp')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should render preview action in chat mode', async () => {
|
||||
mockUseIsChatMode.mockReturnValue(true)
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import {
|
||||
useCallback,
|
||||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FlowType } from '@/types/common'
|
||||
import { TEST_RUN_MENU_HOTKEY } from './header/shortcuts'
|
||||
import {
|
||||
useDSL,
|
||||
@ -18,6 +19,7 @@ import {
|
||||
useWorkflowStartRun,
|
||||
} from './hooks'
|
||||
import { useHooksStore } from './hooks-store'
|
||||
import { isSnippetCanvas } from './nodes/_base/hooks/snippet-input-field-vars'
|
||||
import AddBlock from './operator/add-block'
|
||||
import { useOperator } from './operator/hooks'
|
||||
import { ShortcutKbd } from './shortcuts/shortcut-kbd'
|
||||
@ -48,6 +50,7 @@ export function PanelContextmenu({
|
||||
const { isCommentModeAvailable } = useWorkflowMoveMode()
|
||||
const { exportCheck } = useDSL()
|
||||
const accessControl = useHooksStore(s => s.accessControl)
|
||||
const flowType = useHooksStore(s => s.configsMap?.flowType)
|
||||
const isChatMode = useIsChatMode()
|
||||
const workflowOperationReadOnly = !!(
|
||||
workflowRunningData?.result.status === WorkflowRunningStatus.Running
|
||||
@ -57,6 +60,7 @@ export function PanelContextmenu({
|
||||
)
|
||||
const canEditWorkflow = accessControl.canEdit && !workflowOperationReadOnly
|
||||
const canCommentWorkflow = accessControl.canComment && !workflowOperationReadOnly
|
||||
const shouldHideImportApp = flowType === FlowType.snippet || isSnippetCanvas()
|
||||
|
||||
const renderAddBlockTrigger = useCallback(() => {
|
||||
return (
|
||||
@ -177,12 +181,14 @@ export function PanelContextmenu({
|
||||
>
|
||||
{t('export', { ns: 'app' })}
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem
|
||||
className="justify-between gap-4 px-3 text-text-secondary"
|
||||
onClick={() => setShowImportDSLModal(true)}
|
||||
>
|
||||
{t('importApp', { ns: 'app' })}
|
||||
</ContextMenuItem>
|
||||
{!shouldHideImportApp && (
|
||||
<ContextMenuItem
|
||||
className="justify-between gap-4 px-3 text-text-secondary"
|
||||
onClick={() => setShowImportDSLModal(true)}
|
||||
>
|
||||
{t('importApp', { ns: 'app' })}
|
||||
</ContextMenuItem>
|
||||
)}
|
||||
</ContextMenuGroup>
|
||||
</>
|
||||
)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user