Skip to content

Commit

Permalink
fix: adjust the api for connections token check
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsweet committed Sep 26, 2024
1 parent 626db74 commit 288be50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 2 additions & 0 deletions config-ui/src/api/blueprint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
11 changes: 1 addition & 10 deletions config-ui/src/api/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
10 changes: 5 additions & 5 deletions config-ui/src/routes/blueprint/detail/status-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 288be50

Please sign in to comment.