Add checksId option to EntityTechInsightsScorecardContent component

Signed-off-by: Rogerio Angeliski <angeliski@hotmail.com>
This commit is contained in:
Rogerio Angeliski
2022-04-07 18:06:21 -03:00
parent 9f78f91a4c
commit 567b13a84a
5 changed files with 14 additions and 6 deletions
@@ -47,7 +47,7 @@ export interface TechInsightsApi {
getAllChecks(): Promise<Check[]>;
runChecks(
entityParams: CompoundEntityRef,
checks?: Check[],
checks?: string[],
): Promise<CheckResult[]>;
runBulkChecks(
entities: CompoundEntityRef[],
@@ -75,13 +75,12 @@ export class TechInsightsClient implements TechInsightsApi {
async runChecks(
entityParams: CompoundEntityRef,
checks?: Check[],
checks?: string[],
): Promise<CheckResult[]> {
const url = await this.discoveryApi.getBaseUrl('tech-insights');
const { token } = await this.identityApi.getCredentials();
const { namespace, kind, name } = entityParams;
const checkIds = checks ? checks.map(check => check.id) : [];
const requestBody = { checks: checkIds.length > 0 ? checkIds : undefined };
const requestBody = { checks };
const response = await fetch(
`${url}/checks/run/${encodeURIComponent(namespace)}/${encodeURIComponent(
kind,
@@ -26,14 +26,16 @@ import { techInsightsApiRef } from '../../api/TechInsightsApi';
export const ScorecardsOverview = ({
title,
description,
checksId,
}: {
title?: string;
description?: string;
checksId?: string[];
}) => {
const api = useApi(techInsightsApiRef);
const { namespace, kind, name } = useParams();
const { value, loading, error } = useAsync(
async () => await api.runChecks({ namespace, kind, name }),
async () => await api.runChecks({ namespace, kind, name }, checksId),
);
if (loading) {