fix: check status

This commit is contained in:
Joel 2024-10-28 18:36:13 +08:00
parent c4d6f9e179
commit ca9e23d6ea
3 changed files with 49 additions and 30 deletions

View File

@ -4,7 +4,7 @@ import { TaskStatus } from '../../types'
const INTERVAL = 10 * 1000 // 10 seconds const INTERVAL = 10 * 1000 // 10 seconds
interface Params { type Params = {
taskId: string taskId: string
pluginUniqueIdentifier: string pluginUniqueIdentifier: string
} }
@ -18,7 +18,8 @@ function checkTaskStatus() {
pluginUniqueIdentifier, pluginUniqueIdentifier,
}: Params) => { }: Params) => {
if (isStop) return 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) const plugin = plugins.find((p: PluginStatus) => p.plugin_unique_identifier === pluginUniqueIdentifier)
if (!plugin) { if (!plugin) {
nextStatus = TaskStatus.failed nextStatus = TaskStatus.failed

View File

@ -37,6 +37,19 @@ const InstallPluginDropdown = ({
} }
} }
// TODO TEST INSTALL : uninstall
// const [pluginLists, setPluginLists] = useState<any>([])
// 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 ( return (
<PortalToFollowElem <PortalToFollowElem
open={isMenuOpen} open={isMenuOpen}
@ -110,6 +123,9 @@ const InstallPluginDropdown = ({
/> />
) )
} }
{/* {pluginLists.map((item: any) => (
<div key={item.id} onClick={() => handleUninstall(item.id)}>{item.name} </div>
))} */}
</PortalToFollowElem> </PortalToFollowElem>
) )
} }

View File

@ -15,7 +15,7 @@ export enum PluginSource {
debugging = 'remote', debugging = 'remote',
} }
export interface PluginToolDeclaration { export type PluginToolDeclaration = {
identity: { identity: {
author: string author: string
name: string name: string
@ -27,17 +27,17 @@ export interface PluginToolDeclaration {
credentials_schema: ToolCredential[] // TODO credentials_schema: ToolCredential[] // TODO
} }
export interface PluginEndpointDeclaration { export type PluginEndpointDeclaration = {
settings: ToolCredential[] settings: ToolCredential[]
endpoints: EndpointItem[] endpoints: EndpointItem[]
} }
export interface EndpointItem { export type EndpointItem = {
path: string path: string
method: string method: string
} }
export interface EndpointListItem { export type EndpointListItem = {
id: string id: string
created_at: string created_at: string
updated_at: string updated_at: string
@ -53,7 +53,7 @@ export interface EndpointListItem {
} }
// Plugin manifest // Plugin manifest
export interface PluginDeclaration { export type PluginDeclaration = {
version: string version: string
author: string author: string
icon: string icon: string
@ -70,7 +70,7 @@ export interface PluginDeclaration {
model: any // TODO model: any // TODO
} }
export interface PluginDetail { export type PluginDetail = {
id: string id: string
created_at: string created_at: string
updated_at: string updated_at: string
@ -87,7 +87,7 @@ export interface PluginDetail {
meta?: any meta?: any
} }
export interface Plugin { export type Plugin = {
type: PluginType type: PluginType
org: string org: string
name: string name: string
@ -113,7 +113,7 @@ export enum PermissionType {
noOne = 'noOne', noOne = 'noOne',
} }
export interface Permissions { export type Permissions = {
canManagement: PermissionType canManagement: PermissionType
canDebugger: PermissionType canDebugger: PermissionType
} }
@ -125,7 +125,7 @@ export enum InstallStepFromGitHub {
installed = 'installed', installed = 'installed',
} }
export interface InstallState { export type InstallState = {
step: InstallStepFromGitHub step: InstallStepFromGitHub
repoUrl: string repoUrl: string
selectedVersion: string selectedVersion: string
@ -133,34 +133,34 @@ export interface InstallState {
releases: GitHubRepoReleaseResponse[] releases: GitHubRepoReleaseResponse[]
} }
export interface GitHubUrlInfo { export type GitHubUrlInfo = {
isValid: boolean isValid: boolean
owner?: string owner?: string
repo?: string repo?: string
} }
// endpoint // endpoint
export interface CreateEndpointRequest { export type CreateEndpointRequest = {
plugin_unique_identifier: string plugin_unique_identifier: string
settings: Record<string, any> settings: Record<string, any>
name: string name: string
} }
export interface EndpointOperationResponse { export type EndpointOperationResponse = {
result: 'success' | 'error' result: 'success' | 'error'
} }
export interface EndpointsRequest { export type EndpointsRequest = {
limit: number limit: number
page: number page: number
plugin_id: string plugin_id: string
} }
export interface EndpointsResponse { export type EndpointsResponse = {
endpoints: EndpointListItem[] endpoints: EndpointListItem[]
has_more: boolean has_more: boolean
limit: number limit: number
total: number total: number
page: number page: number
} }
export interface UpdateEndpointRequest { export type UpdateEndpointRequest = {
endpoint_id: string endpoint_id: string
settings: Record<string, any> settings: Record<string, any>
name: string name: string
@ -175,24 +175,24 @@ export enum InstallStep {
installFailed = 'failed', installFailed = 'failed',
} }
export interface GitHubAsset { export type GitHubAsset = {
id: number id: number
name: string name: string
browser_download_url: string browser_download_url: string
} }
export interface GitHubRepoReleaseResponse { export type GitHubRepoReleaseResponse = {
tag_name: string tag_name: string
assets: GitHubAsset[] assets: GitHubAsset[]
} }
export interface InstallPackageResponse { export type InstallPackageResponse = {
plugin_unique_identifier: string plugin_unique_identifier: string
all_installed: boolean all_installed: boolean
task_id: string task_id: string
} }
export interface DebugInfo { export type DebugInfo = {
key: string key: string
host: string host: string
port: number port: number
@ -204,14 +204,15 @@ export enum TaskStatus {
failed = 'failed', failed = 'failed',
} }
export interface PluginStatus { export type PluginStatus = {
plugin_unique_identifier: string plugin_unique_identifier: string
plugin_id: string plugin_id: string
status: TaskStatus status: TaskStatus
message: string message: string
} }
export interface TaskStatusResponse { export type TaskStatusResponse = {
task: {
id: string id: string
created_at: string created_at: string
updated_at: string updated_at: string
@ -220,3 +221,4 @@ export interface TaskStatusResponse {
completed_plugins: number completed_plugins: number
plugins: PluginStatus[] plugins: PluginStatus[]
} }
}