From 9e9bc88473028416a6d8d436347b5e4f3eb98156 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Thu, 21 Aug 2025 10:47:53 +0800 Subject: [PATCH] chore: remove plugin reorder functionality --- web/src/app/home/plugins/page.tsx | 14 +- .../plugins/plugin-sort/PluginSortDialog.tsx | 390 +++++++++--------- 2 files changed, 205 insertions(+), 199 deletions(-) diff --git a/web/src/app/home/plugins/page.tsx b/web/src/app/home/plugins/page.tsx index 8274d025..40a666eb 100644 --- a/web/src/app/home/plugins/page.tsx +++ b/web/src/app/home/plugins/page.tsx @@ -3,7 +3,7 @@ import PluginInstalledComponent, { PluginInstalledComponentRef, } from '@/app/home/plugins/plugin-installed/PluginInstalledComponent'; import MarketPage from '@/app/home/plugins/plugin-market/PluginMarketComponent'; -import PluginSortDialog from '@/app/home/plugins/plugin-sort/PluginSortDialog'; +// import PluginSortDialog from '@/app/home/plugins/plugin-sort/PluginSortDialog'; import styles from './plugins.module.css'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Button } from '@/components/ui/button'; @@ -44,7 +44,7 @@ enum PluginInstallStatus { export default function PluginConfigPage() { const { t } = useTranslation(); const [modalOpen, setModalOpen] = useState(false); - const [sortModalOpen, setSortModalOpen] = useState(false); + // const [sortModalOpen, setSortModalOpen] = useState(false); const [activeTab, setActiveTab] = useState('installed'); const [installSource, setInstallSource] = useState('local'); const [installInfo, setInstallInfo] = useState>({}); // eslint-disable-line @typescript-eslint/no-explicit-any @@ -219,15 +219,15 @@ export default function PluginConfigPage() {
- + */}
)} - { pluginInstalledRef.current?.refreshPluginList(); }} - /> + /> */} ); } diff --git a/web/src/app/home/plugins/plugin-sort/PluginSortDialog.tsx b/web/src/app/home/plugins/plugin-sort/PluginSortDialog.tsx index acde5741..998ae93e 100644 --- a/web/src/app/home/plugins/plugin-sort/PluginSortDialog.tsx +++ b/web/src/app/home/plugins/plugin-sort/PluginSortDialog.tsx @@ -1,209 +1,215 @@ -'use client'; +// 'use client'; -import * as React from 'react'; -import { useState, useEffect } from 'react'; -import { PluginCardVO } from '@/app/home/plugins/plugin-installed/PluginCardVO'; -import { httpClient } from '@/app/infra/http/HttpClient'; -import { PluginReorderElement } from '@/app/infra/entities/api'; -import { toast } from 'sonner'; -import { - Dialog, - DialogContent, - DialogHeader, - DialogTitle, - DialogFooter, -} from '@/components/ui/dialog'; -import { Button } from '@/components/ui/button'; -import { - DndContext, - closestCenter, - KeyboardSensor, - PointerSensor, - useSensor, - useSensors, - DragEndEvent, -} from '@dnd-kit/core'; -import { - arrayMove, - SortableContext, - sortableKeyboardCoordinates, - useSortable, - verticalListSortingStrategy, -} from '@dnd-kit/sortable'; -import { CSS } from '@dnd-kit/utilities'; -import { useTranslation } from 'react-i18next'; -import { extractI18nObject } from '@/i18n/I18nProvider'; +// import * as React from 'react'; +// import { useState, useEffect } from 'react'; +// import { PluginCardVO } from '@/app/home/plugins/plugin-installed/PluginCardVO'; +// import { httpClient } from '@/app/infra/http/HttpClient'; +// import { PluginReorderElement } from '@/app/infra/entities/api'; +// import { toast } from 'sonner'; +// import { +// Dialog, +// DialogContent, +// DialogHeader, +// DialogTitle, +// DialogFooter, +// } from '@/components/ui/dialog'; +// import { Button } from '@/components/ui/button'; +// import { +// DndContext, +// closestCenter, +// KeyboardSensor, +// PointerSensor, +// useSensor, +// useSensors, +// DragEndEvent, +// } from '@dnd-kit/core'; +// import { +// arrayMove, +// SortableContext, +// sortableKeyboardCoordinates, +// useSortable, +// verticalListSortingStrategy, +// } from '@dnd-kit/sortable'; +// import { CSS } from '@dnd-kit/utilities'; +// import { useTranslation } from 'react-i18next'; +// import { extractI18nObject } from '@/i18n/I18nProvider'; -interface PluginSortDialogProps { - open: boolean; - onOpenChange: (open: boolean) => void; - onSortComplete: () => void; -} +// interface PluginSortDialogProps { +// open: boolean; +// onOpenChange: (open: boolean) => void; +// onSortComplete: () => void; +// } -function SortablePluginItem({ plugin }: { plugin: PluginCardVO }) { - const { attributes, listeners, setNodeRef, transform, transition } = - useSortable({ - id: `${plugin.author}-${plugin.name}`, - }); +// function SortablePluginItem({ plugin }: { plugin: PluginCardVO }) { +// const { attributes, listeners, setNodeRef, transform, transition } = +// useSortable({ +// id: `${plugin.author}-${plugin.name}`, +// }); - const style = { - transform: CSS.Transform.toString(transform), - transition, - }; +// const style = { +// transform: CSS.Transform.toString(transform), +// transition, +// }; - return ( -
-
-
- {plugin.author} -
-
{plugin.name}
-
- {plugin.description} -
-
-
- ); -} +// return ( +//
+//
+//
+// {plugin.author} +//
+//
{plugin.name}
+//
+// {plugin.description} +//
+//
+//
+// ); +// } -export default function PluginSortDialog({ - open, - onOpenChange, - onSortComplete, -}: PluginSortDialogProps) { - const { t } = useTranslation(); - const [sortedPlugins, setSortedPlugins] = useState([]); - const [isLoading, setIsLoading] = useState(false); +// export default function PluginSortDialog({ +// open, +// onOpenChange, +// onSortComplete, +// }: PluginSortDialogProps) { +// const { t } = useTranslation(); +// const [sortedPlugins, setSortedPlugins] = useState([]); +// const [isLoading, setIsLoading] = useState(false); - function getPluginList() { - httpClient.getPlugins().then((value) => { - setSortedPlugins( - value.plugins.map((plugin) => { - return new PluginCardVO({ - author: plugin.author, - description: extractI18nObject(plugin.description), - enabled: plugin.enabled, - name: plugin.name, - version: plugin.version, - status: plugin.status, - tools: plugin.tools, - event_handlers: plugin.event_handlers, - repository: plugin.repository, - priority: plugin.priority, - }); - }), - ); - }); - } +// function getPluginList() { +// httpClient.getPlugins().then((value) => { +// setSortedPlugins( +// value.plugins.map((plugin) => { +// return new PluginCardVO({ +// author: plugin.manifest.manifest.metadata.author ?? '', +// description: extractI18nObject( +// plugin.manifest.manifest.metadata.description ?? { +// en_US: '', +// zh_Hans: '', +// }, +// ), +// enabled: plugin.enabled, +// name: plugin.manifest.manifest.metadata.name, +// version: plugin.manifest.manifest.metadata.version ?? '', +// status: plugin.status, +// components: plugin.components, +// install_source: plugin.install_source, +// install_info: plugin.install_info, +// priority: plugin.priority, +// debug: plugin.debug, +// }); +// }), +// ); +// }); +// } - useEffect(() => { - if (open) { - getPluginList(); - } - }, [open]); +// useEffect(() => { +// if (open) { +// getPluginList(); +// } +// }, [open]); - const sensors = useSensors( - useSensor(PointerSensor), - useSensor(KeyboardSensor, { - coordinateGetter: sortableKeyboardCoordinates, - }), - ); +// const sensors = useSensors( +// useSensor(PointerSensor), +// useSensor(KeyboardSensor, { +// coordinateGetter: sortableKeyboardCoordinates, +// }), +// ); - function handleDragEnd(event: DragEndEvent) { - const { active, over } = event; - console.log('Drag end event:', { active, over }); +// function handleDragEnd(event: DragEndEvent) { +// const { active, over } = event; +// console.log('Drag end event:', { active, over }); - if (over && active.id !== over.id) { - setSortedPlugins((items) => { - const oldIndex = items.findIndex( - (item) => `${item.author}-${item.name}` === active.id, - ); - const newIndex = items.findIndex( - (item) => `${item.author}-${item.name}` === over.id, - ); +// if (over && active.id !== over.id) { +// setSortedPlugins((items) => { +// const oldIndex = items.findIndex( +// (item) => `${item.author}-${item.name}` === active.id, +// ); +// const newIndex = items.findIndex( +// (item) => `${item.author}-${item.name}` === over.id, +// ); - const newItems = arrayMove(items, oldIndex, newIndex); +// const newItems = arrayMove(items, oldIndex, newIndex); - return newItems; - }); - } - } +// return newItems; +// }); +// } +// } - function handleSave() { - setIsLoading(true); +// function handleSave() { +// setIsLoading(true); - const reorderElements: PluginReorderElement[] = sortedPlugins.map( - (plugin, index) => ({ - author: plugin.author, - name: plugin.name, - priority: index, - }), - ); +// const reorderElements: PluginReorderElement[] = sortedPlugins.map( +// (plugin, index) => ({ +// author: plugin.author, +// name: plugin.name, +// priority: index, +// }), +// ); - httpClient - .reorderPlugins(reorderElements) - .then(() => { - toast.success(t('plugins.pluginSortSuccess')); - onSortComplete(); - onOpenChange(false); - }) - .catch((err) => { - toast.error(t('plugins.pluginSortError') + err.message); - }) - .finally(() => { - setIsLoading(false); - }); - } +// httpClient +// .reorderPlugins(reorderElements) +// .then(() => { +// toast.success(t('plugins.pluginSortSuccess')); +// onSortComplete(); +// onOpenChange(false); +// }) +// .catch((err) => { +// toast.error(t('plugins.pluginSortError') + err.message); +// }) +// .finally(() => { +// setIsLoading(false); +// }); +// } - return ( - - - - {t('plugins.pluginSort')} - -
-

- {t('plugins.pluginSortDescription')} -

- - `${plugin.author}-${plugin.name}`, - )} - strategy={verticalListSortingStrategy} - > - {sortedPlugins.map((plugin) => ( - - ))} - - -
- - - - -
-
- ); -} +// return ( +// +// +// +// {t('plugins.pluginSort')} +// +//
+//

+// {t('plugins.pluginSortDescription')} +//

+// +// `${plugin.author}-${plugin.name}`, +// )} +// strategy={verticalListSortingStrategy} +// > +// {sortedPlugins.map((plugin) => ( +// +// ))} +// +// +//
+// +// +// +// +//
+//
+// ); +// }