fix(cicd-statistics): Added entity option to getConfiguration
Signed-off-by: Gustaf Räntilä <g.rantila@gmail.com>
This commit is contained in:
@@ -82,7 +82,9 @@ export interface CicdStatisticsApi {
|
||||
// (undocumented)
|
||||
fetchBuilds(options: FetchBuildsOptions): Promise<CicdState>;
|
||||
// (undocumented)
|
||||
getConfiguration(): Promise<Partial<CicdConfiguration>>;
|
||||
getConfiguration(
|
||||
options: GetConfigurationOptions,
|
||||
): Promise<Partial<CicdConfiguration>>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "cicdStatisticsApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
@@ -150,9 +152,15 @@ export type FilterStatusType<Extra extends string = never> =
|
||||
| 'expired';
|
||||
|
||||
// Warning: (ae-missing-release-tag) "rootCatalogCicdStatsRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
// Warning: (ae-missing-release-tag) "GetConfigurationOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export const rootCatalogCicdStatsRouteRef: RouteRef<undefined>;
|
||||
// @public
|
||||
export interface GetConfigurationOptions {
|
||||
// (undocumented)
|
||||
entity: Entity;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "Stage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
|
||||
@@ -195,6 +195,14 @@ export type UpdateProgress = (
|
||||
started?: number,
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* When reading configuration, the Api can return a custom settings depending on
|
||||
* the entity being viewed.
|
||||
*/
|
||||
export interface GetConfigurationOptions {
|
||||
entity: Entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* When fetching, the Api should fetch build information about the `entity` and
|
||||
* respect the `timeFrom`, `timeTo`, `filterStatus` and `filterType`.
|
||||
@@ -220,6 +228,8 @@ export interface FetchBuildsOptions {
|
||||
* the UI.
|
||||
*/
|
||||
export interface CicdStatisticsApi {
|
||||
getConfiguration(): Promise<Partial<CicdConfiguration>>;
|
||||
getConfiguration(
|
||||
options: GetConfigurationOptions,
|
||||
): Promise<Partial<CicdConfiguration>>;
|
||||
fetchBuilds(options: FetchBuildsOptions): Promise<CicdState>;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
|
||||
import { CicdConfiguration, statusTypes } from '../apis';
|
||||
import { Progress } from '../components/progress';
|
||||
@@ -23,6 +24,7 @@ import { useCicdStatisticsApi } from './use-cicd-statistics-api';
|
||||
|
||||
export function useCicdConfiguration(): Progress<CicdConfiguration> {
|
||||
const cicdStatisticsApi = useCicdStatisticsApi();
|
||||
const { entity } = useEntity();
|
||||
|
||||
const [state, setState] = useState<Progress<CicdConfiguration>>({
|
||||
loading: true,
|
||||
@@ -35,7 +37,7 @@ export function useCicdConfiguration(): Progress<CicdConfiguration> {
|
||||
}
|
||||
|
||||
cicdStatisticsApi
|
||||
.getConfiguration()
|
||||
.getConfiguration({ entity })
|
||||
.then(configuration => {
|
||||
const {
|
||||
availableStatuses = statusTypes,
|
||||
@@ -53,7 +55,7 @@ export function useCicdConfiguration(): Progress<CicdConfiguration> {
|
||||
.catch(error => {
|
||||
setState({ error });
|
||||
});
|
||||
}, [cicdStatisticsApi]);
|
||||
}, [cicdStatisticsApi, entity]);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user