From 021bc57cd4f6d6076af1569ddcd711d8138ded69 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 21 Nov 2024 12:43:18 +0800 Subject: [PATCH] empty of tool list --- .../plugins/marketplace/empty/index.tsx | 19 +++-- web/app/components/tools/provider-list.tsx | 70 +++++++++---------- web/i18n/en-US/tools.ts | 1 + web/i18n/zh-Hans/tools.ts | 1 + 4 files changed, 51 insertions(+), 40 deletions(-) diff --git a/web/app/components/plugins/marketplace/empty/index.tsx b/web/app/components/plugins/marketplace/empty/index.tsx index 25f8efc504..32b706a291 100644 --- a/web/app/components/plugins/marketplace/empty/index.tsx +++ b/web/app/components/plugins/marketplace/empty/index.tsx @@ -4,12 +4,22 @@ import { Group } from '@/app/components/base/icons/src/vender/other' import Line from './line' import cn from '@/utils/classnames' -const Empty = () => { +type Props = { + text?: string + lightCard?: boolean + className?: string +} + +const Empty = ({ + text, + lightCard, + className, +}: Props) => { const { t } = useTranslation() return (
{ Array.from({ length: 16 }).map((_, index) => ( @@ -19,6 +29,7 @@ const Empty = () => { 'mr-3 mb-3 h-[144px] w-[calc((100%-36px)/4)] rounded-xl bg-background-section-burn', index % 4 === 3 && 'mr-0', index > 11 && 'mb-0', + lightCard && 'bg-background-default-lighter', )} >
@@ -28,7 +39,7 @@ const Empty = () => { className='absolute inset-0 bg-marketplace-plugin-empty z-[1]' >
-
+
@@ -36,7 +47,7 @@ const Empty = () => {
- {t('plugin.marketplace.noPluginFound')} + {text || t('plugin.marketplace.noPluginFound')}
diff --git a/web/app/components/tools/provider-list.tsx b/web/app/components/tools/provider-list.tsx index 4ebd70dc56..2c0d52b0ba 100644 --- a/web/app/components/tools/provider-list.tsx +++ b/web/app/components/tools/provider-list.tsx @@ -1,5 +1,5 @@ 'use client' -import { useEffect, useMemo, useRef, useState } from 'react' +import { useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import type { Collection } from './types' import Marketplace from './marketplace' @@ -9,7 +9,7 @@ import TabSliderNew from '@/app/components/base/tab-slider-new' import LabelFilter from '@/app/components/tools/labels/filter' import Input from '@/app/components/base/input' import ProviderDetail from '@/app/components/tools/provider/detail' -import Empty from '@/app/components/tools/add-tool-modal/empty' +import Empty from '@/app/components/plugins/marketplace/empty' import Card from '@/app/components/plugins/card' import CardMoreInfo from '@/app/components/plugins/card/card-more-info' import { useSelector as useAppContextSelector } from '@/context/app-context' @@ -50,12 +50,6 @@ const ProviderList = () => { }, [activeTab, tagFilterValue, keywords, collectionList]) const [currentProvider, setCurrentProvider] = useState() - useEffect(() => { - if (currentProvider && collectionList.length > 0) { - const newCurrentProvider = collectionList.find(collection => collection.id === currentProvider.id) - setCurrentProvider(newCurrentProvider) - } - }, [collectionList, currentProvider]) return (
@@ -88,34 +82,38 @@ const ProviderList = () => { />
-
- {filteredCollectionList.map(collection => ( -
setCurrentProvider(collection)} - > - - } - /> -
- ))} - {!filteredCollectionList.length &&
} -
+ {filteredCollectionList.length > 0 && ( +
+ {filteredCollectionList.map(collection => ( +
setCurrentProvider(collection)} + > + + } + /> +
+ ))} +
+ )} + {!filteredCollectionList.length && ( + + )} { enable_marketplace && (