more api cleanup

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-08-18 14:11:45 +02:00
parent e195112c5c
commit 3f739be9d9
88 changed files with 358 additions and 594 deletions
+3 -57
View File
@@ -21,23 +21,17 @@ import { RepoBuildOptions } from '@backstage/plugin-azure-devops-common';
import { SvgIconProps } from '@material-ui/core';
import { Team } from '@backstage/plugin-azure-devops-common';
// Warning: (ae-missing-release-tag) "AllFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type AllFilter = BaseFilter & {
type: FilterType.All;
};
// Warning: (ae-missing-release-tag) "AssignedToTeamFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type AssignedToTeamFilter = BaseFilter & {
type: FilterType.AssignedToTeam;
teamId: string;
};
// Warning: (ae-missing-release-tag) "AssignedToTeamsFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type AssignedToTeamsFilter = BaseFilter &
(
@@ -51,8 +45,6 @@ export type AssignedToTeamsFilter = BaseFilter &
}
);
// Warning: (ae-missing-release-tag) "AssignedToUserFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type AssignedToUserFilter = BaseFilter &
(
@@ -66,8 +58,6 @@ export type AssignedToUserFilter = BaseFilter &
}
);
// Warning: (ae-missing-release-tag) "AzureDevOpsApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface AzureDevOpsApi {
// (undocumented)
@@ -112,13 +102,9 @@ export interface AzureDevOpsApi {
getUserTeamIds(userId: string): Promise<string[]>;
}
// Warning: (ae-missing-release-tag) "azureDevOpsApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const azureDevOpsApiRef: ApiRef<AzureDevOpsApi>;
// Warning: (ae-missing-release-tag) "AzureDevOpsClient" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export class AzureDevOpsClient implements AzureDevOpsApi {
constructor(options: {
@@ -167,38 +153,24 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
getUserTeamIds(userId: string): Promise<string[]>;
}
// Warning: (ae-missing-release-tag) "azureDevOpsPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const azureDevOpsPlugin: BackstagePlugin<{}, {}, {}>;
// Warning: (ae-missing-release-tag) "AzurePullRequestsIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const AzurePullRequestsIcon: (props: SvgIconProps) => JSX.Element;
// Warning: (ae-missing-release-tag) "AzurePullRequestsPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const AzurePullRequestsPage: ({
projectName,
pollingInterval,
defaultColumnConfigs,
}: {
export const AzurePullRequestsPage: (props: {
projectName?: string | undefined;
pollingInterval?: number | undefined;
defaultColumnConfigs?: PullRequestColumnConfig[] | undefined;
}) => JSX.Element;
// Warning: (ae-missing-release-tag) "BaseFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type BaseFilter = {
type: FilterType;
};
// Warning: (ae-missing-release-tag) "CreatedByTeamFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CreatedByTeamFilter = BaseFilter &
({
@@ -212,8 +184,6 @@ export type CreatedByTeamFilter = BaseFilter &
}
));
// Warning: (ae-missing-release-tag) "CreatedByTeamsFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CreatedByTeamsFilter = BaseFilter &
(
@@ -233,8 +203,6 @@ export type CreatedByTeamsFilter = BaseFilter &
}
);
// Warning: (ae-missing-release-tag) "CreatedByUserFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CreatedByUserFilter = BaseFilter &
(
@@ -248,31 +216,19 @@ export type CreatedByUserFilter = BaseFilter &
}
);
// Warning: (ae-missing-release-tag) "EntityAzureGitTagsContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityAzureGitTagsContent: () => JSX.Element;
// Warning: (ae-missing-release-tag) "EntityAzurePipelinesContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityAzurePipelinesContent: ({
defaultLimit,
}: {
export const EntityAzurePipelinesContent: (props: {
defaultLimit?: number | undefined;
}) => JSX.Element;
// Warning: (ae-missing-release-tag) "EntityAzurePullRequestsContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityAzurePullRequestsContent: ({
defaultLimit,
}: {
export const EntityAzurePullRequestsContent: (props: {
defaultLimit?: number | undefined;
}) => JSX.Element;
// Warning: (ae-missing-release-tag) "Filter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type Filter =
| AssignedToUserFilter
@@ -283,8 +239,6 @@ export type Filter =
| CreatedByTeamsFilter
| AllFilter;
// Warning: (ae-missing-release-tag) "FilterType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export enum FilterType {
// (undocumented)
@@ -311,18 +265,12 @@ export enum FilterType {
CreatedByUser = 'CreatedByUser',
}
// Warning: (ae-missing-release-tag) "isAzureDevOpsAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const isAzureDevOpsAvailable: (entity: Entity) => boolean;
// Warning: (ae-missing-release-tag) "isAzurePipelinesAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const isAzurePipelinesAvailable: (entity: Entity) => boolean;
// Warning: (ae-missing-release-tag) "PullRequestColumnConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface PullRequestColumnConfig {
// (undocumented)
@@ -333,8 +281,6 @@ export interface PullRequestColumnConfig {
title: string;
}
// Warning: (ae-missing-release-tag) "PullRequestFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PullRequestFilter = (pullRequest: DashboardPullRequest) => boolean;
@@ -28,10 +28,12 @@ import {
import { createApiRef } from '@backstage/core-plugin-api';
/** @public */
export const azureDevOpsApiRef = createApiRef<AzureDevOpsApi>({
id: 'plugin.azure-devops.service',
});
/** @public */
export interface AzureDevOpsApi {
getRepoBuilds(
projectName: string,
@@ -26,10 +26,10 @@ import {
Team,
} from '@backstage/plugin-azure-devops-common';
import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
import { AzureDevOpsApi } from './AzureDevOpsApi';
import { ResponseError } from '@backstage/errors';
import { AzureDevOpsApi } from './AzureDevOpsApi';
/** @public */
export class AzureDevOpsClient implements AzureDevOpsApi {
private readonly discoveryApi: DiscoveryApi;
private readonly identityApi: IdentityApi;
@@ -14,10 +14,10 @@
* limitations under the License.
*/
import React from 'react';
import { SvgIcon, SvgIconProps } from '@material-ui/core';
import React from 'react';
/** @public */
export const AzurePullRequestsIcon = (props: SvgIconProps) => (
<SvgIcon {...props} viewBox="0 0 512 512">
<circle
@@ -20,18 +20,14 @@ import { getAnnotationFromEntity } from '../../utils/getAnnotationFromEntity';
import { useBuildRuns } from '../../hooks/useBuildRuns';
import { useEntity } from '@backstage/plugin-catalog-react';
export const EntityPageAzurePipelines = ({
defaultLimit,
}: {
defaultLimit?: number;
}) => {
export const EntityPageAzurePipelines = (props: { defaultLimit?: number }) => {
const { entity } = useEntity();
const { project, repo, definition } = getAnnotationFromEntity(entity);
const { items, loading, error } = useBuildRuns(
project,
defaultLimit,
props.defaultLimit,
repo,
definition,
);
@@ -17,10 +17,8 @@
import { PullRequestTable } from '../PullRequestTable/PullRequestTable';
import React from 'react';
export const EntityPageAzurePullRequests = ({
defaultLimit,
}: {
export const EntityPageAzurePullRequests = (props: {
defaultLimit?: number;
}) => {
return <PullRequestTable defaultLimit={defaultLimit} />;
return <PullRequestTable defaultLimit={props.defaultLimit} />;
};
@@ -24,7 +24,6 @@ import {
import { PullRequestColumnConfig, PullRequestGroup } from './lib/types';
import React, { useState } from 'react';
import { getPullRequestGroupConfigs, getPullRequestGroups } from './lib/utils';
import { FilterType } from './lib/filters';
import { PullRequestGrid } from './lib/PullRequestGrid';
import { useDashboardPullRequests } from '../../hooks';
@@ -71,11 +70,9 @@ type PullRequestsPageProps = {
defaultColumnConfigs?: PullRequestColumnConfig[];
};
export const PullRequestsPage = ({
projectName,
pollingInterval,
defaultColumnConfigs,
}: PullRequestsPageProps) => {
export const PullRequestsPage = (props: PullRequestsPageProps) => {
const { projectName, pollingInterval, defaultColumnConfigs } = props;
const { pullRequests, loading, error } = useDashboardPullRequests(
projectName,
pollingInterval,
@@ -18,6 +18,7 @@ import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
/** @public */
export type AllFilter = BaseFilter & {
type: FilterType.All;
};
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { stringArrayHas } from '../../../../utils';
/** @public */
export type AssignedToTeamFilter = BaseFilter & {
type: FilterType.AssignedToTeam;
teamId: string;
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { createAssignedToTeamFilter } from './assignedToTeamFilter';
/** @public */
export type AssignedToTeamsFilter = BaseFilter &
(
| {
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { stringArrayHas } from '../../../../utils';
/** @public */
export type AssignedToUserFilter = BaseFilter &
(
| {
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { stringArrayHas } from '../../../../utils';
/** @public */
export type CreatedByTeamFilter = BaseFilter &
({
type: FilterType.CreatedByTeam;
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { createCreatedByTeamFilter } from './createdByTeamFilter';
/** @public */
export type CreatedByTeamsFilter = BaseFilter &
(
| ({
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
import { BaseFilter, FilterType, PullRequestFilter } from './types';
import { equalsIgnoreCase } from '../../../../utils';
/** @public */
export type CreatedByUserFilter = BaseFilter &
(
| {
@@ -23,6 +23,7 @@ import { CreatedByTeamsFilter } from './createdByTeamsFilter';
import { CreatedByUserFilter } from './createdByUserFilter';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
/** @public */
export enum FilterType {
All = 'All',
@@ -41,6 +42,7 @@ export enum FilterType {
CreatedByCurrentUsersTeams = 'CreatedByCurrentUsersTeams',
}
/** @public */
export const FilterTypes = [
FilterType.All,
@@ -57,10 +59,12 @@ export const FilterTypes = [
FilterType.CreatedByCurrentUsersTeams,
] as const;
/** @public */
export type BaseFilter = {
type: FilterType;
};
/** @public */
export type Filter =
| AssignedToUserFilter
| CreatedByUserFilter
@@ -80,4 +84,5 @@ export type {
AllFilter,
};
/** @public */
export type PullRequestFilter = (pullRequest: DashboardPullRequest) => boolean;
@@ -14,22 +14,24 @@
* limitations under the License.
*/
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
import { Filter, PullRequestFilter } from './filters';
import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
/** @public */
export interface PullRequestColumnConfig {
title: string;
filters: Filter[];
simplified?: boolean;
}
/** @public */
export interface PullRequestGroupConfig {
title: string;
filter: PullRequestFilter;
simplified?: boolean;
}
/** @public */
export interface PullRequestGroup {
title: string;
pullRequests: DashboardPullRequest[];
+7
View File
@@ -37,9 +37,11 @@ import { AzureDevOpsClient } from './api/AzureDevOpsClient';
import { Entity } from '@backstage/catalog-model';
import { azureDevOpsApiRef } from './api/AzureDevOpsApi';
/** @public */
export const isAzureDevOpsAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[AZURE_DEVOPS_REPO_ANNOTATION]);
/** @public */
export const isAzurePipelinesAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[AZURE_DEVOPS_REPO_ANNOTATION]) ||
(Boolean(entity.metadata.annotations?.[AZURE_DEVOPS_PROJECT_ANNOTATION]) &&
@@ -47,6 +49,7 @@ export const isAzurePipelinesAvailable = (entity: Entity) =>
entity.metadata.annotations?.[AZURE_DEVOPS_BUILD_DEFINITION_ANNOTATION],
));
/** @public */
export const azureDevOpsPlugin = createPlugin({
id: 'azureDevOps',
apis: [
@@ -59,6 +62,7 @@ export const azureDevOpsPlugin = createPlugin({
],
});
/** @public */
export const AzurePullRequestsPage = azureDevOpsPlugin.provide(
createRoutableExtension({
name: 'AzurePullRequestsPage',
@@ -68,6 +72,7 @@ export const AzurePullRequestsPage = azureDevOpsPlugin.provide(
}),
);
/** @public */
export const EntityAzurePipelinesContent = azureDevOpsPlugin.provide(
createRoutableExtension({
name: 'EntityAzurePipelinesContent',
@@ -79,6 +84,7 @@ export const EntityAzurePipelinesContent = azureDevOpsPlugin.provide(
}),
);
/** @public */
export const EntityAzureGitTagsContent = azureDevOpsPlugin.provide(
createRoutableExtension({
name: 'EntityAzureGitTagsContent',
@@ -90,6 +96,7 @@ export const EntityAzureGitTagsContent = azureDevOpsPlugin.provide(
}),
);
/** @public */
export const EntityAzurePullRequestsContent = azureDevOpsPlugin.provide(
createRoutableExtension({
name: 'EntityAzurePullRequestsContent',