diff --git a/web/app/components/plugins/install-plugin/base/check-task-status.ts b/web/app/components/plugins/install-plugin/base/check-task-status.ts index 365bd9cf36..96d6171aaf 100644 --- a/web/app/components/plugins/install-plugin/base/check-task-status.ts +++ b/web/app/components/plugins/install-plugin/base/check-task-status.ts @@ -4,7 +4,7 @@ import { TaskStatus } from '../../types' const INTERVAL = 10 * 1000 // 10 seconds -interface Params { +type Params = { taskId: string pluginUniqueIdentifier: string } @@ -18,7 +18,8 @@ function checkTaskStatus() { pluginUniqueIdentifier, }: Params) => { if (isStop) return - const { plugins } = await fetchCheckTaskStatus(taskId) + const res = await fetchCheckTaskStatus(taskId) + const { plugins } = res.task const plugin = plugins.find((p: PluginStatus) => p.plugin_unique_identifier === pluginUniqueIdentifier) if (!plugin) { nextStatus = TaskStatus.failed diff --git a/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx b/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx index 7a20d5b43e..605a9f36f0 100644 --- a/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx +++ b/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx @@ -37,6 +37,19 @@ const InstallPluginDropdown = ({ } } + // TODO TEST INSTALL : uninstall + // const [pluginLists, setPluginLists] = useState([]) + // useEffect(() => { + // (async () => { + // const list: any = await get('workspaces/current/plugin/list') + // })() + // }) + + // const handleUninstall = async (id: string) => { + // const res = await post('workspaces/current/plugin/uninstall', { body: { plugin_installation_id: id } }) + // console.log(res) + // } + return ( ) } + {/* {pluginLists.map((item: any) => ( +
handleUninstall(item.id)}>{item.name} 卸载
+ ))} */}
) } diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index 89c557eec7..663ae3900c 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -15,7 +15,7 @@ export enum PluginSource { debugging = 'remote', } -export interface PluginToolDeclaration { +export type PluginToolDeclaration = { identity: { author: string name: string @@ -27,17 +27,17 @@ export interface PluginToolDeclaration { credentials_schema: ToolCredential[] // TODO } -export interface PluginEndpointDeclaration { +export type PluginEndpointDeclaration = { settings: ToolCredential[] endpoints: EndpointItem[] } -export interface EndpointItem { +export type EndpointItem = { path: string method: string } -export interface EndpointListItem { +export type EndpointListItem = { id: string created_at: string updated_at: string @@ -53,7 +53,7 @@ export interface EndpointListItem { } // Plugin manifest -export interface PluginDeclaration { +export type PluginDeclaration = { version: string author: string icon: string @@ -70,7 +70,7 @@ export interface PluginDeclaration { model: any // TODO } -export interface PluginDetail { +export type PluginDetail = { id: string created_at: string updated_at: string @@ -87,7 +87,7 @@ export interface PluginDetail { meta?: any } -export interface Plugin { +export type Plugin = { type: PluginType org: string name: string @@ -113,7 +113,7 @@ export enum PermissionType { noOne = 'noOne', } -export interface Permissions { +export type Permissions = { canManagement: PermissionType canDebugger: PermissionType } @@ -125,7 +125,7 @@ export enum InstallStepFromGitHub { installed = 'installed', } -export interface InstallState { +export type InstallState = { step: InstallStepFromGitHub repoUrl: string selectedVersion: string @@ -133,34 +133,34 @@ export interface InstallState { releases: GitHubRepoReleaseResponse[] } -export interface GitHubUrlInfo { +export type GitHubUrlInfo = { isValid: boolean owner?: string repo?: string } // endpoint -export interface CreateEndpointRequest { +export type CreateEndpointRequest = { plugin_unique_identifier: string settings: Record name: string } -export interface EndpointOperationResponse { +export type EndpointOperationResponse = { result: 'success' | 'error' } -export interface EndpointsRequest { +export type EndpointsRequest = { limit: number page: number plugin_id: string } -export interface EndpointsResponse { +export type EndpointsResponse = { endpoints: EndpointListItem[] has_more: boolean limit: number total: number page: number } -export interface UpdateEndpointRequest { +export type UpdateEndpointRequest = { endpoint_id: string settings: Record name: string @@ -175,24 +175,24 @@ export enum InstallStep { installFailed = 'failed', } -export interface GitHubAsset { +export type GitHubAsset = { id: number name: string browser_download_url: string } -export interface GitHubRepoReleaseResponse { +export type GitHubRepoReleaseResponse = { tag_name: string assets: GitHubAsset[] } -export interface InstallPackageResponse { +export type InstallPackageResponse = { plugin_unique_identifier: string all_installed: boolean task_id: string } -export interface DebugInfo { +export type DebugInfo = { key: string host: string port: number @@ -204,19 +204,21 @@ export enum TaskStatus { failed = 'failed', } -export interface PluginStatus { +export type PluginStatus = { plugin_unique_identifier: string plugin_id: string status: TaskStatus message: string } -export interface TaskStatusResponse { - id: string - created_at: string - updated_at: string - status: string - total_plugins: number - completed_plugins: number - plugins: PluginStatus[] +export type TaskStatusResponse = { + task: { + id: string + created_at: string + updated_at: string + status: string + total_plugins: number + completed_plugins: number + plugins: PluginStatus[] + } }