From 76f6b8d104f2f828a904636c3b7ec581fb066e1c Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Fri, 11 Oct 2024 16:15:24 +0800 Subject: [PATCH] marketplace --- web/app/(commonLayout)/plugins/Container.tsx | 37 ++++++---------- web/app/(commonLayout)/plugins/page.tsx | 11 +++-- .../(commonLayout)/plugins/plugins-panel.tsx | 25 +++++++++++ .../components/plugins/marketplace/index.tsx | 43 ++++++++++++++++--- .../components/plugins/marketplace/list.tsx | 14 ++++++ .../marketplace/marketplace-wrapper.tsx | 12 ------ .../plugins/marketplace/marketplace.tsx | 41 ------------------ .../marketplace/plugin-type-switch.tsx | 4 +- .../plugins/marketplace/search-box/index.tsx | 6 +-- 9 files changed, 99 insertions(+), 94 deletions(-) create mode 100644 web/app/(commonLayout)/plugins/plugins-panel.tsx delete mode 100644 web/app/components/plugins/marketplace/marketplace-wrapper.tsx delete mode 100644 web/app/components/plugins/marketplace/marketplace.tsx diff --git a/web/app/(commonLayout)/plugins/Container.tsx b/web/app/(commonLayout)/plugins/Container.tsx index 1c03b08d37..f3de74cfab 100644 --- a/web/app/(commonLayout)/plugins/Container.tsx +++ b/web/app/(commonLayout)/plugins/Container.tsx @@ -6,7 +6,6 @@ import { RiArrowRightUpLine, RiBugLine, RiClipboardLine, - RiDragDropLine, RiEqualizer2Line, } from '@remixicon/react' import InstallPluginDropdown from './InstallPluginDropdown' @@ -16,12 +15,18 @@ import Button from '@/app/components/base/button' import TabSlider from '@/app/components/base/tab-slider' import ActionButton from '@/app/components/base/action-button' import Tooltip from '@/app/components/base/tooltip' -import Marketplace from '@/app/components/plugins/marketplace' import cn from '@/utils/classnames' -const Container = () => { +type ContainerWrapperProps = { + plugins: React.ReactNode + marketplace: React.ReactNode +} +const ContainerWrapper = ({ + plugins, + marketplace, +}: ContainerWrapperProps) => { const { t } = useTranslation() - const { setShowPluginSettingModal } = useModalContext() + const { setShowPluginSettingModal } = useModalContext() as any const options = useMemo(() => { return [ @@ -104,31 +109,13 @@ const Container = () => { { - activeTab === 'plugins' && ( - <> -
-
-
- {/* Filter goes here */} -
-
-
- {/* Plugin cards go here */} -
-
- - Drop plugin package here to install -
- - ) + activeTab === 'plugins' && plugins } { - activeTab === 'discover' && ( - - ) + activeTab === 'discover' && marketplace } ) } -export default Container +export default ContainerWrapper diff --git a/web/app/(commonLayout)/plugins/page.tsx b/web/app/(commonLayout)/plugins/page.tsx index 5c22853fcd..830efd7159 100644 --- a/web/app/(commonLayout)/plugins/page.tsx +++ b/web/app/(commonLayout)/plugins/page.tsx @@ -1,10 +1,13 @@ -import Container from './Container' +import PluginsPanel from './plugins-panel' +import Container from './container' +import Marketplace from '@/app/components/plugins/marketplace' const PluginList = async () => { return ( - <> - - + } + marketplace={} + /> ) } diff --git a/web/app/(commonLayout)/plugins/plugins-panel.tsx b/web/app/(commonLayout)/plugins/plugins-panel.tsx new file mode 100644 index 0000000000..227630f7d8 --- /dev/null +++ b/web/app/(commonLayout)/plugins/plugins-panel.tsx @@ -0,0 +1,25 @@ +'use client' + +import { RiDragDropLine } from '@remixicon/react' + +const PluginsPanel = () => { + return ( + <> +
+
+
+ {/* Filter goes here */} +
+
+
+ {/* Plugin cards go here */} +
+
+ + Drop plugin package here to install +
+ + ) +} + +export default PluginsPanel diff --git a/web/app/components/plugins/marketplace/index.tsx b/web/app/components/plugins/marketplace/index.tsx index 8e0cb16452..b07db8e920 100644 --- a/web/app/components/plugins/marketplace/index.tsx +++ b/web/app/components/plugins/marketplace/index.tsx @@ -1,12 +1,41 @@ -import MarketplaceWrapper from './marketplace-wrapper' -import Marketplace from './marketplace' +import SearchBox from './search-box' +import PluginTypeSwitch from './plugin-type-switch' +import List from './list' -const MarketplacePage = () => { +const Marketplace = () => { return ( - - - +
+
+

+ Empower your AI development +

+

+ Discover + + models + + , + + tools + + , + + extensions + + and + + bundles + + in Dify Marketplace +

+
+ +
+ +
+ +
) } -export default MarketplacePage +export default Marketplace diff --git a/web/app/components/plugins/marketplace/list.tsx b/web/app/components/plugins/marketplace/list.tsx index a42e6e3edb..d9365fa54a 100644 --- a/web/app/components/plugins/marketplace/list.tsx +++ b/web/app/components/plugins/marketplace/list.tsx @@ -1,8 +1,11 @@ import Card from '@/app/components/plugins/card' import CardMoreInfo from '@/app/components/plugins/card/card-more-info' import { toolNotion } from '@/app/components/plugins/card/card-mock' +import { getLocaleOnServer } from '@/i18n/server' const List = () => { + const locale = getLocaleOnServer() + return (
@@ -10,30 +13,35 @@ const List = () => {
Our top picks to get you started
} /> } /> } /> } /> @@ -46,36 +54,42 @@ const List = () => {
Explore the library and discover the incredible work of our community
} /> } /> } /> } /> } /> diff --git a/web/app/components/plugins/marketplace/marketplace-wrapper.tsx b/web/app/components/plugins/marketplace/marketplace-wrapper.tsx deleted file mode 100644 index 6c78d73c39..0000000000 --- a/web/app/components/plugins/marketplace/marketplace-wrapper.tsx +++ /dev/null @@ -1,12 +0,0 @@ -'use client' - -type WrapperProps = { - children: React.ReactNode -} -const MarketplaceWrapper = ({ - children, -}: WrapperProps) => { - return children -} - -export default MarketplaceWrapper diff --git a/web/app/components/plugins/marketplace/marketplace.tsx b/web/app/components/plugins/marketplace/marketplace.tsx deleted file mode 100644 index bc40e6c245..0000000000 --- a/web/app/components/plugins/marketplace/marketplace.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import SearchBox from './search-box' -import PluginTypeSwitch from './plugin-type-switch' -import List from './list' - -const Marketplace = () => { - return ( -
-
-

- Empower your AI development -

-

- Discover - - models - - , - - tools - - , - - extensions - - and - - bundles - - in Dify Marketplace -

-
- {}} /> -
- {}} /> -
- -
- ) -} - -export default Marketplace diff --git a/web/app/components/plugins/marketplace/plugin-type-switch.tsx b/web/app/components/plugins/marketplace/plugin-type-switch.tsx index 607bd362a6..9c9d73cdb7 100644 --- a/web/app/components/plugins/marketplace/plugin-type-switch.tsx +++ b/web/app/components/plugins/marketplace/plugin-type-switch.tsx @@ -8,7 +8,7 @@ import { import cn from '@/utils/classnames' type PluginTypeSwitchProps = { - onChange: (type: string) => void + onChange?: (type: string) => void } const options = [ { @@ -54,7 +54,7 @@ const PluginTypeSwitch = ({ )} onClick={() => { setActiveType(option.value) - onChange(option.value) + onChange?.(option.value) }} > {option.icon} diff --git a/web/app/components/plugins/marketplace/search-box/index.tsx b/web/app/components/plugins/marketplace/search-box/index.tsx index 627f387aef..cb01f0ad10 100644 --- a/web/app/components/plugins/marketplace/search-box/index.tsx +++ b/web/app/components/plugins/marketplace/search-box/index.tsx @@ -9,7 +9,7 @@ import TagsFilter from './tags-filter' import ActionButton from '@/app/components/base/action-button' type SearchBoxProps = { - onChange: (searchText: string, tags: string[]) => void + onChange?: (searchText: string, tags: string[]) => void } const SearchBox = ({ onChange, @@ -19,7 +19,7 @@ const SearchBox = ({ const handleTagsChange = useCallback((tags: string[]) => { setSelectedTags(tags) - onChange(searchText, tags) + onChange?.(searchText, tags) }, [searchText, onChange]) return ( @@ -36,7 +36,7 @@ const SearchBox = ({ value={searchText} onChange={(e) => { setSearchText(e.target.value) - onChange(e.target.value, selectedTags) + onChange?.(e.target.value, selectedTags) }} /> {