mirror of
https://github.com/langgenius/dify.git
synced 2026-02-20 01:44:42 +08:00
Some checks failed
autofix.ci / autofix (push) Has been cancelled
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Has been cancelled
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Has been cancelled
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Has been cancelled
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Has been cancelled
Main CI Pipeline / Check Changed Files (push) Has been cancelled
Main CI Pipeline / Style Check (push) Has been cancelled
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Has been cancelled
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Has been cancelled
Main CI Pipeline / API Tests (push) Has been cancelled
Main CI Pipeline / Web Tests (push) Has been cancelled
Main CI Pipeline / VDB Tests (push) Has been cancelled
Main CI Pipeline / DB Migration Test (push) Has been cancelled
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
'use client'
|
|
|
|
import { useRouter } from 'next/navigation'
|
|
import { useEffect } from 'react'
|
|
import Loading from '@/app/components/base/loading'
|
|
import { useAppContext } from '@/context/app-context'
|
|
import { ExternalApiPanelProvider } from '@/context/external-api-panel-context'
|
|
import { ExternalKnowledgeApiProvider } from '@/context/external-knowledge-api-context'
|
|
|
|
export default function DatasetsLayout({ children }: { children: React.ReactNode }) {
|
|
const { isCurrentWorkspaceEditor, isCurrentWorkspaceDatasetOperator, currentWorkspace, isLoadingCurrentWorkspace } = useAppContext()
|
|
const router = useRouter()
|
|
const shouldRedirect = !isLoadingCurrentWorkspace
|
|
&& currentWorkspace.id
|
|
&& !(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator)
|
|
|
|
useEffect(() => {
|
|
if (shouldRedirect)
|
|
router.replace('/apps')
|
|
}, [shouldRedirect, router])
|
|
|
|
if (isLoadingCurrentWorkspace || !currentWorkspace.id)
|
|
return <Loading type="app" />
|
|
|
|
if (shouldRedirect) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<ExternalKnowledgeApiProvider>
|
|
<ExternalApiPanelProvider>
|
|
{children}
|
|
</ExternalApiPanelProvider>
|
|
</ExternalKnowledgeApiProvider>
|
|
)
|
|
}
|