mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 19:27:23 +08:00
fix(web): template creation permission for app templates (#30367)
Co-authored-by: 非法操作 <hjlarry@163.com>
This commit is contained in:
parent
3a59ae9617
commit
de53c78125
@ -14,13 +14,6 @@ vi.mock('ahooks', () => ({
|
|||||||
vi.mock('@/context/app-context', () => ({
|
vi.mock('@/context/app-context', () => ({
|
||||||
useAppContext: () => ({ isCurrentWorkspaceEditor: true }),
|
useAppContext: () => ({ isCurrentWorkspaceEditor: true }),
|
||||||
}))
|
}))
|
||||||
vi.mock('use-context-selector', async () => {
|
|
||||||
const actual = await vi.importActual<typeof import('use-context-selector')>('use-context-selector')
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
useContext: () => ({ hasEditPermission: true }),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
vi.mock('nuqs', () => ({
|
vi.mock('nuqs', () => ({
|
||||||
useQueryState: () => ['Recommended', vi.fn()],
|
useQueryState: () => ['Recommended', vi.fn()],
|
||||||
}))
|
}))
|
||||||
@ -119,6 +112,7 @@ describe('Apps', () => {
|
|||||||
fireEvent.click(screen.getAllByTestId('app-card')[0])
|
fireEvent.click(screen.getAllByTestId('app-card')[0])
|
||||||
expect(screen.getByTestId('create-from-template-modal')).toBeInTheDocument()
|
expect(screen.getByTestId('create-from-template-modal')).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows no template message when list is empty', () => {
|
it('shows no template message when list is empty', () => {
|
||||||
mockUseExploreAppList.mockReturnValueOnce({
|
mockUseExploreAppList.mockReturnValueOnce({
|
||||||
data: { allList: [], categories: [] },
|
data: { allList: [], categories: [] },
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import { useRouter } from 'next/navigation'
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { useMemo, useState } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useContext } from 'use-context-selector'
|
|
||||||
import AppTypeSelector from '@/app/components/app/type-selector'
|
import AppTypeSelector from '@/app/components/app/type-selector'
|
||||||
import { trackEvent } from '@/app/components/base/amplitude'
|
import { trackEvent } from '@/app/components/base/amplitude'
|
||||||
import Divider from '@/app/components/base/divider'
|
import Divider from '@/app/components/base/divider'
|
||||||
@ -19,7 +18,6 @@ import CreateAppModal from '@/app/components/explore/create-app-modal'
|
|||||||
import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'
|
import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'
|
||||||
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
||||||
import { useAppContext } from '@/context/app-context'
|
import { useAppContext } from '@/context/app-context'
|
||||||
import ExploreContext from '@/context/explore-context'
|
|
||||||
import { DSLImportMode } from '@/models/app'
|
import { DSLImportMode } from '@/models/app'
|
||||||
import { importDSL } from '@/service/apps'
|
import { importDSL } from '@/service/apps'
|
||||||
import { fetchAppDetail } from '@/service/explore'
|
import { fetchAppDetail } from '@/service/explore'
|
||||||
@ -47,7 +45,6 @@ const Apps = ({
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { isCurrentWorkspaceEditor } = useAppContext()
|
const { isCurrentWorkspaceEditor } = useAppContext()
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
const { hasEditPermission } = useContext(ExploreContext)
|
|
||||||
const allCategoriesEn = AppCategories.RECOMMENDED
|
const allCategoriesEn = AppCategories.RECOMMENDED
|
||||||
|
|
||||||
const [keywords, setKeywords] = useState('')
|
const [keywords, setKeywords] = useState('')
|
||||||
@ -214,7 +211,7 @@ const Apps = ({
|
|||||||
<AppCard
|
<AppCard
|
||||||
key={app.app_id}
|
key={app.app_id}
|
||||||
app={app}
|
app={app}
|
||||||
canCreate={hasEditPermission}
|
canCreate={isCurrentWorkspaceEditor}
|
||||||
onCreate={() => {
|
onCreate={() => {
|
||||||
setCurrApp(app)
|
setCurrApp(app)
|
||||||
setIsShowCreateModal(true)
|
setIsShowCreateModal(true)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user