Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graphql): adjustments for Dashboard Automated Analysis with new API schema #1220

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,23 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
`
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
}
}
}
}
}
Expand All @@ -214,7 +219,10 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
downloadUrl
reportUrl
metadata {
labels
labels {
key
value
}
}
size
archivedTime
Expand Down Expand Up @@ -358,7 +366,7 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
}
}
}),
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);
Expand Down
10 changes: 9 additions & 1 deletion src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,19 @@ const mockTargetNode = {

const mockActiveRecordingsResponse = {
data: {
targetNodes: [mockTargetNode],
targetNodes: [{ target: mockTargetNode }],
},
};

const mockEmptyActiveRecordingsResponse = {
data: {
targetNodes: [
{
recordings: {
active: {
data: [],
target: {
recordings: {
active: {
data: [],
},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/test/Recordings/ArchivedRecordingsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const mockUploadedRecordingLabels = [
];
export const convertLabels = (kv: KeyValue[]): object => {
const out = {};
for (let e of kv) {
for (const e of kv) {
out[e.key] = e.value;
}
return out;
Expand Down
Loading