mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-28 13:17:14 +00:00
feat(ui): list plugins
This commit is contained in:
@@ -43,15 +43,20 @@ const PluginInstalledComponent = forwardRef<PluginInstalledComponentRef>(
|
|||||||
setPluginList(
|
setPluginList(
|
||||||
value.plugins.map((plugin) => {
|
value.plugins.map((plugin) => {
|
||||||
return new PluginCardVO({
|
return new PluginCardVO({
|
||||||
author: plugin.author,
|
author: plugin.manifest.manifest.metadata.author ?? '',
|
||||||
description: i18nObj(plugin.description),
|
description: i18nObj(
|
||||||
|
plugin.manifest.manifest.metadata.description ?? {
|
||||||
|
en_US: '',
|
||||||
|
zh_Hans: '',
|
||||||
|
},
|
||||||
|
),
|
||||||
enabled: plugin.enabled,
|
enabled: plugin.enabled,
|
||||||
name: plugin.name,
|
name: plugin.manifest.manifest.metadata.name,
|
||||||
version: plugin.version,
|
version: plugin.manifest.manifest.metadata.version ?? '',
|
||||||
status: plugin.status,
|
status: plugin.status,
|
||||||
tools: plugin.tools,
|
tools: [],
|
||||||
event_handlers: plugin.event_handlers,
|
event_handlers: {},
|
||||||
repository: plugin.repository,
|
repository: plugin.manifest.manifest.metadata.repository ?? '',
|
||||||
priority: plugin.priority,
|
priority: plugin.priority,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { ApiRespPluginConfig, Plugin } from '@/app/infra/entities/api';
|
import { ApiRespPluginConfig } from '@/app/infra/entities/api';
|
||||||
|
import { Plugin } from '@/app/infra/entities/plugin';
|
||||||
import { httpClient } from '@/app/infra/http/HttpClient';
|
import { httpClient } from '@/app/infra/http/HttpClient';
|
||||||
import DynamicFormComponent from '@/app/home/components/dynamic-form/DynamicFormComponent';
|
import DynamicFormComponent from '@/app/home/components/dynamic-form/DynamicFormComponent';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
@@ -183,13 +184,22 @@ export default function PluginForm({
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div className="text-lg font-medium">{pluginInfo.name}</div>
|
<div className="text-lg font-medium">
|
||||||
<div className="text-sm text-gray-500 pb-2">
|
{i18nObj(pluginInfo.manifest.manifest.metadata.label)}
|
||||||
{i18nObj(pluginInfo.description)}
|
|
||||||
</div>
|
</div>
|
||||||
{pluginInfo.config_schema.length > 0 && (
|
<div className="text-sm text-gray-500 pb-2">
|
||||||
|
{i18nObj(
|
||||||
|
pluginInfo.manifest.manifest.metadata.description ?? {
|
||||||
|
en_US: '',
|
||||||
|
zh_Hans: '',
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{/* @ts-ignore */}
|
||||||
|
{pluginInfo.manifest.manifest.spec.config.length > 0 && (
|
||||||
<DynamicFormComponent
|
<DynamicFormComponent
|
||||||
itemConfigList={pluginInfo.config_schema}
|
// @ts-ignore
|
||||||
|
itemConfigList={pluginInfo.manifest.manifest.spec.config}
|
||||||
initialValues={pluginConfig.config as Record<string, object>}
|
initialValues={pluginConfig.config as Record<string, object>}
|
||||||
onSubmit={(values) => {
|
onSubmit={(values) => {
|
||||||
let config = pluginConfig.config;
|
let config = pluginConfig.config;
|
||||||
@@ -203,7 +213,8 @@ export default function PluginForm({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{pluginInfo.config_schema.length === 0 && (
|
{/* @ts-ignore */}
|
||||||
|
{pluginInfo.manifest.manifest.spec.config.length === 0 && (
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-500">
|
||||||
{t('plugins.pluginNoConfig')}
|
{t('plugins.pluginNoConfig')}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { IDynamicFormItemSchema } from '@/app/infra/entities/form/dynamic';
|
|||||||
import { PipelineConfigTab } from '@/app/infra/entities/pipeline';
|
import { PipelineConfigTab } from '@/app/infra/entities/pipeline';
|
||||||
import { I18nLabel } from '@/app/infra/entities/common';
|
import { I18nLabel } from '@/app/infra/entities/common';
|
||||||
import { Message } from '@/app/infra/entities/message';
|
import { Message } from '@/app/infra/entities/message';
|
||||||
|
import { Plugin } from '@/app/infra/entities/plugin';
|
||||||
|
|
||||||
export interface ApiResponse<T> {
|
export interface ApiResponse<T> {
|
||||||
code: number;
|
code: number;
|
||||||
@@ -119,22 +120,22 @@ export interface ApiRespPlugin {
|
|||||||
plugin: Plugin;
|
plugin: Plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Plugin {
|
// export interface Plugin {
|
||||||
author: string;
|
// author: string;
|
||||||
name: string;
|
// name: string;
|
||||||
description: I18nLabel;
|
// description: I18nLabel;
|
||||||
label: I18nLabel;
|
// label: I18nLabel;
|
||||||
version: string;
|
// version: string;
|
||||||
enabled: boolean;
|
// enabled: boolean;
|
||||||
priority: number;
|
// priority: number;
|
||||||
status: string;
|
// status: string;
|
||||||
tools: object[];
|
// tools: object[];
|
||||||
event_handlers: object;
|
// event_handlers: object;
|
||||||
main_file: string;
|
// main_file: string;
|
||||||
pkg_path: string;
|
// pkg_path: string;
|
||||||
repository: string;
|
// repository: string;
|
||||||
config_schema: IDynamicFormItemSchema[];
|
// config_schema: IDynamicFormItemSchema[];
|
||||||
}
|
// }
|
||||||
|
|
||||||
export interface ApiRespPluginConfig {
|
export interface ApiRespPluginConfig {
|
||||||
config: object;
|
config: object;
|
||||||
|
|||||||
@@ -3,3 +3,18 @@ export interface I18nLabel {
|
|||||||
zh_Hans: string;
|
zh_Hans: string;
|
||||||
ja_JP?: string;
|
ja_JP?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ComponentManifest {
|
||||||
|
apiVersion: string;
|
||||||
|
kind: string;
|
||||||
|
metadata: {
|
||||||
|
name: string;
|
||||||
|
label: I18nLabel;
|
||||||
|
description?: I18nLabel;
|
||||||
|
icon?: string;
|
||||||
|
repository?: string;
|
||||||
|
version?: string;
|
||||||
|
author?: string;
|
||||||
|
};
|
||||||
|
spec: object;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { ComponentManifest } from '@/app/infra/entities/common';
|
||||||
|
|
||||||
|
export interface Plugin {
|
||||||
|
status: 'intialized' | 'mounted' | 'unmounted';
|
||||||
|
priority: number;
|
||||||
|
plugin_config: object;
|
||||||
|
manifest: {
|
||||||
|
manifest: ComponentManifest;
|
||||||
|
};
|
||||||
|
enabled: boolean;
|
||||||
|
components: {
|
||||||
|
component_config: object;
|
||||||
|
manifest: {
|
||||||
|
manifest: ComponentManifest;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user