This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch feat-8017 in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 288be500457eb72d322fc84fb1a480b11a056e02 Author: mintsweet <0x1304...@gmail.com> AuthorDate: Wed Sep 25 18:29:09 2024 +1200 fix: adjust the api for connections token check --- config-ui/src/api/blueprint/index.ts | 2 ++ config-ui/src/api/project/index.ts | 11 +---------- config-ui/src/routes/blueprint/detail/status-panel.tsx | 10 +++++----- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/config-ui/src/api/blueprint/index.ts b/config-ui/src/api/blueprint/index.ts index 3876d3e20..99460c088 100644 --- a/config-ui/src/api/blueprint/index.ts +++ b/config-ui/src/api/blueprint/index.ts @@ -43,3 +43,5 @@ type TriggerQuery = { export const trigger = (id: ID, data: TriggerQuery = { skipCollectors: false, fullSync: false }) => request(`/blueprints/${id}/trigger`, { method: 'post', data }); + +export const connectionsTokenCheck = (id: ID) => request(`/blueprints/${id}/connections-token-check`); diff --git a/config-ui/src/api/project/index.ts b/config-ui/src/api/project/index.ts index bc27b5e00..8e79ee5fa 100644 --- a/config-ui/src/api/project/index.ts +++ b/config-ui/src/api/project/index.ts @@ -24,16 +24,7 @@ export const list = (data: Pagination & { keyword?: string }): Promise<{ count: export const get = (name: string): Promise<IProject> => request(`/projects/${encodeURIComponent(name)}`); -export const check = ( - name: string, - data?: { check_token: 1 }, -): Promise<{ - exist: boolean; - tokens: Array<{ pluginName: string; connectionId: ID; success: boolean }>; -}> => - request(`/projects/${encodeURIComponent(name)}/check`, { - data, - }); +export const checkName = (name: string) => request(`/projects/${encodeURIComponent(name)}/check`); export const create = (data: Pick<IProject, 'name' | 'description' | 'metrics'>) => request('/projects', { diff --git a/config-ui/src/routes/blueprint/detail/status-panel.tsx b/config-ui/src/routes/blueprint/detail/status-panel.tsx index f9aaccc38..9e48d9968 100644 --- a/config-ui/src/routes/blueprint/detail/status-panel.tsx +++ b/config-ui/src/routes/blueprint/detail/status-panel.tsx @@ -74,15 +74,15 @@ export const StatusPanel = ({ from, blueprint, pipelineId, onRefresh }: Props) = skipCollectors?: boolean; fullSync?: boolean; }) => { - if (!skipCollectors && from === FromEnum.project) { - const [success, res] = await operator(() => API.project.check(blueprint.projectName, { check_token: 1 }), { + if (!skipCollectors) { + const [success, res] = await operator(() => API.blueprint.connectionsTokenCheck(blueprint.id), { hideToast: true, setOperating, }); - if (success && res.tokens.length) { - const connectionFailed = res.tokens - .filter((token: any) => !token.success) + if (success && res.length) { + const connectionFailed = res + .filter((it: any) => !it.success) .map((it: any) => { const unique = `${it.pluginName}-${it.connectionId}`; const connection = connections.find((c) => c.unique === unique);