From 817e32dbc7cdf1599bd677918ccdff99e77ff4c8 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 4 Mar 2024 13:01:05 -0500 Subject: [PATCH] fix(graphql): adjustments for Dashboard Automated Analysis with new API schema (#1220) * fix(graphql): adjustments for Dashboard Automated Analysis with new API schema --- .../AutomatedAnalysisCard.tsx | 36 +++++++++++-------- src/app/Shared/Services/Api.service.tsx | 10 +++++- .../AutomatedAnalysisCard.test.tsx | 10 +++--- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx b/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx index 901257860..4755d9578 100644 --- a/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx +++ b/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx @@ -179,18 +179,23 @@ export const AutomatedAnalysisCard: DashboardCardFC ` query ActiveRecordingsForAutomatedAnalysis($connectUrl: String) { targetNodes(filter: { name: $connectUrl }) { - recordings { - active (filter: { - name: "${automatedAnalysisRecordingName}", - labels: ["origin=${automatedAnalysisRecordingName}"], - }) { - data { - state - name - downloadUrl - reportUrl - metadata { - labels + target { + recordings { + active (filter: { + name: "${automatedAnalysisRecordingName}", + labels: ["origin=${automatedAnalysisRecordingName}"], + }) { + data { + state + name + downloadUrl + reportUrl + metadata { + labels { + key + value + } + } } } } @@ -214,7 +219,10 @@ export const AutomatedAnalysisCard: DashboardCardFC downloadUrl reportUrl metadata { - labels + labels { + key + value + } } size archivedTime @@ -358,7 +366,7 @@ export const AutomatedAnalysisCard: DashboardCardFC } } }), - map((v) => v.data.targetNodes[0].recordings.active.data[0] as Recording), + map((v) => v.data.targetNodes[0].target.recordings.active.data[0] as Recording), tap((recording) => { if (recording === null || recording === undefined) { throw new Error(NO_RECORDINGS_MESSAGE); diff --git a/src/app/Shared/Services/Api.service.tsx b/src/app/Shared/Services/Api.service.tsx index 2bded2658..4f8b3b7a4 100644 --- a/src/app/Shared/Services/Api.service.tsx +++ b/src/app/Shared/Services/Api.service.tsx @@ -310,8 +310,16 @@ export class ApiService { if (archiveOnStop != undefined) { form.append('archiveOnStop', String(archiveOnStop)); } + const transformedMetadata = { + labels: {}, + annotations: { + cryostat: {}, + platform: {}, + }, + }; + metadata?.labels.forEach((label) => (transformedMetadata.labels[label.key] = label.value)); if (metadata) { - form.append('metadata', JSON.stringify(metadata)); + form.append('metadata', JSON.stringify(transformedMetadata)); } if (restart != undefined) { form.append('restart', String(restart)); diff --git a/src/test/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.test.tsx b/src/test/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.test.tsx index 8f6d9a313..32b6bd382 100644 --- a/src/test/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.test.tsx +++ b/src/test/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.test.tsx @@ -162,7 +162,7 @@ const mockTargetNode = { const mockActiveRecordingsResponse = { data: { - targetNodes: [mockTargetNode], + targetNodes: [{ target: mockTargetNode }], }, }; @@ -170,9 +170,11 @@ const mockEmptyActiveRecordingsResponse = { data: { targetNodes: [ { - recordings: { - active: { - data: [], + target: { + recordings: { + active: { + data: [], + }, }, }, },