Merge branch 'master' of https://github.com/backstage/backstage into marley/7641-consume-exported-ado-types
Signed-off-by: Marley Powell <Marley.Powell@exclaimer.com>
This commit is contained in:
@@ -155,13 +155,13 @@ const columns: TableColumn[] = [
|
||||
},
|
||||
];
|
||||
|
||||
type Props = {
|
||||
type BuildTableProps = {
|
||||
items?: RepoBuild[];
|
||||
loading: boolean;
|
||||
error?: any;
|
||||
error?: Error;
|
||||
};
|
||||
|
||||
export const BuildTable = ({ items, loading, error }: Props) => {
|
||||
export const BuildTable = ({ items, loading, error }: BuildTableProps) => {
|
||||
if (error) {
|
||||
return (
|
||||
<div>
|
||||
@@ -181,7 +181,7 @@ export const BuildTable = ({ items, loading, error }: Props) => {
|
||||
showEmptyDataSourceMessage: !loading,
|
||||
}}
|
||||
title={`Builds (${items ? items.length : 0})`}
|
||||
data={items || []}
|
||||
data={items ?? []}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -14,28 +14,31 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { useAsync } from 'react-use';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
import { azureDevOpsApiRef } from '../api';
|
||||
import { RepoBuild, RepoBuildOptions } from '../api/types';
|
||||
import { useProjectRepoFromEntity } from './useProjectRepoFromEntity';
|
||||
|
||||
import { AZURE_DEVOPS_DEFAULT_TOP } from '../constants';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { azureDevOpsApiRef } from '../api';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
import { useAsync } from 'react-use';
|
||||
import { useProjectRepoFromEntity } from './useProjectRepoFromEntity';
|
||||
|
||||
export function useRepoBuilds(
|
||||
entity: Entity,
|
||||
defaultLimit?: number,
|
||||
): {
|
||||
items: RepoBuild[] | undefined;
|
||||
items?: RepoBuild[];
|
||||
loading: boolean;
|
||||
error: any;
|
||||
error?: Error;
|
||||
} {
|
||||
const top = defaultLimit ?? AZURE_DEVOPS_DEFAULT_TOP;
|
||||
const options: RepoBuildOptions = {
|
||||
top: top,
|
||||
};
|
||||
|
||||
const api = useApi(azureDevOpsApiRef);
|
||||
const { project, repo } = useProjectRepoFromEntity(entity);
|
||||
|
||||
const { value, loading, error } = useAsync(() => {
|
||||
return api.getRepoBuilds(project, repo, options);
|
||||
}, [api, project, repo, entity]);
|
||||
|
||||
Reference in New Issue
Block a user