From beb03a1519599f966d3ff86ac623baed55927163 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Tue, 9 Jul 2024 12:40:37 +0800 Subject: [PATCH] hide api tab for dataset operator --- web/app/(commonLayout)/datasets/Container.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web/app/(commonLayout)/datasets/Container.tsx b/web/app/(commonLayout)/datasets/Container.tsx index 1be6a5c2a74a9d..f532ca416fc243 100644 --- a/web/app/(commonLayout)/datasets/Container.tsx +++ b/web/app/(commonLayout)/datasets/Container.tsx @@ -1,7 +1,7 @@ 'use client' // Libraries -import { useEffect, 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' @@ -31,10 +31,12 @@ const Container = () => { 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',