fix dataset operator (#6064)

Co-authored-by: JzoNg <jzongcode@gmail.com>
This commit is contained in:
Joe
2024-07-09 17:47:54 +08:00
committed by GitHub
parent 3b14939d66
commit ce930f19b9
46 changed files with 1072 additions and 290 deletions

View File

@@ -1,7 +1,8 @@
'use client'
// Libraries
import { useRef, useState } from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useRouter } from 'next/navigation'
import { useTranslation } from 'react-i18next'
import { useDebounceFn } from 'ahooks'
import useSWR from 'swr'
@@ -22,15 +23,20 @@ import { fetchDatasetApiBaseUrl } from '@/service/datasets'
// Hooks
import { useTabSearchParams } from '@/hooks/use-tab-searchparams'
import { useStore as useTagStore } from '@/app/components/base/tag-management/store'
import { useAppContext } from '@/context/app-context'
const Container = () => {
const { t } = useTranslation()
const router = useRouter()
const { currentWorkspace } = useAppContext()
const showTagManagementModal = useTagStore(s => s.showTagManagementModal)
const options = [
{ value: 'dataset', text: t('dataset.datasets') },
{ value: 'api', text: t('dataset.datasetsApi') },
]
const options = useMemo(() => {
return [
{ value: 'dataset', text: t('dataset.datasets') },
...(currentWorkspace.role === 'dataset_operator' ? [] : [{ value: 'api', text: t('dataset.datasetsApi') }]),
]
}, [currentWorkspace.role, t])
const [activeTab, setActiveTab] = useTabSearchParams({
defaultTab: 'dataset',
@@ -57,6 +63,11 @@ const Container = () => {
handleTagsUpdate()
}
useEffect(() => {
if (currentWorkspace.role === 'normal')
return router.replace('/apps')
}, [currentWorkspace])
return (
<div ref={containerRef} className='grow relative flex flex-col bg-gray-100 overflow-y-auto'>
<div className='sticky top-0 flex justify-between pt-4 px-12 pb-2 leading-[56px] bg-gray-100 z-10 flex-wrap gap-y-2'>