;
-// @public
+// @alpha
export const atlassianAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>;
@@ -206,27 +195,26 @@ export function attachComponentData(
data: unknown,
): void;
-// @public
+// @public @deprecated
export const auth0AuthApiRef: ApiRef<
OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>;
+// @public @deprecated (undocumented)
+export type AuthProvider = Omit;
+
// @public
-export type AuthProvider = {
+export type AuthProviderInfo = {
+ id: string;
title: string;
icon: IconComponent;
};
-// @public
-export type AuthRequester = (
- scopes: Set,
-) => Promise;
+// @public @deprecated (undocumented)
+export type AuthRequester = OAuthRequester;
-// @public
-export type AuthRequesterOptions = {
- provider: AuthProvider;
- onAuthRequest(scopes: Set): Promise;
-};
+// @public @deprecated (undocumented)
+export type AuthRequesterOptions = OAuthRequesterOptions;
// @public
export type AuthRequestOptions = {
@@ -272,7 +260,7 @@ export type BackstageUserIdentity = {
ownershipEntityRefs: string[];
};
-// @public
+// @alpha
export const bitbucketAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>;
@@ -283,7 +271,7 @@ export type BootErrorPageProps = {
error: Error;
};
-// @public
+// @alpha
export type CommonAnalyticsContext = {
pluginId: string;
routeRef: string;
@@ -506,23 +494,31 @@ export enum FeatureFlagState {
None = 0,
}
+// @public
+export type FetchApi = {
+ fetch: typeof fetch;
+};
+
+// @public
+export const fetchApiRef: ApiRef;
+
// @public
export function getComponentData(
node: ReactNode,
type: string,
): T | undefined;
-// @public
+// @alpha
export const githubAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>;
-// @public
+// @alpha
export const gitlabAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
>;
-// @public
+// @alpha
export const googleAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
@@ -570,7 +566,7 @@ export type MergeParams<
P2 extends AnyParams,
> = (P1[keyof P1] extends never ? {} : P1) & (P2 extends undefined ? {} : P2);
-// @public
+// @alpha
export const microsoftAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
@@ -579,7 +575,7 @@ export const microsoftAuthApiRef: ApiRef<
SessionApi
>;
-// @public
+// @public @deprecated
export const oauth2ApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
@@ -598,15 +594,28 @@ export type OAuthApi = {
// @public
export type OAuthRequestApi = {
- createAuthRequester(
- options: AuthRequesterOptions,
- ): AuthRequester;
- authRequest$(): Observable_2;
+ createAuthRequester(
+ options: OAuthRequesterOptions,
+ ): OAuthRequester;
+ authRequest$(): Observable_2;
};
// @public
export const oauthRequestApiRef: ApiRef;
+// @public
+export type OAuthRequester = (
+ scopes: Set,
+) => Promise;
+
+// @public
+export type OAuthRequesterOptions = {
+ provider: Omit & {
+ id?: string;
+ };
+ onAuthRequest(scopes: Set): Promise;
+};
+
// @public
export type OAuthScope = string | string[];
@@ -616,7 +625,7 @@ export type Observable = Observable_2;
// @public @deprecated
export type Observer = Observer_2;
-// @public
+// @public @deprecated
export const oidcAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
@@ -625,7 +634,7 @@ export const oidcAuthApiRef: ApiRef<
SessionApi
>;
-// @public
+// @alpha
export const oktaAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
@@ -637,7 +646,7 @@ export const oktaAuthApiRef: ApiRef<
// @public
export type OldIconComponent = ComponentType;
-// @public
+// @alpha
export const oneloginAuthApiRef: ApiRef<
OAuthApi &
OpenIdConnectApi &
@@ -679,10 +688,15 @@ export type PathParams = {
[name in ParamNames]: string;
};
+// @public @deprecated (undocumented)
+export type PendingAuthRequest = PendingOAuthRequest;
+
// @public
-export type PendingAuthRequest = {
- provider: AuthProvider;
- reject: () => void;
+export type PendingOAuthRequest = {
+ provider: Omit & {
+ id?: string;
+ };
+ reject(): void;
trigger(): Promise;
};
@@ -738,7 +752,7 @@ export type RouteRef = {
title?: string;
};
-// @public
+// @public @deprecated
export const samlAuthApiRef: ApiRef<
ProfileInfoApi & BackstageIdentityApi & SessionApi
>;
@@ -803,7 +817,7 @@ export type TypesToApiRefs = {
[key in keyof T]: ApiRef;
};
-// @public
+// @alpha
export function useAnalytics(): AnalyticsTracker;
// @public
diff --git a/packages/core-plugin-api/package.json b/packages/core-plugin-api/package.json
index 72827bde73..20479acfeb 100644
--- a/packages/core-plugin-api/package.json
+++ b/packages/core-plugin-api/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/core-plugin-api",
"description": "Core API used by Backstage plugins",
- "version": "0.3.0",
+ "version": "0.3.1",
"private": false,
"publishConfig": {
"access": "public",
@@ -45,8 +45,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^11.2.5",
diff --git a/packages/core-plugin-api/src/analytics/AnalyticsContext.tsx b/packages/core-plugin-api/src/analytics/AnalyticsContext.tsx
index 075cdff3ff..af362cd921 100644
--- a/packages/core-plugin-api/src/analytics/AnalyticsContext.tsx
+++ b/packages/core-plugin-api/src/analytics/AnalyticsContext.tsx
@@ -60,7 +60,7 @@ export const useAnalyticsContext = (): AnalyticsContextValue => {
* Analytics contexts are additive, meaning the context ultimately emitted with
* an event is the combination of all contexts in the parent tree.
*
- * @public
+ * @alpha
*/
export const AnalyticsContext = (options: {
attributes: Partial;
diff --git a/packages/core-plugin-api/src/analytics/types.ts b/packages/core-plugin-api/src/analytics/types.ts
index d001c38d3e..431e453a61 100644
--- a/packages/core-plugin-api/src/analytics/types.ts
+++ b/packages/core-plugin-api/src/analytics/types.ts
@@ -17,7 +17,7 @@
/**
* Common analytics context attributes.
*
- * @public
+ * @alpha
*/
export type CommonAnalyticsContext = {
/**
@@ -40,6 +40,7 @@ export type CommonAnalyticsContext = {
* Allows arbitrary scalar values as context attributes too.
*
* @public
+ * @deprecated Will be removed, use `AnalyticsContextValue` instead
*/
export type AnyAnalyticsContext = {
[param in string]: string | boolean | number | undefined;
@@ -48,7 +49,8 @@ export type AnyAnalyticsContext = {
/**
* Analytics context envelope.
*
- * @public
+ * @alpha
*/
-export type AnalyticsContextValue = CommonAnalyticsContext &
- AnyAnalyticsContext;
+export type AnalyticsContextValue = CommonAnalyticsContext & {
+ [param in string]: string | boolean | number | undefined;
+};
diff --git a/packages/core-plugin-api/src/analytics/useAnalytics.tsx b/packages/core-plugin-api/src/analytics/useAnalytics.tsx
index 5a047e5a63..f1297c5e4e 100644
--- a/packages/core-plugin-api/src/analytics/useAnalytics.tsx
+++ b/packages/core-plugin-api/src/analytics/useAnalytics.tsx
@@ -35,7 +35,7 @@ function useAnalyticsApi(): AnalyticsApi {
/**
* Gets a pre-configured analytics tracker.
*
- * @public
+ * @alpha
*/
export function useAnalytics(): AnalyticsTracker {
const trackerRef = useRef(null);
diff --git a/packages/core-plugin-api/src/apis/definitions/AnalyticsApi.ts b/packages/core-plugin-api/src/apis/definitions/AnalyticsApi.ts
index ef190d6c21..dc38d7a250 100644
--- a/packages/core-plugin-api/src/apis/definitions/AnalyticsApi.ts
+++ b/packages/core-plugin-api/src/apis/definitions/AnalyticsApi.ts
@@ -21,7 +21,7 @@ import { AnalyticsContextValue } from '../../analytics/types';
* Represents an event worth tracking in an analytics system that could inform
* how users of a Backstage instance are using its features.
*
- * @public
+ * @alpha
*/
export type AnalyticsEvent = {
/**
@@ -79,7 +79,7 @@ export type AnalyticsEvent = {
* A structure allowing other arbitrary metadata to be provided by analytics
* event emitters.
*
- * @public
+ * @alpha
*/
export type AnalyticsEventAttributes = {
[attribute in string]: string | boolean | number;
@@ -89,7 +89,7 @@ export type AnalyticsEventAttributes = {
* Represents a tracker with methods that can be called to track events in a
* configured analytics service.
*
- * @public
+ * @alpha
*/
export type AnalyticsTracker = {
captureEvent: (
@@ -103,6 +103,8 @@ export type AnalyticsTracker = {
};
/**
+ * **EXPERIMENTAL**
+ *
* The Analytics API is used to track user behavior in a Backstage instance.
*
* @remarks
@@ -111,7 +113,7 @@ export type AnalyticsTracker = {
* useAnalytics() hook. This will return a pre-configured AnalyticsTracker
* with relevant methods for instrumentation.
*
- * @public
+ * @alpha
*/
export type AnalyticsApi = {
/**
@@ -122,9 +124,11 @@ export type AnalyticsApi = {
};
/**
+ * **EXPERIMENTAL**
+ *
* The {@link ApiRef} of {@link AnalyticsApi}.
*
- * @public
+ * @alpha
*/
export const analyticsApiRef: ApiRef = createApiRef({
id: 'core.analytics',
diff --git a/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts b/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts
index 45ee0901c8..364a7bd29a 100644
--- a/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts
+++ b/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts
@@ -41,7 +41,15 @@ export type Error = ErrorApiError;
* @public
*/
export type ErrorApiErrorContext = {
- // If set to true, this error should not be displayed to the user. Defaults to false.
+ /**
+ * If set to true, this error should not be displayed to the user.
+ *
+ * Hidden errors are typically not displayed in the UI, but the ErrorApi
+ * implementation may still report them to error tracking services
+ * or other utilities that care about all errors.
+ *
+ * @defaultValue false
+ */
hidden?: boolean;
};
diff --git a/packages/core-plugin-api/src/apis/definitions/FetchApi.ts b/packages/core-plugin-api/src/apis/definitions/FetchApi.ts
new file mode 100644
index 0000000000..ba304157ea
--- /dev/null
+++ b/packages/core-plugin-api/src/apis/definitions/FetchApi.ts
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ApiRef, createApiRef } from '../system';
+
+/**
+ * A wrapper for the fetch API, that has additional behaviors such as the
+ * ability to automatically inject auth information where necessary.
+ *
+ * @public
+ */
+export type FetchApi = {
+ fetch: typeof fetch;
+};
+
+/**
+ * A wrapper for the fetch API, that has additional behaviors such as the
+ * ability to automatically inject auth information where necessary.
+ *
+ * @public
+ */
+export const fetchApiRef: ApiRef = createApiRef({
+ id: 'core.fetch',
+});
diff --git a/packages/core-plugin-api/src/apis/definitions/OAuthRequestApi.ts b/packages/core-plugin-api/src/apis/definitions/OAuthRequestApi.ts
index 03e129ef6a..5b8dab29f7 100644
--- a/packages/core-plugin-api/src/apis/definitions/OAuthRequestApi.ts
+++ b/packages/core-plugin-api/src/apis/definitions/OAuthRequestApi.ts
@@ -14,31 +14,15 @@
* limitations under the License.
*/
-import { IconComponent } from '../../icons/types';
import { Observable } from '@backstage/types';
import { ApiRef, createApiRef } from '../system';
+import { AuthProviderInfo } from './auth';
/**
- * Information about the auth provider that we're requesting a login towards.
- *
- * @remarks
- *
- * This should be shown to the user so that they can be informed about what login is being requested
- * before a popup is shown.
- *
* @public
+ * @deprecated Use AuthProviderInfo instead
*/
-export type AuthProvider = {
- /**
- * Title for the auth provider, for example "GitHub"
- */
- title: string;
-
- /**
- * Icon for the auth provider.
- */
- icon: IconComponent;
-};
+export type AuthProvider = Omit;
/**
* Describes how to handle auth requests. Both how to show them to the user, and what to do when
@@ -46,26 +30,34 @@ export type AuthProvider = {
*
* @public
*/
-export type AuthRequesterOptions = {
+export type OAuthRequesterOptions = {
/**
* Information about the auth provider, which will be forwarded to auth requests.
+ *
+ * Not passing in an `id` is deprecated, and it will be required in the future.
*/
- provider: AuthProvider;
+ provider: Omit & { id?: string };
/**
* Implementation of the auth flow, which will be called synchronously when
* trigger() is called on an auth requests.
*/
- onAuthRequest(scopes: Set): Promise;
+ onAuthRequest(scopes: Set): Promise;
};
+/**
+ * @public
+ * @deprecated Use OAuthRequesterOptions instead
+ */
+export type AuthRequesterOptions = OAuthRequesterOptions;
+
/**
* Function used to trigger new auth requests for a set of scopes.
*
* @remarks
*
* The returned promise will resolve to the same value returned by the onAuthRequest in the
- * {@link AuthRequesterOptions}. Or rejected, if the request is rejected.
+ * {@link OAuthRequesterOptions}. Or rejected, if the request is rejected.
*
* This function can be called multiple times before the promise resolves. All calls
* will be merged into one request, and the scopes forwarded to the onAuthRequest will be the
@@ -73,9 +65,15 @@ export type AuthRequesterOptions = {
*
* @public
*/
-export type AuthRequester = (
+export type OAuthRequester = (
scopes: Set,
-) => Promise;
+) => Promise;
+
+/**
+ * @public
+ * @deprecated Use OAuthRequester instead
+ */
+export type AuthRequester = OAuthRequester;
/**
* An pending auth request for a single auth provider. The request will remain in this pending
@@ -88,16 +86,18 @@ export type AuthRequester = (
*
* @public
*/
-export type PendingAuthRequest = {
+export type PendingOAuthRequest = {
/**
* Information about the auth provider, as given in the AuthRequesterOptions
+ *
+ * Not passing in an `id` is deprecated, and it will be required in the future.
*/
- provider: AuthProvider;
+ provider: Omit & { id?: string };
/**
* Rejects the request, causing all pending AuthRequester calls to fail with "RejectedError".
*/
- reject: () => void;
+ reject(): void;
/**
* Trigger the auth request to continue the auth flow, by for example showing a popup.
@@ -107,6 +107,12 @@ export type PendingAuthRequest = {
trigger(): Promise;
};
+/**
+ * @public
+ * @deprecated Use PendingOAuthRequest instead
+ */
+export type PendingAuthRequest = PendingOAuthRequest;
+
/**
* Provides helpers for implemented OAuth login flows within Backstage.
*
@@ -125,9 +131,9 @@ export type OAuthRequestApi = {
*
* See AuthRequesterOptions, AuthRequester, and handleAuthRequests for more info.
*/
- createAuthRequester(
- options: AuthRequesterOptions,
- ): AuthRequester;
+ createAuthRequester(
+ options: OAuthRequesterOptions,
+ ): OAuthRequester;
/**
* Observers pending auth requests. The returned observable will emit all
@@ -140,7 +146,7 @@ export type OAuthRequestApi = {
* If a auth is triggered, and the auth handler resolves successfully, then all currently pending
* AuthRequester calls will resolve to the value returned by the onAuthRequest call.
*/
- authRequest$(): Observable;
+ authRequest$(): Observable;
};
/**
diff --git a/packages/core-plugin-api/src/apis/definitions/auth.ts b/packages/core-plugin-api/src/apis/definitions/auth.ts
index 37308ec29b..a362d16750 100644
--- a/packages/core-plugin-api/src/apis/definitions/auth.ts
+++ b/packages/core-plugin-api/src/apis/definitions/auth.ts
@@ -15,6 +15,7 @@
*/
import { ApiRef, createApiRef } from '../system';
+import { IconComponent } from '../../icons/types';
import { Observable } from '@backstage/types';
/**
@@ -28,6 +29,33 @@ import { Observable } from '@backstage/types';
* const googleAuthApiRef = createApiRef({ ... })
*/
+/**
+ * Information about the auth provider.
+ *
+ * @remarks
+ *
+ * This information is used both to connect the correct auth provider in the backend, as
+ * well as displaying the provider to the user.
+ *
+ * @public
+ */
+export type AuthProviderInfo = {
+ /**
+ * The ID of the auth provider. This should match with ID of the provider in the `@backstage/auth-backend`.
+ */
+ id: string;
+
+ /**
+ * Title for the auth provider, for example "GitHub"
+ */
+ title: string;
+
+ /**
+ * Icon for the auth provider.
+ */
+ icon: IconComponent;
+};
+
/**
* An array of scopes, or a scope string formatted according to the
* auth provider, which is typically a space separated list.
@@ -282,14 +310,14 @@ export type SessionApi = {
/**
* Provides authentication towards Google APIs and identities.
*
+ * @alpha This API is **EXPERIMENTAL** and might change in the future.
+ *
* @remarks
*
* See {@link https://developers.google.com/identity/protocols/googlescopes} for a full list of supported scopes.
*
* Note that the ID token payload is only guaranteed to contain the user's numerical Google ID,
* email and expiration information. Do not rely on any other fields, as they might not be present.
- *
- * @public
*/
export const googleAuthApiRef: ApiRef<
OAuthApi &
@@ -304,12 +332,12 @@ export const googleAuthApiRef: ApiRef<
/**
* Provides authentication towards GitHub APIs.
*
+ * @alpha This API is **EXPERIMENTAL** and might change in the future.
+ *
* @remarks
*
* See {@link https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/}
* for a full list of supported scopes.
- *
- * @public
*/
export const githubAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
@@ -320,12 +348,12 @@ export const githubAuthApiRef: ApiRef<
/**
* Provides authentication towards Okta APIs.
*
+ * @alpha This API is **EXPERIMENTAL** and might change in the future.
+ *
* @remarks
*
* See {@link https://developer.okta.com/docs/guides/implement-oauth-for-okta/scopes/}
* for a full list of supported scopes.
- *
- * @public
*/
export const oktaAuthApiRef: ApiRef<
OAuthApi &
@@ -340,12 +368,12 @@ export const oktaAuthApiRef: ApiRef<
/**
* Provides authentication towards GitLab APIs.
*
+ * @alpha This API is **EXPERIMENTAL** and might change in the future.
+ *
* @remarks
*
* See {@link https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#limiting-scopes-of-a-personal-access-token}
* for a full list of supported scopes.
- *
- * @public
*/
export const gitlabAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
@@ -362,6 +390,7 @@ export const gitlabAuthApiRef: ApiRef<
* for a full list of supported scopes.
*
* @public
+ * @deprecated See https://backstage.io/docs/api/deprecations#generic-auth-api-refs
*/
export const auth0AuthApiRef: ApiRef<
OpenIdConnectApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
@@ -372,13 +401,13 @@ export const auth0AuthApiRef: ApiRef<
/**
* Provides authentication towards Microsoft APIs and identities.
*
+ * @alpha This API is **EXPERIMENTAL** and might change in the future.
+ *
* @remarks
*
* For more info and a full list of supported scopes, see:
* - {@link https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent}
* - {@link https://docs.microsoft.com/en-us/graph/permissions-reference}
- *
- * @public
*/
export const microsoftAuthApiRef: ApiRef<
OAuthApi &
@@ -394,6 +423,7 @@ export const microsoftAuthApiRef: ApiRef<
* Provides authentication for custom identity providers.
*
* @public
+ * @deprecated See https://backstage.io/docs/api/deprecations#generic-auth-api-refs
*/
export const oauth2ApiRef: ApiRef<
OAuthApi &
@@ -409,6 +439,7 @@ export const oauth2ApiRef: ApiRef<
* Provides authentication for custom OpenID Connect identity providers.
*
* @public
+ * @deprecated See https://backstage.io/docs/api/deprecations#generic-auth-api-refs
*/
export const oidcAuthApiRef: ApiRef<
OAuthApi &
@@ -424,6 +455,7 @@ export const oidcAuthApiRef: ApiRef<
* Provides authentication for SAML-based identity providers.
*
* @public
+ * @deprecated See https://backstage.io/docs/api/deprecations#generic-auth-api-refs
*/
export const samlAuthApiRef: ApiRef<
ProfileInfoApi & BackstageIdentityApi & SessionApi
@@ -434,7 +466,7 @@ export const samlAuthApiRef: ApiRef<
/**
* Provides authentication towards OneLogin APIs.
*
- * @public
+ * @alpha This API is **EXPERIMENTAL** and might change in the future.
*/
export const oneloginAuthApiRef: ApiRef<
OAuthApi &
@@ -449,12 +481,11 @@ export const oneloginAuthApiRef: ApiRef<
/**
* Provides authentication towards Bitbucket APIs.
*
+ * @alpha This API is **EXPERIMENTAL** and might change in the future.
* @remarks
*
* See {@link https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/}
* for a full list of supported scopes.
- *
- * @public
*/
export const bitbucketAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
@@ -465,12 +496,11 @@ export const bitbucketAuthApiRef: ApiRef<
/**
* Provides authentication towards Atlassian APIs.
*
+ * @alpha This API is **EXPERIMENTAL** and might change in the future.
* @remarks
*
* See {@link https://developer.atlassian.com/cloud/jira/platform/scopes-for-connect-and-oauth-2-3LO-apps/}
* for a full list of supported scopes.
- *
- * @public
*/
export const atlassianAuthApiRef: ApiRef<
OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionApi
diff --git a/packages/core-plugin-api/src/apis/definitions/index.ts b/packages/core-plugin-api/src/apis/definitions/index.ts
index b7666bcb54..67d442587d 100644
--- a/packages/core-plugin-api/src/apis/definitions/index.ts
+++ b/packages/core-plugin-api/src/apis/definitions/index.ts
@@ -29,6 +29,7 @@ export * from './ConfigApi';
export * from './DiscoveryApi';
export * from './ErrorApi';
export * from './FeatureFlagsApi';
+export * from './FetchApi';
export * from './IdentityApi';
export * from './OAuthRequestApi';
export * from './StorageApi';
diff --git a/packages/core-plugin-api/src/apis/system/types.ts b/packages/core-plugin-api/src/apis/system/types.ts
index a449e83450..96614c320c 100644
--- a/packages/core-plugin-api/src/apis/system/types.ts
+++ b/packages/core-plugin-api/src/apis/system/types.ts
@@ -31,33 +31,13 @@ export type ApiRef = {
*/
export type AnyApiRef = ApiRef;
-/**
- * Transforms ApiRef type into its inner API type.
- *
- * @public
- * @deprecated unused type.
- */
-export type ApiRefType = T extends ApiRef ? U : never;
-
/**
* Wraps a type with API properties into a type holding their respective {@link ApiRef}s.
- * Reverse type transform of {@link ApiRefsToTypes}.
*
* @public
*/
export type TypesToApiRefs = { [key in keyof T]: ApiRef };
-/**
- * Unwraps type with {@link ApiRef} properties into a type holding their respective API types.
- * Reverse type transform of {@link TypesToApiRefs}.
- *
- * @public
- * @deprecated unused type.
- */
-export type ApiRefsToTypes }> = {
- [key in keyof T]: ApiRefType;
-};
-
/**
* Provides lookup of APIs through their {@link ApiRef}s.
*
diff --git a/packages/core-plugin-api/src/routing/RouteRef.ts b/packages/core-plugin-api/src/routing/RouteRef.ts
index 8bd3d604f6..37d79f3b83 100644
--- a/packages/core-plugin-api/src/routing/RouteRef.ts
+++ b/packages/core-plugin-api/src/routing/RouteRef.ts
@@ -23,17 +23,6 @@ import {
} from './types';
import { OldIconComponent } from '../icons/types';
-/**
- * @deprecated
- * @internal
- */
-export type RouteRefConfig = {
- params?: ParamKeys;
- path?: string;
- icon?: OldIconComponent;
- title: string;
-};
-
/**
* @internal
*/
diff --git a/packages/core-plugin-api/src/routing/types.ts b/packages/core-plugin-api/src/routing/types.ts
index bd419abb76..6232810e56 100644
--- a/packages/core-plugin-api/src/routing/types.ts
+++ b/packages/core-plugin-api/src/routing/types.ts
@@ -142,23 +142,6 @@ export type AnyRouteRef =
| SubRouteRef
| ExternalRouteRef;
-// TODO(Rugvip): None of these should be found in the wild anymore, remove in next minor release
-/**
- * @deprecated
- * @internal
- */
-export type ConcreteRoute = {};
-/**
- * @deprecated
- * @internal
- */
-export type AbsoluteRouteRef = RouteRef<{}>;
-/**
- * @deprecated
- * @internal
- */
-export type MutableRouteRef = RouteRef<{}>;
-
/**
* A duplicate of the react-router RouteObject, but with routeRef added
* @internal
diff --git a/packages/create-app/CHANGELOG.md b/packages/create-app/CHANGELOG.md
index cdcf7f4952..60d8a55635 100644
--- a/packages/create-app/CHANGELOG.md
+++ b/packages/create-app/CHANGELOG.md
@@ -1,5 +1,19 @@
# @backstage/create-app
+## 0.4.8
+
+### Patch Changes
+
+- 25dfc2d483: Updated the root `package.json` to include files with `.cjs` and `.mjs` extensions in the `"lint-staged"` configuration.
+
+ To make this change to an existing app, apply the following changes to the `package.json` file:
+
+ ```diff
+ "lint-staged": {
+ - "*.{js,jsx,ts,tsx}": [
+ + "*.{js,jsx,ts,tsx,mjs,cjs}": [
+ ```
+
## 0.4.7
### Patch Changes
diff --git a/packages/create-app/package.json b/packages/create-app/package.json
index ec739820b9..7a6c7ad551 100644
--- a/packages/create-app/package.json
+++ b/packages/create-app/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/create-app",
"description": "A CLI that helps you create your own Backstage app",
- "version": "0.4.7",
+ "version": "0.4.8",
"private": false,
"publishConfig": {
"access": "public"
@@ -41,7 +41,7 @@
},
"devDependencies": {
"@types/fs-extra": "^9.0.1",
- "@types/inquirer": "^7.3.1",
+ "@types/inquirer": "^8.1.3",
"@types/node": "^14.14.32",
"@types/recursive-readdir": "^2.2.0",
"mock-fs": "^5.1.1",
diff --git a/packages/create-app/templates/default-app/package.json.hbs b/packages/create-app/templates/default-app/package.json.hbs
index b0747c4454..a73045c050 100644
--- a/packages/create-app/templates/default-app/package.json.hbs
+++ b/packages/create-app/templates/default-app/package.json.hbs
@@ -38,7 +38,7 @@
},
"prettier": "@spotify/prettier-config",
"lint-staged": {
- "*.{js,jsx,ts,tsx}": [
+ "*.{js,jsx,ts,tsx,mjs,cjs}": [
"eslint --fix",
"prettier --write"
],
diff --git a/packages/storybook/.storybook/main.js b/packages/storybook/.storybook/main.js
index 72ff42311d..f5852b0164 100644
--- a/packages/storybook/.storybook/main.js
+++ b/packages/storybook/.storybook/main.js
@@ -59,7 +59,7 @@ module.exports = ({ args }) => {
},
},
{
- test: /\.(jsx?|mjs)$/,
+ test: /\.(jsx?|mjs|cjs)$/,
exclude: /node_modules/,
loader: require.resolve('@sucrase/webpack-loader'),
options: {
diff --git a/packages/test-utils/api-report.md b/packages/test-utils/api-report.md
index a01f306fab..295cf3a8c3 100644
--- a/packages/test-utils/api-report.md
+++ b/packages/test-utils/api-report.md
@@ -34,52 +34,6 @@ export type ErrorWithContext = {
context?: ErrorApiErrorContext;
};
-// @public @deprecated (undocumented)
-export class Keyboard {
- constructor(
- target: any,
- {
- debug,
- }?: {
- debug?: boolean | undefined;
- },
- );
- // (undocumented)
- click(): Promise;
- // (undocumented)
- debug: boolean;
- // (undocumented)
- document: any;
- // (undocumented)
- enter(value: any): Promise;
- // (undocumented)
- escape(): Promise;
- // (undocumented)
- get focused(): any;
- // (undocumented)
- static fromReadableInput(input: any): any;
- // (undocumented)
- _log(message: any, ...args: any[]): void;
- // (undocumented)
- _pretty(element: any): string;
- // (undocumented)
- send(chars: any): Promise;
- // (undocumented)
- _sendKey(key: any, charCode: any, action: any): Promise;
- // (undocumented)
- tab(): Promise;
- // (undocumented)
- static toReadableInput(chars: any): any;
- // (undocumented)
- toString(): string;
- // (undocumented)
- static type(target: any, input: any): Promise;
- // (undocumented)
- type(input: any): Promise;
- // (undocumented)
- static typeDebug(target: any, input: any): Promise;
-}
-
// @public
export type LogCollector = AsyncLogCollector | SyncLogCollector;
diff --git a/packages/test-utils/src/testUtils/Keyboard.js b/packages/test-utils/src/testUtils/Keyboard.js
deleted file mode 100644
index 2a7928f8cd..0000000000
--- a/packages/test-utils/src/testUtils/Keyboard.js
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright 2020 The Backstage Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { act, fireEvent } from '@testing-library/react';
-
-const codes = {
- Tab: 9,
- Enter: 10,
- Click: 17 /* This keyboard can click, deal with it */,
- Esc: 27,
-};
-
-/**
- * @public
- * @deprecated superseded by {@link @testing-library/user-event#userEvent}
- */
-export class Keyboard {
- static async type(target, input) {
- await new Keyboard(target).type(input);
- }
-
- static async typeDebug(target, input) {
- await new Keyboard(target, { debug: true }).type(input);
- }
-
- static toReadableInput(chars) {
- return chars.split('').map(char => {
- switch (char.charCodeAt(0)) {
- case codes.Tab:
- return '';
- case codes.Enter:
- return '';
- case codes.Click:
- return '';
- case codes.Esc:
- return '';
- default:
- return char;
- }
- });
- }
-
- static fromReadableInput(input) {
- return input.trim().replace(/\s*<([a-zA-Z]+)>\s*/g, (match, name) => {
- if (name in codes) {
- return String.fromCharCode(codes[name]);
- }
- throw new Error(`Unknown char name: '${name}'`);
- });
- }
-
- constructor(target, { debug = false } = {}) {
- this.debug = debug;
-
- if (target.ownerDocument) {
- this.document = target.ownerDocument;
- } else if (target.baseElement) {
- this.document = target.baseElement.ownerDocument;
- } else {
- throw new TypeError(
- 'Keyboard(target): target must be DOM node or react-testing-library render() output',
- );
- }
- }
-
- toString() {
- return `Keyboard{document=${this.document}, debug=${this.debug}}`;
- }
-
- _log(message, ...args) {
- if (this.debug) {
- // eslint-disable-next-line no-console
- console.log(`[Keyboard] ${message}`, ...args);
- }
- }
-
- _pretty(element) {
- const attrs = [...element.attributes]
- .map(attr => `${attr.name}="${attr.value}"`)
- .join(' ');
- return `<${element.nodeName.toLocaleLowerCase('en-US')} ${attrs}>`;
- }
-
- get focused() {
- return this.document.activeElement;
- }
-
- async type(input) {
- this._log(
- `sending sequence '${input}' with initial focus ${this._pretty(
- this.focused,
- )}`,
- );
- await this.send(Keyboard.fromReadableInput(input));
- }
-
- async send(chars) {
- for (const key of chars.split('')) {
- const charCode = key.charCodeAt(0);
-
- if (charCode === codes.Tab) {
- await this.tab();
- continue;
- }
-
- const focused = this.focused;
- if (!focused || focused === this.document.body) {
- throw Error(
- `No element focused in document while trying to type '${Keyboard.toReadableInput(
- chars,
- )}'`,
- );
- }
- const nextValue = (focused.value || '') + key;
-
- if (charCode >= 32) {
- await this._sendKey(key, charCode, () => {
- this._log(
- `sending +${key} = '${nextValue}' to ${this._pretty(focused)}`,
- );
- fireEvent.change(focused, {
- target: { value: nextValue },
- bubbles: true,
- cancelable: true,
- });
- });
- } else if (charCode === codes.Enter) {
- await this.enter(focused.value || '');
- } else if (charCode === codes.Esc) {
- await this.escape();
- } else if (charCode === codes.Click) {
- await this.click();
- } else {
- throw new Error(`Unsupported char code, ${charCode}`);
- }
- }
- }
-
- async click() {
- this._log(`clicking ${this._pretty(this.focused)}`);
- await act(async () => fireEvent.click(this.focused));
- }
-
- async tab() {
- await this._sendKey('Tab', codes.Tab, () => {
- const focusable = this.document.querySelectorAll(
- [
- 'a[href]',
- 'area[href]',
- 'input:not([disabled])',
- 'select:not([disabled])',
- 'textarea:not([disabled])',
- 'button:not([disabled])',
- 'iframe',
- 'object',
- 'embed',
- '*[tabindex]',
- '*[contenteditable]',
- ].join(','),
- );
-
- const tabbable = [...focusable].filter(el => {
- return el.tabIndex >= 0;
- });
-
- const focused = this.document.activeElement;
- const focusedIndex = tabbable.indexOf(focused);
- const nextFocus = tabbable[focusedIndex + (1 % tabbable.length)];
-
- this._log(
- `tabbing to ${this._pretty(nextFocus)} ${this.focused.textContent}`,
- );
- nextFocus.focus();
- });
- }
-
- async enter(value) {
- this._log(`submitting '${value}' via ${this._pretty(this.focused)}`);
- await act(() =>
- this._sendKey('Enter', codes.Enter, () => {
- if (this.focused.type === 'button') {
- fireEvent.click(this.focused, { target: { value } });
- } else {
- fireEvent.submit(this.focused, {
- target: { value },
- bubbles: true,
- cancelable: true,
- });
- }
- }),
- );
- }
-
- async escape() {
- this._log(`escape from ${this._pretty(this.focused)}`);
- await act(async () => this._sendKey('Escape', codes.Esc));
- }
-
- async _sendKey(key, charCode, action) {
- const event = { key, charCode, keyCode: charCode, which: charCode };
- const focused = this.focused;
-
- if (fireEvent.keyDown(focused, event)) {
- if (fireEvent.keyPress(focused, event)) {
- if (action) {
- action();
- }
- }
- }
- fireEvent.keyUp(focused, event);
- }
-}
diff --git a/packages/test-utils/src/testUtils/Keyboard.test.js b/packages/test-utils/src/testUtils/Keyboard.test.js
deleted file mode 100644
index 41ee3a12d6..0000000000
--- a/packages/test-utils/src/testUtils/Keyboard.test.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2020 The Backstage Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import React from 'react';
-import { Keyboard } from './Keyboard';
-import { render } from '@testing-library/react';
-
-describe('testUtils.Keyboard', () => {
- it('types into some inputs with focus and submits a form', async () => {
- const typed1 = [];
- const typed2 = [];
- const typed3 = [];
-
- let submitted = false;
- const handleSubmit = event => {
- event.preventDefault();
- submitted = true;
- };
-
- const rendered = render(
- ,
- );
-
- const keyboard = new Keyboard(rendered);
- await keyboard.send('xy');
- await keyboard.tab();
- await keyboard.send('abc');
- await keyboard.enter();
-
- expect(typed1).toEqual([]);
- expect(typed2).toEqual(['x', 'xy']);
- expect(typed3).toEqual(['a', 'ab', 'abc']);
- expect(submitted).toBe(true);
- });
-
- it('can use Keyboard.type to send readable input', async () => {
- const typed1 = [];
- const typed2 = [];
- const typed3 = [];
-
- let submitted = false;
- const handleSubmit = event => {
- event.preventDefault();
- submitted = true;
- };
-
- const rendered = render(
- ,
- );
-
- await Keyboard.type(rendered, ' a b c ');
-
- expect(typed1).toEqual(['1a']);
- expect(typed2).toEqual(['2b']);
- expect(typed3).toEqual(['3c']);
- expect(submitted).toBe(true);
- });
-
- it('should be able to navigate a radio input with click', async () => {
- const selections = [];
-
- const rendered = render(
- selections.push(value)}>
-
-
-
-
,
- );
-
- await Keyboard.type(rendered, ' ');
-
- expect(selections).toEqual(['a', 'c']);
- });
-});
diff --git a/packages/test-utils/src/testUtils/index.tsx b/packages/test-utils/src/testUtils/index.tsx
index c778c5c837..a7850fc158 100644
--- a/packages/test-utils/src/testUtils/index.tsx
+++ b/packages/test-utils/src/testUtils/index.tsx
@@ -19,7 +19,6 @@ export { default as mockBreakpoint } from './mockBreakpoint';
export { wrapInTestApp, renderInTestApp } from './appWrappers';
export type { TestAppOptions } from './appWrappers';
export * from './msw';
-export * from './Keyboard';
export * from './logCollector';
export * from './testingLibrary';
export { TestApiProvider, TestApiRegistry } from './TestApiProvider';
diff --git a/plugins/allure/package.json b/plugins/allure/package.json
index 8b3ee3b882..261c5e1879 100644
--- a/plugins/allure/package.json
+++ b/plugins/allure/package.json
@@ -23,8 +23,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -37,8 +37,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/analytics-module-ga/package.json b/plugins/analytics-module-ga/package.json
index 15055b2a4f..5f48d4404e 100644
--- a/plugins/analytics-module-ga/package.json
+++ b/plugins/analytics-module-ga/package.json
@@ -22,8 +22,8 @@
},
"dependencies": {
"@backstage/config": "^0.1.5",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -35,8 +35,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/apache-airflow/CHANGELOG.md b/plugins/apache-airflow/CHANGELOG.md
new file mode 100644
index 0000000000..64abdb929a
--- /dev/null
+++ b/plugins/apache-airflow/CHANGELOG.md
@@ -0,0 +1,22 @@
+# @backstage/plugin-apache-airflow
+
+## 0.1.0
+
+### Minor Changes
+
+- 9aea335911: Introduces a new plugin for the Apache Airflow workflow management platform.
+ This implementation has been tested with the Apache Airflow v2 API,
+ authenticating with basic authentication through the Backstage proxy plugin.
+
+ Supported functionality includes:
+
+ - Information card of version information of the Airflow instance
+ - Information card of instance health for the meta-database and scheduler
+ - Table of DAGs with meta information and status, along with a link to view
+ details in the Airflow UI
+
+### Patch Changes
+
+- Updated dependencies
+ - @backstage/core-plugin-api@0.3.1
+ - @backstage/core-components@0.8.1
diff --git a/plugins/apache-airflow/README.md b/plugins/apache-airflow/README.md
index c57ab9da43..bdbb1b981f 100644
--- a/plugins/apache-airflow/README.md
+++ b/plugins/apache-airflow/README.md
@@ -2,6 +2,9 @@
Welcome to the apache-airflow plugin!
+This plugin serves as frontend to the REST API exposed by Apache Airflow.
+Note only [Airflow v2 (and later)](https://airflow.apache.org/docs/apache-airflow/stable/deprecated-rest-api-ref.html) integrate with the plugin.
+
## Feature Requests & Ideas
- [ ] Add support for running multiple instances of Airflow for monitoring
diff --git a/plugins/apache-airflow/package.json b/plugins/apache-airflow/package.json
index a361961d12..58c5dceb77 100644
--- a/plugins/apache-airflow/package.json
+++ b/plugins/apache-airflow/package.json
@@ -1,6 +1,6 @@
{
"name": "@backstage/plugin-apache-airflow",
- "version": "0.0.0",
+ "version": "0.1.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -20,8 +20,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
@@ -33,8 +33,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/api-docs/package.json b/plugins/api-docs/package.json
index 93df7e68aa..fd057cf358 100644
--- a/plugins/api-docs/package.json
+++ b/plugins/api-docs/package.json
@@ -32,8 +32,8 @@
"dependencies": {
"@asyncapi/react-component": "^1.0.0-next.25",
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog": "^0.7.4",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
@@ -54,8 +54,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/auth-backend/CHANGELOG.md b/plugins/auth-backend/CHANGELOG.md
index dc45804449..cfdae9f4ef 100644
--- a/plugins/auth-backend/CHANGELOG.md
+++ b/plugins/auth-backend/CHANGELOG.md
@@ -1,5 +1,14 @@
# @backstage/plugin-auth-backend
+## 0.5.1
+
+### Patch Changes
+
+- 699c2e9ddc: export minimal typescript types for OIDC provider
+- Updated dependencies
+ - @backstage/backend-common@0.9.14
+ - @backstage/catalog-model@0.9.8
+
## 0.5.0
### Minor Changes
diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md
index a637118130..9ed523c678 100644
--- a/plugins/auth-backend/api-report.md
+++ b/plugins/auth-backend/api-report.md
@@ -47,6 +47,16 @@ export type AtlassianProviderOptions = {
};
};
+// @public
+export type AuthHandler = (
+ input: AuthResult,
+) => Promise;
+
+// @public
+export type AuthHandlerResult = {
+ profile: ProfileInfo;
+};
+
// Warning: (ae-missing-release-tag) "AuthProviderFactory" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -258,7 +268,6 @@ export const createOAuth2Provider: (
options?: OAuth2ProviderOptions | undefined,
) => AuthProviderFactory;
-// Warning: (ae-forgotten-export) The symbol "OidcProviderOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "createOidcProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -534,6 +543,20 @@ export type OAuthState = {
origin?: string;
};
+// @public
+export type OidcAuthResult = {
+ tokenset: TokenSet;
+ userinfo: UserinfoResponse;
+};
+
+// @public
+export type OidcProviderOptions = {
+ authHandler?: AuthHandler;
+ signIn?: {
+ resolver?: SignInResolver;
+ };
+};
+
// Warning: (ae-missing-release-tag) "oktaEmailSignInResolver" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -606,6 +629,22 @@ export type SamlProviderOptions = {
};
};
+// @public
+export type SignInInfo = {
+ profile: ProfileInfo;
+ result: AuthResult;
+};
+
+// @public
+export type SignInResolver = (
+ info: SignInInfo,
+ context: {
+ tokenIssuer: TokenIssuer;
+ catalogIdentityClient: CatalogIdentityClient;
+ logger: Logger_2;
+ },
+) => Promise;
+
// Warning: (ae-missing-release-tag) "TokenIssuer" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
@@ -637,8 +676,6 @@ export type WebMessageResponse =
// Warnings were encountered during analysis:
//
// src/identity/types.d.ts:31:9 - (ae-forgotten-export) The symbol "AnyJWK" needs to be exported by the entry point index.d.ts
-// src/providers/atlassian/provider.d.ts:37:5 - (ae-forgotten-export) The symbol "AuthHandler" needs to be exported by the entry point index.d.ts
-// src/providers/atlassian/provider.d.ts:42:9 - (ae-forgotten-export) The symbol "SignInResolver" needs to be exported by the entry point index.d.ts
// src/providers/aws-alb/provider.d.ts:77:5 - (ae-forgotten-export) The symbol "AwsAlbResult" needs to be exported by the entry point index.d.ts
// src/providers/github/provider.d.ts:71:58 - (tsdoc-escape-greater-than) The ">" character should be escaped using a backslash to avoid confusion with an HTML tag
// src/providers/github/provider.d.ts:71:90 - (tsdoc-escape-greater-than) The ">" character should be escaped using a backslash to avoid confusion with an HTML tag
diff --git a/plugins/auth-backend/package.json b/plugins/auth-backend/package.json
index b2822c4f33..c7d208eef2 100644
--- a/plugins/auth-backend/package.json
+++ b/plugins/auth-backend/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/plugin-auth-backend",
"description": "A Backstage backend plugin that handles authentication",
- "version": "0.5.0",
+ "version": "0.5.1",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -30,9 +30,9 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/backend-common": "^0.9.13",
+ "@backstage/backend-common": "^0.9.14",
"@backstage/catalog-client": "^0.5.2",
- "@backstage/catalog-model": "^0.9.7",
+ "@backstage/catalog-model": "^0.9.8",
"@backstage/config": "^0.1.11",
"@backstage/errors": "^0.1.5",
"@backstage/test-utils": "^0.1.24",
@@ -73,7 +73,7 @@
"yn": "^4.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
+ "@backstage/cli": "^0.10.2",
"@types/body-parser": "^1.19.0",
"@types/cookie-parser": "^1.4.2",
"@types/express-session": "^1.17.2",
diff --git a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts
index 92c76b04b7..a3fc77bc02 100644
--- a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts
+++ b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts
@@ -17,7 +17,7 @@
import express from 'express';
import { THOUSAND_DAYS_MS, TEN_MINUTES_MS, OAuthAdapter } from './OAuthAdapter';
import { encodeState } from './helpers';
-import { OAuthHandlers } from './types';
+import { OAuthHandlers, OAuthResponse } from './types';
const mockResponseData = {
providerInfo: {
@@ -36,6 +36,12 @@ const mockResponseData = {
},
};
+function mkTokenBody(payload: unknown): string {
+ return Buffer.from(JSON.stringify(payload), 'utf8')
+ .toString('base64')
+ .replace(/=/g, '');
+}
+
describe('OAuthAdapter', () => {
class MyAuthProvider implements OAuthHandlers {
async start() {
@@ -249,4 +255,86 @@ describe('OAuthAdapter', () => {
'Refresh token is not supported for provider test-provider',
);
});
+
+ it('correctly populates incomplete identities', async () => {
+ const mockRefresh = jest.fn, [express.Request]>();
+
+ const oauthProvider = new OAuthAdapter(
+ {
+ refresh: mockRefresh,
+ start: jest.fn(),
+ handler: jest.fn(),
+ } as OAuthHandlers,
+ {
+ ...oAuthProviderOptions,
+ tokenIssuer: {
+ issueToken: async ({ claims }) => `a.${mkTokenBody(claims)}.a`,
+ listPublicKeys: async () => ({ keys: [] }),
+ },
+ disableRefresh: false,
+ isOriginAllowed: () => false,
+ },
+ );
+
+ const mockRequest = {
+ header: () => 'XMLHttpRequest',
+ cookies: {
+ 'test-provider-refresh-token': 'token',
+ },
+ query: {},
+ } as unknown as express.Request;
+
+ const mockResponse = {
+ json: jest.fn().mockReturnThis(),
+ status: jest.fn().mockReturnThis(),
+ } as unknown as express.Response;
+
+ // Without a token
+ mockRefresh.mockResolvedValueOnce({
+ ...mockResponseData,
+ backstageIdentity: {
+ id: 'foo',
+ token: '',
+ },
+ });
+ await oauthProvider.refresh(mockRequest, mockResponse);
+ expect(mockResponse.json).toHaveBeenCalledTimes(1);
+ expect(mockResponse.json).toHaveBeenLastCalledWith({
+ ...mockResponseData,
+ backstageIdentity: {
+ id: 'foo',
+ token: `a.${mkTokenBody({ sub: 'user:default/foo' })}.a`,
+ idToken: `a.${mkTokenBody({ sub: 'user:default/foo' })}.a`,
+ identity: {
+ type: 'user',
+ userEntityRef: 'user:default/foo',
+ ownershipEntityRefs: [],
+ },
+ },
+ });
+
+ // With a token
+ mockRefresh.mockResolvedValueOnce({
+ ...mockResponseData,
+ backstageIdentity: {
+ id: 'foo',
+ token: `z.${mkTokenBody({ sub: 'user:my-ns/foo' })}.z`,
+ },
+ });
+ await oauthProvider.refresh(mockRequest, mockResponse);
+ expect(mockResponse.json).toHaveBeenCalledTimes(2);
+ expect(mockResponse.json).toHaveBeenLastCalledWith({
+ ...mockResponseData,
+ backstageIdentity: {
+ id: 'foo',
+ token: `z.${mkTokenBody({ sub: 'user:my-ns/foo' })}.z`,
+ idToken: `z.${mkTokenBody({ sub: 'user:my-ns/foo' })}.z`,
+ identity: {
+ type: 'user',
+ userEntityRef: 'user:my-ns/foo',
+ ownershipEntityRefs: [],
+ },
+ },
+ });
+ });
});
diff --git a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts
index eb3f7efa42..4d5d507aa1 100644
--- a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts
+++ b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts
@@ -17,6 +17,11 @@
import express from 'express';
import crypto from 'crypto';
import { URL } from 'url';
+import {
+ ENTITY_DEFAULT_NAMESPACE,
+ parseEntityRef,
+ stringifyEntityRef,
+} from '@backstage/catalog-model';
import {
AuthProviderRouteHandlers,
AuthProviderConfig,
@@ -243,8 +248,14 @@ export class OAuthAdapter implements AuthProviderRouteHandlers {
return prepareBackstageIdentityResponse(identity);
}
+ const userEntityRef = stringifyEntityRef(
+ parseEntityRef(identity.id, {
+ defaultKind: 'user',
+ defaultNamespace: ENTITY_DEFAULT_NAMESPACE,
+ }),
+ );
const token = await this.options.tokenIssuer.issueToken({
- claims: { sub: identity.id },
+ claims: { sub: userEntityRef },
});
return prepareBackstageIdentityResponse({ ...identity, token });
diff --git a/plugins/auth-backend/src/providers/index.ts b/plugins/auth-backend/src/providers/index.ts
index 4ecbb98fd2..9589e97265 100644
--- a/plugins/auth-backend/src/providers/index.ts
+++ b/plugins/auth-backend/src/providers/index.ts
@@ -34,6 +34,10 @@ export type {
AuthProviderRouteHandlers,
AuthProviderFactoryOptions,
AuthProviderFactory,
+ AuthHandler,
+ AuthHandlerResult,
+ SignInResolver,
+ SignInInfo,
} from './types';
// These types are needed for a postMessage from the login pop-up
diff --git a/plugins/auth-backend/src/providers/oidc/index.ts b/plugins/auth-backend/src/providers/oidc/index.ts
index 20d014a783..39bd02928d 100644
--- a/plugins/auth-backend/src/providers/oidc/index.ts
+++ b/plugins/auth-backend/src/providers/oidc/index.ts
@@ -13,5 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+export type { OidcAuthResult, OidcProviderOptions } from './provider';
export { createOidcProvider } from './provider';
diff --git a/plugins/auth-backend/src/providers/oidc/provider.ts b/plugins/auth-backend/src/providers/oidc/provider.ts
index 158af6f830..fe4c042500 100644
--- a/plugins/auth-backend/src/providers/oidc/provider.ts
+++ b/plugins/auth-backend/src/providers/oidc/provider.ts
@@ -56,7 +56,11 @@ type OidcImpl = {
client: Client;
};
-type AuthResult = {
+/**
+ * authentication result for the OIDC which includes the token set and user information (a profile response sent by OIDC server)
+ * @public
+ */
+export type OidcAuthResult = {
tokenset: TokenSet;
userinfo: UserinfoResponse;
};
@@ -66,8 +70,8 @@ export type Options = OAuthProviderOptions & {
scope?: string;
prompt?: string;
tokenSignedResponseAlg?: string;
- signInResolver?: SignInResolver;
- authHandler: AuthHandler;
+ signInResolver?: SignInResolver;
+ authHandler: AuthHandler;
tokenIssuer: TokenIssuer;
catalogIdentityClient: CatalogIdentityClient;
logger: Logger;
@@ -78,8 +82,8 @@ export class OidcAuthProvider implements OAuthHandlers {
private readonly scope?: string;
private readonly prompt?: string;
- private readonly signInResolver?: SignInResolver;
- private readonly authHandler: AuthHandler;
+ private readonly signInResolver?: SignInResolver;
+ private readonly authHandler: AuthHandler;
private readonly tokenIssuer: TokenIssuer;
private readonly catalogIdentityClient: CatalogIdentityClient;
private readonly logger: Logger;
@@ -113,7 +117,7 @@ export class OidcAuthProvider implements OAuthHandlers {
): Promise<{ response: OAuthResponse; refreshToken?: string }> {
const { strategy } = await this.implementation;
const strategyResponse = await executeFrameHandlerStrategy<
- AuthResult,
+ OidcAuthResult,
PrivateInfo
>(req, strategy);
const {
@@ -158,7 +162,7 @@ export class OidcAuthProvider implements OAuthHandlers {
(
tokenset: TokenSet,
userinfo: UserinfoResponse,
- done: PassportDoneCallback,
+ done: PassportDoneCallback,
) => {
if (typeof done !== 'function') {
throw new Error(
@@ -180,7 +184,7 @@ export class OidcAuthProvider implements OAuthHandlers {
// Use this function to grab the user profile info from the token
// Then populate the profile with it
- private async handleResult(result: AuthResult): Promise {
+ private async handleResult(result: OidcAuthResult): Promise {
const { profile } = await this.authHandler(result);
const response: OAuthResponse = {
providerInfo: {
@@ -210,27 +214,37 @@ export class OidcAuthProvider implements OAuthHandlers {
}
}
-export const oAuth2DefaultSignInResolver: SignInResolver = async (
- info,
- ctx,
-) => {
- const { profile } = info;
+export const oAuth2DefaultSignInResolver: SignInResolver =
+ async (info, ctx) => {
+ const { profile } = info;
- if (!profile.email) {
- throw new Error('Profile contained no email');
- }
- const userId = profile.email.split('@')[0];
- const token = await ctx.tokenIssuer.issueToken({
- claims: { sub: userId, ent: [`user:default/${userId}`] },
- });
- return { id: userId, token };
-};
+ if (!profile.email) {
+ throw new Error('Profile contained no email');
+ }
+ const userId = profile.email.split('@')[0];
+ const token = await ctx.tokenIssuer.issueToken({
+ claims: { sub: userId, ent: [`user:default/${userId}`] },
+ });
+ return { id: userId, token };
+ };
+/**
+ * OIDC provider callback options. An auth handler and a sign in resolver
+ * can be passed while creating a OIDC provider.
+ *
+ * authHandler : called after sign in was successful, a new object must be returned which includes a profile
+ * signInResolver: called after sign in was successful, expects to return a new {@link BackstageSignInResult}
+ *
+ * Both options are optional. There is fallback for authHandler where the default handler expect an e-mail explicitly
+ * otherwise it throws an error
+ *
+ * @public
+ */
export type OidcProviderOptions = {
- authHandler?: AuthHandler;
+ authHandler?: AuthHandler;
signIn?: {
- resolver?: SignInResolver;
+ resolver?: SignInResolver;
};
};
@@ -260,7 +274,7 @@ export const createOidcProvider = (
tokenIssuer,
});
- const authHandler: AuthHandler = options?.authHandler
+ const authHandler: AuthHandler = options?.authHandler
? options.authHandler
: async ({ userinfo }) => ({
profile: {
@@ -271,7 +285,7 @@ export const createOidcProvider = (
});
const signInResolverFn =
options?.signIn?.resolver ?? oAuth2DefaultSignInResolver;
- const signInResolver: SignInResolver = info =>
+ const signInResolver: SignInResolver = info =>
signInResolverFn(info, {
catalogIdentityClient,
tokenIssuer,
diff --git a/plugins/auth-backend/src/providers/types.ts b/plugins/auth-backend/src/providers/types.ts
index dafa52163c..ecb466c768 100644
--- a/plugins/auth-backend/src/providers/types.ts
+++ b/plugins/auth-backend/src/providers/types.ts
@@ -240,6 +240,10 @@ export type ProfileInfo = {
picture?: string;
};
+/**
+ * type of sign in information context, includes the profile information and authentication result which contains auth. related information
+ * @public
+ */
export type SignInInfo = {
/**
* The simple profile passed down for use in the frontend.
@@ -252,6 +256,11 @@ export type SignInInfo = {
result: AuthResult;
};
+/**
+ * Sign in resolver type describes the function which handles the result of a successful authentication
+ * and it must return a valid {@link BackstageSignInResult}
+ * @public
+ */
export type SignInResolver = (
info: SignInInfo,
context: {
@@ -261,6 +270,10 @@ export type SignInResolver = (
},
) => Promise;
+/**
+ * The return type of authentication handler which must contain a valid profile information
+ * @public
+ */
export type AuthHandlerResult = { profile: ProfileInfo };
/**
@@ -270,6 +283,8 @@ export type AuthHandlerResult = { profile: ProfileInfo };
*
* Throwing an error in the function will cause the authentication to fail, making it
* possible to use this function as a way to limit access to a certain group of users.
+ *
+ * @public
*/
export type AuthHandler = (
input: AuthResult,
diff --git a/plugins/azure-devops-backend/CHANGELOG.md b/plugins/azure-devops-backend/CHANGELOG.md
index e0e74a9bc6..ff802a30e1 100644
--- a/plugins/azure-devops-backend/CHANGELOG.md
+++ b/plugins/azure-devops-backend/CHANGELOG.md
@@ -1,5 +1,66 @@
# @backstage/plugin-azure-devops-backend
+## 0.2.5
+
+### Patch Changes
+
+- daf32e2c9b: Created some initial filters that can be used to create pull request columns:
+
+ - All
+ - AssignedToUser
+ - AssignedToCurrentUser
+ - AssignedToTeam
+ - AssignedToTeams
+ - AssignedToCurrentUsersTeams
+ - CreatedByUser
+ - CreatedByCurrentUser
+ - CreatedByTeam
+ - CreatedByTeams
+ - CreatedByCurrentUsersTeams
+
+ Example custom column creation:
+
+ ```tsx
+ const COLUMN_CONFIGS: PullRequestColumnConfig[] = [
+ {
+ title: 'Created by me',
+ filters: [{ type: FilterType.CreatedByCurrentUser }],
+ },
+ {
+ title: 'Created by Backstage Core',
+ filters: [
+ {
+ type: FilterType.CreatedByTeam,
+ teamName: 'Backstage Core',
+ },
+ ],
+ },
+ {
+ title: 'Assigned to my teams',
+ filters: [{ type: FilterType.AssignedToCurrentUsersTeams }],
+ },
+ {
+ title: 'Other PRs',
+ filters: [{ type: FilterType.All }],
+ simplified: true,
+ },
+ ];
+
+
+ }
+ />;
+ ```
+
+- Updated dependencies
+ - @backstage/backend-common@0.9.14
+ - @backstage/plugin-azure-devops-common@0.1.3
+
## 0.2.4
### Patch Changes
diff --git a/plugins/azure-devops-backend/package.json b/plugins/azure-devops-backend/package.json
index 9741380fb1..a7aec3f2d6 100644
--- a/plugins/azure-devops-backend/package.json
+++ b/plugins/azure-devops-backend/package.json
@@ -1,6 +1,6 @@
{
"name": "@backstage/plugin-azure-devops-backend",
- "version": "0.2.4",
+ "version": "0.2.5",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -20,9 +20,9 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/backend-common": "^0.9.13",
+ "@backstage/backend-common": "^0.9.14",
"@backstage/config": "^0.1.11",
- "@backstage/plugin-azure-devops-common": "^0.1.2",
+ "@backstage/plugin-azure-devops-common": "^0.1.3",
"@types/express": "^4.17.6",
"azure-devops-node-api": "^11.0.1",
"express": "^4.17.1",
@@ -31,7 +31,7 @@
"yn": "^4.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
+ "@backstage/cli": "^0.10.2",
"@types/supertest": "^2.0.8",
"supertest": "^4.0.2",
"msw": "^0.35.0"
diff --git a/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts b/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts
index aa843e9c17..7a0d0a279e 100644
--- a/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts
+++ b/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts
@@ -215,6 +215,7 @@ function convertReviewer(
return {
id: identityRef.id,
displayName: identityRef.displayName,
+ uniqueName: identityRef.uniqueName,
imageUrl: getAvatarUrl(identityRef),
isRequired: identityRef.isRequired,
isContainer: identityRef.isContainer,
diff --git a/plugins/azure-devops-common/CHANGELOG.md b/plugins/azure-devops-common/CHANGELOG.md
index b2c8645e94..84c2cae9a5 100644
--- a/plugins/azure-devops-common/CHANGELOG.md
+++ b/plugins/azure-devops-common/CHANGELOG.md
@@ -1,5 +1,62 @@
# @backstage/plugin-azure-devops-common
+## 0.1.3
+
+### Patch Changes
+
+- daf32e2c9b: Created some initial filters that can be used to create pull request columns:
+
+ - All
+ - AssignedToUser
+ - AssignedToCurrentUser
+ - AssignedToTeam
+ - AssignedToTeams
+ - AssignedToCurrentUsersTeams
+ - CreatedByUser
+ - CreatedByCurrentUser
+ - CreatedByTeam
+ - CreatedByTeams
+ - CreatedByCurrentUsersTeams
+
+ Example custom column creation:
+
+ ```tsx
+ const COLUMN_CONFIGS: PullRequestColumnConfig[] = [
+ {
+ title: 'Created by me',
+ filters: [{ type: FilterType.CreatedByCurrentUser }],
+ },
+ {
+ title: 'Created by Backstage Core',
+ filters: [
+ {
+ type: FilterType.CreatedByTeam,
+ teamName: 'Backstage Core',
+ },
+ ],
+ },
+ {
+ title: 'Assigned to my teams',
+ filters: [{ type: FilterType.AssignedToCurrentUsersTeams }],
+ },
+ {
+ title: 'Other PRs',
+ filters: [{ type: FilterType.All }],
+ simplified: true,
+ },
+ ];
+
+
+ }
+ />;
+ ```
+
## 0.1.2
### Patch Changes
diff --git a/plugins/azure-devops-common/api-report.md b/plugins/azure-devops-common/api-report.md
index bb458f169a..85a9e54847 100644
--- a/plugins/azure-devops-common/api-report.md
+++ b/plugins/azure-devops-common/api-report.md
@@ -61,6 +61,10 @@ export interface CreatedBy {
// (undocumented)
imageUrl?: string;
// (undocumented)
+ teamIds?: string[];
+ // (undocumented)
+ teamNames?: string[];
+ // (undocumented)
uniqueName?: string;
}
@@ -254,6 +258,8 @@ export interface Reviewer {
// (undocumented)
isRequired?: boolean;
// (undocumented)
+ uniqueName?: string;
+ // (undocumented)
voteStatus: PullRequestVoteStatus;
}
diff --git a/plugins/azure-devops-common/package.json b/plugins/azure-devops-common/package.json
index 7b82296c40..f8a9622bff 100644
--- a/plugins/azure-devops-common/package.json
+++ b/plugins/azure-devops-common/package.json
@@ -1,6 +1,6 @@
{
"name": "@backstage/plugin-azure-devops-common",
- "version": "0.1.2",
+ "version": "0.1.3",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -29,7 +29,7 @@
"clean": "backstage-cli clean"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1"
+ "@backstage/cli": "^0.10.2"
},
"files": [
"dist"
diff --git a/plugins/azure-devops-common/src/types.ts b/plugins/azure-devops-common/src/types.ts
index e6bd174079..0befcf0b60 100644
--- a/plugins/azure-devops-common/src/types.ts
+++ b/plugins/azure-devops-common/src/types.ts
@@ -145,6 +145,7 @@ export interface DashboardPullRequest {
export interface Reviewer {
id?: string;
displayName?: string;
+ uniqueName?: string;
imageUrl?: string;
isRequired?: boolean;
isContainer?: boolean;
@@ -164,6 +165,8 @@ export interface CreatedBy {
displayName?: string;
uniqueName?: string;
imageUrl?: string;
+ teamIds?: string[];
+ teamNames?: string[];
}
export interface Repository {
diff --git a/plugins/azure-devops/CHANGELOG.md b/plugins/azure-devops/CHANGELOG.md
index 57f80f508b..c79c3abdbc 100644
--- a/plugins/azure-devops/CHANGELOG.md
+++ b/plugins/azure-devops/CHANGELOG.md
@@ -1,5 +1,69 @@
# @backstage/plugin-azure-devops
+## 0.1.7
+
+### Patch Changes
+
+- daf32e2c9b: Created some initial filters that can be used to create pull request columns:
+
+ - All
+ - AssignedToUser
+ - AssignedToCurrentUser
+ - AssignedToTeam
+ - AssignedToTeams
+ - AssignedToCurrentUsersTeams
+ - CreatedByUser
+ - CreatedByCurrentUser
+ - CreatedByTeam
+ - CreatedByTeams
+ - CreatedByCurrentUsersTeams
+
+ Example custom column creation:
+
+ ```tsx
+ const COLUMN_CONFIGS: PullRequestColumnConfig[] = [
+ {
+ title: 'Created by me',
+ filters: [{ type: FilterType.CreatedByCurrentUser }],
+ },
+ {
+ title: 'Created by Backstage Core',
+ filters: [
+ {
+ type: FilterType.CreatedByTeam,
+ teamName: 'Backstage Core',
+ },
+ ],
+ },
+ {
+ title: 'Assigned to my teams',
+ filters: [{ type: FilterType.AssignedToCurrentUsersTeams }],
+ },
+ {
+ title: 'Other PRs',
+ filters: [{ type: FilterType.All }],
+ simplified: true,
+ },
+ ];
+
+
+ }
+ />;
+ ```
+
+- Updated dependencies
+ - @backstage/core-plugin-api@0.3.1
+ - @backstage/core-components@0.8.1
+ - @backstage/plugin-azure-devops-common@0.1.3
+ - @backstage/catalog-model@0.9.8
+ - @backstage/plugin-catalog-react@0.6.7
+
## 0.1.6
### Patch Changes
diff --git a/plugins/azure-devops/api-report.md b/plugins/azure-devops/api-report.md
index 0f3e3310ef..11e238e6f5 100644
--- a/plugins/azure-devops/api-report.md
+++ b/plugins/azure-devops/api-report.md
@@ -6,9 +6,55 @@
///
import { BackstagePlugin } from '@backstage/core-plugin-api';
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
import { Entity } from '@backstage/catalog-model';
import { SvgIconProps } from '@material-ui/core';
+// 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 &
+ (
+ | {
+ type: FilterType.AssignedToTeams;
+ teamIds: string[];
+ }
+ | {
+ type: FilterType.AssignedToCurrentUsersTeams;
+ teamIds?: string[];
+ }
+ );
+
+// 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 &
+ (
+ | {
+ type: FilterType.AssignedToUser;
+ email: string;
+ }
+ | {
+ type: FilterType.AssignedToCurrentUser;
+ email?: 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)
@@ -25,11 +71,71 @@ export const AzurePullRequestsIcon: (props: SvgIconProps) => JSX.Element;
export const AzurePullRequestsPage: ({
projectName,
pollingInterval,
+ defaultColumnConfigs,
}: {
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 &
+ ({
+ type: FilterType.CreatedByTeam;
+ } & (
+ | {
+ teamId: string;
+ }
+ | {
+ teamName: string;
+ }
+ ));
+
+// 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 &
+ (
+ | ({
+ type: FilterType.CreatedByTeams;
+ } & (
+ | {
+ teamIds: string[];
+ }
+ | {
+ teamNames: string[];
+ }
+ ))
+ | {
+ type: FilterType.CreatedByCurrentUsersTeams;
+ teamIds?: string[];
+ }
+ );
+
+// 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 &
+ (
+ | {
+ type: FilterType.CreatedByUser;
+ email: string;
+ }
+ | {
+ type: FilterType.CreatedByCurrentUser;
+ email?: string;
+ }
+ );
+
// 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)
@@ -48,10 +154,67 @@ export const EntityAzurePullRequestsContent: ({
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
+ | CreatedByUserFilter
+ | AssignedToTeamFilter
+ | CreatedByTeamFilter
+ | AssignedToTeamsFilter
+ | 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)
+ All = 'All',
+ // (undocumented)
+ AssignedToCurrentUser = 'AssignedToCurrentUser',
+ // (undocumented)
+ AssignedToCurrentUsersTeams = 'AssignedToCurrentUsersTeams',
+ // (undocumented)
+ AssignedToTeam = 'AssignedToTeam',
+ // (undocumented)
+ AssignedToTeams = 'AssignedToTeams',
+ // (undocumented)
+ AssignedToUser = 'AssignedToUser',
+ // (undocumented)
+ CreatedByCurrentUser = 'CreatedByCurrentUser',
+ // (undocumented)
+ CreatedByCurrentUsersTeams = 'CreatedByCurrentUsersTeams',
+ // (undocumented)
+ CreatedByTeam = 'CreatedByTeam',
+ // (undocumented)
+ CreatedByTeams = 'CreatedByTeams',
+ // (undocumented)
+ 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) "PullRequestColumnConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export interface PullRequestColumnConfig {
+ // (undocumented)
+ filters: Filter[];
+ // (undocumented)
+ simplified?: boolean;
+ // (undocumented)
+ 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;
+
// (No @packageDocumentation comment for this package)
```
diff --git a/plugins/azure-devops/package.json b/plugins/azure-devops/package.json
index a37259739f..5d048c6471 100644
--- a/plugins/azure-devops/package.json
+++ b/plugins/azure-devops/package.json
@@ -1,6 +1,6 @@
{
"name": "@backstage/plugin-azure-devops",
- "version": "0.1.6",
+ "version": "0.1.7",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -27,12 +27,12 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/catalog-model": "^0.9.8",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.4",
- "@backstage/plugin-azure-devops-common": "^0.1.2",
- "@backstage/plugin-catalog-react": "^0.6.5",
+ "@backstage/plugin-azure-devops-common": "^0.1.3",
+ "@backstage/plugin-catalog-react": "^0.6.7",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -46,8 +46,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/PullRequestsPage.tsx b/plugins/azure-devops/src/components/PullRequestsPage/PullRequestsPage.tsx
index 9f21c4b81b..158c4bca5b 100644
--- a/plugins/azure-devops/src/components/PullRequestsPage/PullRequestsPage.tsx
+++ b/plugins/azure-devops/src/components/PullRequestsPage/PullRequestsPage.tsx
@@ -21,56 +21,17 @@ import {
Progress,
ResponseErrorPanel,
} from '@backstage/core-components';
-import { PullRequestGroup, PullRequestGroupConfig } from './lib/types';
-import React, { useEffect, useState } from 'react';
-import { getCreatedByUserFilter, getPullRequestGroups } from './lib/utils';
-import { useDashboardPullRequests, useUserEmail } from '../../hooks';
+import { PullRequestColumnConfig, PullRequestGroup } from './lib/types';
+import React, { useState } from 'react';
+import { getPullRequestGroupConfigs, getPullRequestGroups } from './lib/utils';
-import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { FilterType } from './lib/filters';
import { PullRequestGrid } from './lib/PullRequestGrid';
-
-function usePullRequestGroupConfigs(
- userEmail: string | undefined,
-): PullRequestGroupConfig[] {
- const [pullRequestGroupConfigs, setPullRequestGroupConfigs] = useState<
- PullRequestGroupConfig[]
- >([]);
-
- useEffect(() => {
- const prGroupConfigs: PullRequestGroupConfig[] = [
- { title: 'Created by me', filter: getCreatedByUserFilter(userEmail) },
- { title: 'Other PRs', filter: _ => true, simplified: false },
- ];
-
- setPullRequestGroupConfigs(prGroupConfigs);
- }, [userEmail]);
-
- return pullRequestGroupConfigs;
-}
-
-function usePullRequestGroups(
- pullRequests: DashboardPullRequest[] | undefined,
- pullRequestGroupConfigs: PullRequestGroupConfig[],
-): PullRequestGroup[] {
- const [pullRequestGroups, setPullRequestGroups] = useState<
- PullRequestGroup[]
- >([]);
-
- useEffect(() => {
- if (pullRequests) {
- const groups = getPullRequestGroups(
- pullRequests,
- pullRequestGroupConfigs,
- );
- setPullRequestGroups(groups);
- }
- }, [pullRequests, pullRequestGroupConfigs]);
-
- return pullRequestGroups;
-}
+import { useDashboardPullRequests } from '../../hooks';
+import { useFilterProcessor } from './lib/hooks';
type PullRequestsPageContentProps = {
- pullRequestGroups: PullRequestGroup[];
+ pullRequestGroups: PullRequestGroup[] | undefined;
loading: boolean;
error?: Error;
};
@@ -80,7 +41,7 @@ const PullRequestsPageContent = ({
loading,
error,
}: PullRequestsPageContentProps) => {
- if (loading && pullRequestGroups.length <= 0) {
+ if (loading && (!pullRequestGroups || pullRequestGroups.length <= 0)) {
return ;
}
@@ -88,25 +49,50 @@ const PullRequestsPageContent = ({
return ;
}
- return ;
+ return ;
};
+const DEFAULT_COLUMN_CONFIGS: PullRequestColumnConfig[] = [
+ {
+ title: 'Created by me',
+ filters: [{ type: FilterType.CreatedByCurrentUser }],
+ simplified: false,
+ },
+ {
+ title: 'Other PRs',
+ filters: [{ type: FilterType.All }],
+ simplified: true,
+ },
+];
+
type PullRequestsPageProps = {
projectName?: string;
pollingInterval?: number;
+ defaultColumnConfigs?: PullRequestColumnConfig[];
};
export const PullRequestsPage = ({
projectName,
pollingInterval,
+ defaultColumnConfigs,
}: PullRequestsPageProps) => {
const { pullRequests, loading, error } = useDashboardPullRequests(
projectName,
pollingInterval,
);
- const userEmail = useUserEmail();
- const pullRequestGroupConfigs = usePullRequestGroupConfigs(userEmail);
- const pullRequestGroups = usePullRequestGroups(
+
+ const [columnConfigs] = useState(
+ defaultColumnConfigs ?? DEFAULT_COLUMN_CONFIGS,
+ );
+
+ const filterProcessor = useFilterProcessor();
+
+ const pullRequestGroupConfigs = getPullRequestGroupConfigs(
+ columnConfigs,
+ filterProcessor,
+ );
+
+ const pullRequestGroups = getPullRequestGroups(
pullRequests,
pullRequestGroupConfigs,
);
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/index.ts b/plugins/azure-devops/src/components/PullRequestsPage/index.ts
index e8b6cfa6bb..4061c72a8e 100644
--- a/plugins/azure-devops/src/components/PullRequestsPage/index.ts
+++ b/plugins/azure-devops/src/components/PullRequestsPage/index.ts
@@ -15,3 +15,17 @@
*/
export { PullRequestsPage } from './PullRequestsPage';
+export type { PullRequestColumnConfig } from './lib/types';
+export { FilterType } from './lib/filters';
+export type {
+ BaseFilter,
+ Filter,
+ PullRequestFilter,
+ AssignedToUserFilter,
+ CreatedByUserFilter,
+ AssignedToTeamFilter,
+ CreatedByTeamFilter,
+ AssignedToTeamsFilter,
+ CreatedByTeamsFilter,
+ AllFilter,
+} from './lib/filters';
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/allFilter.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/allFilter.ts
new file mode 100644
index 0000000000..90ec822ef6
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/allFilter.ts
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { BaseFilter, FilterType, PullRequestFilter } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+
+export type AllFilter = BaseFilter & {
+ type: FilterType.All;
+};
+
+export function createAllFilter(): PullRequestFilter {
+ return (_pullRequest: DashboardPullRequest): boolean => true;
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToTeamFilter.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToTeamFilter.ts
new file mode 100644
index 0000000000..8e816db2c3
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToTeamFilter.ts
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { BaseFilter, FilterType, PullRequestFilter } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { stringArrayHas } from '../../../../utils';
+
+export type AssignedToTeamFilter = BaseFilter & {
+ type: FilterType.AssignedToTeam;
+ teamId: string;
+};
+
+export function createAssignedToTeamFilter(
+ filter: AssignedToTeamFilter,
+): PullRequestFilter {
+ return (pullRequest: DashboardPullRequest): boolean => {
+ const reviewerIds = pullRequest.reviewers?.map(reviewer => reviewer.id);
+
+ if (!reviewerIds) {
+ return false;
+ }
+
+ return stringArrayHas(reviewerIds, filter.teamId, true);
+ };
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToTeamsFilter.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToTeamsFilter.ts
new file mode 100644
index 0000000000..ce5e5bcc11
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToTeamsFilter.ts
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { BaseFilter, FilterType, PullRequestFilter } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { createAssignedToTeamFilter } from './assignedToTeamFilter';
+
+export type AssignedToTeamsFilter = BaseFilter &
+ (
+ | {
+ type: FilterType.AssignedToTeams;
+ teamIds: string[];
+ }
+ | {
+ type: FilterType.AssignedToCurrentUsersTeams;
+ teamIds?: string[];
+ }
+ );
+
+export function createAssignedToTeamsFilter(
+ filter: AssignedToTeamsFilter,
+): PullRequestFilter {
+ const teamIds = filter.teamIds;
+
+ return (pullRequest: DashboardPullRequest): boolean => {
+ if (!teamIds) {
+ return false;
+ }
+
+ return teamIds.some(teamId => {
+ return createAssignedToTeamFilter({
+ type: FilterType.AssignedToTeam,
+ teamId,
+ })(pullRequest);
+ });
+ };
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToUserFilter.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToUserFilter.ts
new file mode 100644
index 0000000000..95ee3d5a59
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/assignedToUserFilter.ts
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { BaseFilter, FilterType, PullRequestFilter } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { stringArrayHas } from '../../../../utils';
+
+export type AssignedToUserFilter = BaseFilter &
+ (
+ | {
+ type: FilterType.AssignedToUser;
+ email: string;
+ }
+ | {
+ type: FilterType.AssignedToCurrentUser;
+ email?: string;
+ }
+ );
+
+export function createAssignedToUserFilter(
+ filter: AssignedToUserFilter,
+): PullRequestFilter {
+ const email = filter.email;
+
+ return (pullRequest: DashboardPullRequest): boolean => {
+ const uniqueNames = pullRequest.reviewers?.map(
+ reviewer => reviewer.uniqueName,
+ );
+
+ if (!email || !uniqueNames) {
+ return false;
+ }
+
+ return stringArrayHas(uniqueNames, email, true);
+ };
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createFilter.test.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createFilter.test.ts
new file mode 100644
index 0000000000..b0ac4d402b
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createFilter.test.ts
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Filter, FilterType } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { createFilter } from './createFilter';
+
+describe('createFilter', () => {
+ const pullRequest = {
+ createdBy: {
+ uniqueName: 'user1@backstage.com',
+ teamIds: ['team1Id', 'team2Id'],
+ },
+ reviewers: [
+ { uniqueName: 'user2@backstage.com' },
+ { id: 'team2Id' },
+ { id: 'team3Id' },
+ ],
+ } as DashboardPullRequest;
+
+ const testCases: Array<{ filter: Filter; result: boolean }> = [
+ {
+ filter: {
+ type: FilterType.AssignedToUser,
+ email: 'user2@backstage.com',
+ },
+ result: true,
+ },
+ {
+ filter: {
+ type: FilterType.AssignedToUser,
+ email: 'random-user@backstage.com',
+ },
+ result: false,
+ },
+ {
+ filter: {
+ type: FilterType.CreatedByUser,
+ email: 'user1@backstage.com',
+ },
+ result: true,
+ },
+ {
+ filter: {
+ type: FilterType.CreatedByUser,
+ email: 'random-user@backstage.com',
+ },
+ result: false,
+ },
+ {
+ filter: {
+ type: FilterType.AssignedToTeam,
+ teamId: 'team2Id',
+ },
+ result: true,
+ },
+ {
+ filter: {
+ type: FilterType.AssignedToTeam,
+ teamId: 'randomTeamId',
+ },
+ result: false,
+ },
+ {
+ filter: {
+ type: FilterType.CreatedByTeam,
+ teamId: 'team1Id',
+ },
+ result: true,
+ },
+ {
+ filter: {
+ type: FilterType.CreatedByTeam,
+ teamId: 'randomTeamId',
+ },
+ result: false,
+ },
+ {
+ filter: {
+ type: FilterType.AssignedToTeams,
+ teamIds: ['team2Id', 'randomTeamId'],
+ },
+ result: true,
+ },
+ {
+ filter: {
+ type: FilterType.AssignedToTeams,
+ teamIds: ['team2Id', 'team3Id'],
+ },
+ result: true,
+ },
+ {
+ filter: {
+ type: FilterType.AssignedToTeams,
+ teamIds: ['randomTeam1Id', 'randomTeam2Id'],
+ },
+ result: false,
+ },
+ {
+ filter: {
+ type: FilterType.CreatedByTeams,
+ teamIds: ['team1Id', 'randomTeamId'],
+ },
+ result: true,
+ },
+ {
+ filter: {
+ type: FilterType.CreatedByTeams,
+ teamIds: ['team1Id', 'team2Id'],
+ },
+ result: true,
+ },
+ {
+ filter: {
+ type: FilterType.CreatedByTeams,
+ teamIds: ['randomTeam1Id', 'randomTeam2Id'],
+ },
+ result: false,
+ },
+ {
+ filter: {
+ type: FilterType.All,
+ },
+ result: true,
+ },
+ ];
+
+ testCases.forEach(({ filter, result }) => {
+ it(`should return ${String(result)} when pull request ${
+ result ? 'is' : 'is not'
+ } ${filter.type}`, () => {
+ const pullRequestFilter = createFilter(filter);
+ expect(pullRequestFilter(pullRequest)).toBe(result);
+ });
+ });
+});
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createFilter.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createFilter.ts
new file mode 100644
index 0000000000..492d0539c5
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createFilter.ts
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Filter, FilterType, PullRequestFilter } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { createAllFilter } from './allFilter';
+import { createAssignedToTeamFilter } from './assignedToTeamFilter';
+import { createAssignedToTeamsFilter } from './assignedToTeamsFilter';
+import { createAssignedToUserFilter } from './assignedToUserFilter';
+import { createCreatedByTeamFilter } from './createdByTeamFilter';
+import { createCreatedByTeamsFilter } from './createdByTeamsFilter';
+import { createCreatedByUserFilter } from './createdByUserFilter';
+
+export function createFilter(filters: Filter | Filter[]): PullRequestFilter {
+ const mapFilter = (filter: Filter): PullRequestFilter => {
+ switch (filter.type) {
+ case FilterType.AssignedToUser:
+ case FilterType.AssignedToCurrentUser:
+ return createAssignedToUserFilter(filter);
+
+ case FilterType.CreatedByUser:
+ case FilterType.CreatedByCurrentUser:
+ return createCreatedByUserFilter(filter);
+
+ case FilterType.AssignedToTeam:
+ return createAssignedToTeamFilter(filter);
+
+ case FilterType.CreatedByTeam:
+ return createCreatedByTeamFilter(filter);
+
+ case FilterType.AssignedToTeams:
+ case FilterType.AssignedToCurrentUsersTeams:
+ return createAssignedToTeamsFilter(filter);
+
+ case FilterType.CreatedByTeams:
+ case FilterType.CreatedByCurrentUsersTeams:
+ return createCreatedByTeamsFilter(filter);
+
+ case FilterType.All:
+ return createAllFilter();
+
+ default:
+ return _ => false;
+ }
+ };
+
+ if (Array.isArray(filters)) {
+ if (filters.length === 1) {
+ return mapFilter(filters[0]);
+ }
+
+ return (pullRequest: DashboardPullRequest): boolean =>
+ filters.every(filter => mapFilter(filter)(pullRequest));
+ }
+
+ return mapFilter(filters);
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByTeamFilter.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByTeamFilter.ts
new file mode 100644
index 0000000000..70a388b540
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByTeamFilter.ts
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { BaseFilter, FilterType, PullRequestFilter } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { stringArrayHas } from '../../../../utils';
+
+export type CreatedByTeamFilter = BaseFilter &
+ ({
+ type: FilterType.CreatedByTeam;
+ } & ({ teamId: string } | { teamName: string }));
+
+export function createCreatedByTeamFilter(
+ filter: CreatedByTeamFilter,
+): PullRequestFilter {
+ return (pullRequest: DashboardPullRequest): boolean => {
+ const [createdByTeams, team] =
+ 'teamId' in filter
+ ? [pullRequest.createdBy?.teamIds, filter.teamId]
+ : [pullRequest.createdBy?.teamNames, filter.teamName];
+
+ if (!createdByTeams) {
+ return false;
+ }
+
+ return stringArrayHas(createdByTeams, team, true);
+ };
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByTeamsFilter.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByTeamsFilter.ts
new file mode 100644
index 0000000000..34ed81db5d
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByTeamsFilter.ts
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { BaseFilter, FilterType, PullRequestFilter } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { createCreatedByTeamFilter } from './createdByTeamFilter';
+
+export type CreatedByTeamsFilter = BaseFilter &
+ (
+ | ({
+ type: FilterType.CreatedByTeams;
+ } & ({ teamIds: string[] } | { teamNames: string[] }))
+ | {
+ type: FilterType.CreatedByCurrentUsersTeams;
+ teamIds?: string[];
+ }
+ );
+
+export function createCreatedByTeamsFilter(
+ filter: CreatedByTeamsFilter,
+): PullRequestFilter {
+ return (pullRequest: DashboardPullRequest): boolean => {
+ if ('teamNames' in filter) {
+ const teamNames = filter.teamNames;
+
+ if (!teamNames) {
+ return false;
+ }
+
+ return teamNames.some(teamName => {
+ return createCreatedByTeamFilter({
+ type: FilterType.CreatedByTeam,
+ teamName,
+ })(pullRequest);
+ });
+ }
+
+ const teamIds = filter.teamIds;
+
+ if (!teamIds) {
+ return false;
+ }
+
+ return teamIds.some(teamId => {
+ return createCreatedByTeamFilter({
+ type: FilterType.CreatedByTeam,
+ teamId,
+ })(pullRequest);
+ });
+ };
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByUserFilter.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByUserFilter.ts
new file mode 100644
index 0000000000..69d4f23db5
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/createdByUserFilter.ts
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { BaseFilter, FilterType, PullRequestFilter } from './types';
+
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+import { equalsIgnoreCase } from '../../../../utils';
+
+export type CreatedByUserFilter = BaseFilter &
+ (
+ | {
+ type: FilterType.CreatedByUser;
+ email: string;
+ }
+ | {
+ type: FilterType.CreatedByCurrentUser;
+ email?: string;
+ }
+ );
+
+export function createCreatedByUserFilter(
+ filter: CreatedByUserFilter,
+): PullRequestFilter {
+ const email = filter.email;
+
+ return (pullRequest: DashboardPullRequest): boolean => {
+ const uniqueName = pullRequest.createdBy?.uniqueName;
+
+ if (!email || !uniqueName) {
+ return false;
+ }
+
+ return equalsIgnoreCase(email, uniqueName);
+ };
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/index.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/index.ts
new file mode 100644
index 0000000000..df165dc9ca
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/index.ts
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export { createFilter } from './createFilter';
+export { FilterTypes, FilterType } from './types';
+export type {
+ BaseFilter,
+ Filter,
+ PullRequestFilter,
+ AssignedToUserFilter,
+ CreatedByUserFilter,
+ AssignedToTeamFilter,
+ CreatedByTeamFilter,
+ AssignedToTeamsFilter,
+ CreatedByTeamsFilter,
+ AllFilter,
+} from './types';
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/types.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/types.ts
new file mode 100644
index 0000000000..bc4643d51b
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/filters/types.ts
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AllFilter } from './allFilter';
+import { AssignedToTeamFilter } from './assignedToTeamFilter';
+import { AssignedToTeamsFilter } from './assignedToTeamsFilter';
+import { AssignedToUserFilter } from './assignedToUserFilter';
+import { CreatedByTeamFilter } from './createdByTeamFilter';
+import { CreatedByTeamsFilter } from './createdByTeamsFilter';
+import { CreatedByUserFilter } from './createdByUserFilter';
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+
+export enum FilterType {
+ All = 'All',
+
+ // Assigned To
+ AssignedToUser = 'AssignedToUser',
+ AssignedToCurrentUser = 'AssignedToCurrentUser',
+ AssignedToTeam = 'AssignedToTeam',
+ AssignedToTeams = 'AssignedToTeams',
+ AssignedToCurrentUsersTeams = 'AssignedToCurrentUsersTeams',
+
+ // Created By
+ CreatedByUser = 'CreatedByUser',
+ CreatedByCurrentUser = 'CreatedByCurrentUser',
+ CreatedByTeam = 'CreatedByTeam',
+ CreatedByTeams = 'CreatedByTeams',
+ CreatedByCurrentUsersTeams = 'CreatedByCurrentUsersTeams',
+}
+
+export const FilterTypes = [
+ FilterType.All,
+
+ FilterType.AssignedToUser,
+ FilterType.AssignedToCurrentUser,
+ FilterType.AssignedToTeam,
+ FilterType.AssignedToTeams,
+ FilterType.AssignedToCurrentUsersTeams,
+
+ FilterType.CreatedByUser,
+ FilterType.CreatedByCurrentUser,
+ FilterType.CreatedByTeam,
+ FilterType.CreatedByTeams,
+ FilterType.CreatedByCurrentUsersTeams,
+] as const;
+
+export type BaseFilter = {
+ type: FilterType;
+};
+
+export type Filter =
+ | AssignedToUserFilter
+ | CreatedByUserFilter
+ | AssignedToTeamFilter
+ | CreatedByTeamFilter
+ | AssignedToTeamsFilter
+ | CreatedByTeamsFilter
+ | AllFilter;
+
+export type {
+ AssignedToUserFilter,
+ CreatedByUserFilter,
+ AssignedToTeamFilter,
+ CreatedByTeamFilter,
+ AssignedToTeamsFilter,
+ CreatedByTeamsFilter,
+ AllFilter,
+};
+
+export type PullRequestFilter = (pullRequest: DashboardPullRequest) => boolean;
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/hooks/index.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/hooks/index.ts
new file mode 100644
index 0000000000..2e87dfea0c
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/hooks/index.ts
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export * from './useFilterProcessor';
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/hooks/useFilterProcessor.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/hooks/useFilterProcessor.ts
new file mode 100644
index 0000000000..546b23430d
--- /dev/null
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/hooks/useFilterProcessor.ts
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Filter, FilterType } from '../filters';
+
+import { useUserEmail } from '../../../../hooks';
+
+export function useFilterProcessor(): (filters: Filter[]) => Filter[] {
+ const userEmail = useUserEmail();
+
+ return (filters: Filter[]): Filter[] => {
+ for (const filter of filters) {
+ switch (filter.type) {
+ case FilterType.AssignedToCurrentUser:
+ case FilterType.CreatedByCurrentUser:
+ filter.email = userEmail;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return filters;
+ };
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/types.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/types.ts
index 2d936f7b64..74c8ebe605 100644
--- a/plugins/azure-devops/src/components/PullRequestsPage/lib/types.ts
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/types.ts
@@ -14,23 +14,24 @@
* limitations under the License.
*/
-import {
- DashboardPullRequest,
- Team,
-} from '@backstage/plugin-azure-devops-common';
+import { Filter, PullRequestFilter } from './filters';
-export interface PullRequestGroup {
+import { DashboardPullRequest } from '@backstage/plugin-azure-devops-common';
+
+export interface PullRequestColumnConfig {
title: string;
- pullRequests: DashboardPullRequest[];
+ filters: Filter[];
simplified?: boolean;
}
-export type PullRequestFilter = (pullRequest: DashboardPullRequest) => boolean;
-
-export type TeamFilter = (team: Team) => boolean;
-
export interface PullRequestGroupConfig {
title: string;
filter: PullRequestFilter;
simplified?: boolean;
}
+
+export interface PullRequestGroup {
+ title: string;
+ pullRequests: DashboardPullRequest[];
+ simplified?: boolean;
+}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/utils.test.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/utils.test.ts
index da27b2e06e..d128cbd1db 100644
--- a/plugins/azure-devops/src/components/PullRequestsPage/lib/utils.test.ts
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/utils.test.ts
@@ -19,33 +19,7 @@ import {
PullRequestVoteStatus,
Reviewer,
} from '@backstage/plugin-azure-devops-common';
-import {
- arrayExtract,
- getCreatedByUserFilter,
- getPullRequestGroups,
- reviewerFilter,
-} from './utils';
-
-describe('getCreatedByUserFilter', () => {
- it('should filter if pull request is created by user', () => {
- const userEmail = 'user1@backstage.com';
- const pr = {
- createdBy: { uniqueName: userEmail },
- } as DashboardPullRequest;
- const result = getCreatedByUserFilter(userEmail)(pr);
- expect(result).toBe(true);
- });
-
- it('should not filter if pull request is not created by user', () => {
- const userEmail1 = 'user1@backstage.com';
- const userEmail2 = 'user2@backstage.com';
- const pr = {
- createdBy: { uniqueName: userEmail1 },
- } as DashboardPullRequest;
- const result = getCreatedByUserFilter(userEmail2)(pr);
- expect(result).toBe(false);
- });
-});
+import { arrayExtract, getPullRequestGroups, reviewerFilter } from './utils';
describe('reviewerFilter', () => {
it('should return false if reviewer has no vote and is not required', () => {
@@ -128,11 +102,15 @@ describe('getPullRequestGroups', () => {
];
const configs = [
- { title: 'Created by me', filter: getCreatedByUserFilter(userEmail) },
+ {
+ title: 'Created by me',
+ filter: (pullRequest: DashboardPullRequest): boolean =>
+ pullRequest.createdBy?.uniqueName === userEmail,
+ },
{ title: 'Other PRs', filter: (_: unknown) => true, simplified: true },
];
- const result = getPullRequestGroups(pullRequests, configs);
+ const result = getPullRequestGroups(pullRequests, configs) ?? [];
expect(result.length).toBe(2);
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/utils.ts b/plugins/azure-devops/src/components/PullRequestsPage/lib/utils.ts
index c9cf866010..c4fcdc9f7e 100644
--- a/plugins/azure-devops/src/components/PullRequestsPage/lib/utils.ts
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/utils.ts
@@ -19,25 +19,13 @@ import {
PullRequestVoteStatus,
Reviewer,
} from '@backstage/plugin-azure-devops-common';
+import { Filter, createFilter } from './filters';
import {
- PullRequestFilter,
+ PullRequestColumnConfig,
PullRequestGroup,
PullRequestGroupConfig,
} from './types';
-/**
- * Creates a filter that matches pull requests created by `userEmail`.
- * @param userEmail an email to filter by.
- * @returns a filter for pull requests created by `userEmail`.
- */
-export function getCreatedByUserFilter(
- userEmail: string | undefined,
-): PullRequestFilter {
- return (pullRequest: DashboardPullRequest): boolean =>
- pullRequest.createdBy?.uniqueName?.toLocaleLowerCase() ===
- userEmail?.toLocaleLowerCase();
-}
-
/**
* Filters a reviewer based on vote status and if the reviewer is required.
* @param reviewer a reviewer to filter.
@@ -97,9 +85,13 @@ export function arrayExtract(arr: T[], filter: (value: T) => unknown): T[] {
* @returns a list of pull request groups.
*/
export function getPullRequestGroups(
- pullRequests: DashboardPullRequest[],
+ pullRequests: DashboardPullRequest[] | undefined,
configs: PullRequestGroupConfig[],
-): PullRequestGroup[] {
+): PullRequestGroup[] | undefined {
+ if (!pullRequests) {
+ return undefined;
+ }
+
const remainingPullRequests: DashboardPullRequest[] = [...pullRequests];
const pullRequestGroups: PullRequestGroup[] = [];
@@ -115,3 +107,17 @@ export function getPullRequestGroups(
return pullRequestGroups;
}
+
+export function getPullRequestGroupConfigs(
+ columnConfigs: PullRequestColumnConfig[],
+ filterProcessor: (filters: Filter[]) => Filter[],
+): PullRequestGroupConfig[] {
+ return columnConfigs.map(columnConfig => {
+ const filters = filterProcessor(columnConfig.filters);
+ return {
+ title: columnConfig.title,
+ filter: createFilter(filters),
+ simplified: columnConfig.simplified,
+ };
+ });
+}
diff --git a/plugins/azure-devops/src/index.ts b/plugins/azure-devops/src/index.ts
index c9b804bc8d..8289a93a5c 100644
--- a/plugins/azure-devops/src/index.ts
+++ b/plugins/azure-devops/src/index.ts
@@ -23,3 +23,18 @@ export {
} from './plugin';
export { AzurePullRequestsIcon } from './components/AzurePullRequestsIcon';
+
+export { FilterType } from './components/PullRequestsPage';
+export type {
+ PullRequestColumnConfig,
+ BaseFilter,
+ Filter,
+ PullRequestFilter,
+ AssignedToUserFilter,
+ CreatedByUserFilter,
+ AssignedToTeamFilter,
+ CreatedByTeamFilter,
+ AssignedToTeamsFilter,
+ CreatedByTeamsFilter,
+ AllFilter,
+} from './components/PullRequestsPage';
diff --git a/plugins/azure-devops/src/utils/arrayHas.ts b/plugins/azure-devops/src/utils/arrayHas.ts
new file mode 100644
index 0000000000..8dac8b8ec9
--- /dev/null
+++ b/plugins/azure-devops/src/utils/arrayHas.ts
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export function arrayHas(arr: T[], value: T): boolean {
+ return new Set(arr).has(value);
+}
+
+export function stringArrayHas(
+ arr: Array,
+ value: string | undefined,
+ ignoreCase: boolean = false,
+): boolean {
+ if (ignoreCase) {
+ return arrayHas(
+ arr.map(a => a?.toLocaleLowerCase('en-US')),
+ value?.toLocaleLowerCase('en-US'),
+ );
+ }
+
+ return arrayHas(arr, value);
+}
diff --git a/plugins/azure-devops/src/utils/equalsIgnoreCase.ts b/plugins/azure-devops/src/utils/equalsIgnoreCase.ts
new file mode 100644
index 0000000000..12b058e6ae
--- /dev/null
+++ b/plugins/azure-devops/src/utils/equalsIgnoreCase.ts
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export function equalsIgnoreCase(str1: string, str2: string): boolean {
+ return str1.toLocaleLowerCase('en-US') === str2.toLocaleLowerCase('en-US');
+}
diff --git a/plugins/azure-devops/src/utils/index.ts b/plugins/azure-devops/src/utils/index.ts
new file mode 100644
index 0000000000..f2214e8106
--- /dev/null
+++ b/plugins/azure-devops/src/utils/index.ts
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export * from './arrayHas';
+export * from './equalsIgnoreCase';
+export * from './getDurationFromDates';
diff --git a/plugins/badges/package.json b/plugins/badges/package.json
index 441f72c550..9d35a3b9e2 100644
--- a/plugins/badges/package.json
+++ b/plugins/badges/package.json
@@ -28,8 +28,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.5",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
@@ -43,8 +43,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/bazaar/package.json b/plugins/bazaar/package.json
index 3db79b9cdf..88da003778 100644
--- a/plugins/bazaar/package.json
+++ b/plugins/bazaar/package.json
@@ -23,8 +23,8 @@
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
"@backstage/cli": "^0.10.1",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog": "^0.7.4",
"@backstage/plugin-catalog-react": "^0.6.5",
"@date-io/luxon": "1.x",
@@ -42,7 +42,7 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
+ "@backstage/cli": "^0.10.2",
"@backstage/dev-utils": "^0.2.14",
"@testing-library/jest-dom": "^5.10.1",
"cross-fetch": "^3.0.6"
diff --git a/plugins/bitrise/package.json b/plugins/bitrise/package.json
index 35a0a9e079..c4a02c7403 100644
--- a/plugins/bitrise/package.json
+++ b/plugins/bitrise/package.json
@@ -22,8 +22,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -40,8 +40,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/catalog-backend/CHANGELOG.md b/plugins/catalog-backend/CHANGELOG.md
index dc7fc50f76..ce502f8f46 100644
--- a/plugins/catalog-backend/CHANGELOG.md
+++ b/plugins/catalog-backend/CHANGELOG.md
@@ -1,5 +1,14 @@
# @backstage/plugin-catalog-backend
+## 0.19.2
+
+### Patch Changes
+
+- 3368f27aef: Fixed the handling of optional locations so that the catalog no longer logs `NotFoundError`s for missing optional locations.
+- Updated dependencies
+ - @backstage/backend-common@0.9.14
+ - @backstage/catalog-model@0.9.8
+
## 0.19.1
### Patch Changes
diff --git a/plugins/catalog-backend/package.json b/plugins/catalog-backend/package.json
index 6cfb73a3d1..d49723b7d2 100644
--- a/plugins/catalog-backend/package.json
+++ b/plugins/catalog-backend/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/plugin-catalog-backend",
"description": "The Backstage backend plugin that provides the Backstage catalog",
- "version": "0.19.1",
+ "version": "0.19.2",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -30,9 +30,9 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/backend-common": "^0.9.13",
+ "@backstage/backend-common": "^0.9.14",
"@backstage/catalog-client": "^0.5.2",
- "@backstage/catalog-model": "^0.9.7",
+ "@backstage/catalog-model": "^0.9.8",
"@backstage/config": "^0.1.11",
"@backstage/errors": "^0.1.5",
"@backstage/integration": "^0.6.10",
@@ -63,7 +63,7 @@
},
"devDependencies": {
"@backstage/backend-test-utils": "^0.1.10",
- "@backstage/cli": "^0.10.1",
+ "@backstage/cli": "^0.10.2",
"@backstage/test-utils": "^0.1.24",
"@types/core-js": "^2.5.4",
"@types/git-url-parse": "^9.0.0",
diff --git a/plugins/catalog-backend/src/ingestion/processors/AzureDevOpsDiscoveryProcessor.test.ts b/plugins/catalog-backend/src/ingestion/processors/AzureDevOpsDiscoveryProcessor.test.ts
index ab053e8748..463d982ca2 100644
--- a/plugins/catalog-backend/src/ingestion/processors/AzureDevOpsDiscoveryProcessor.test.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/AzureDevOpsDiscoveryProcessor.test.ts
@@ -165,6 +165,7 @@ describe('AzureDevOpsDiscoveryProcessor', () => {
type: 'url',
target:
'https://dev.azure.com/shopify/engineering/_git/backstage?path=/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -174,6 +175,7 @@ describe('AzureDevOpsDiscoveryProcessor', () => {
type: 'url',
target:
'https://dev.azure.com/shopify/engineering/_git/ios-app?path=/src/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -211,6 +213,7 @@ describe('AzureDevOpsDiscoveryProcessor', () => {
type: 'url',
target:
'https://dev.azure.com/shopify/engineering/_git/backstage?path=/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -249,6 +252,7 @@ describe('AzureDevOpsDiscoveryProcessor', () => {
type: 'url',
target:
'https://dev.azure.com/shopify/engineering/_git/backstage?path=/src/main/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
diff --git a/plugins/catalog-backend/src/ingestion/processors/AzureDevOpsDiscoveryProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/AzureDevOpsDiscoveryProcessor.ts
index 58ee2155e9..aeac64f54d 100644
--- a/plugins/catalog-backend/src/ingestion/processors/AzureDevOpsDiscoveryProcessor.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/AzureDevOpsDiscoveryProcessor.ts
@@ -95,6 +95,7 @@ export class AzureDevOpsDiscoveryProcessor implements CatalogProcessor {
{
type: 'url',
target: `${baseUrl}/${org}/${project}/_git/${file.repository.name}?path=${file.path}`,
+ presence: 'optional',
},
// Not all locations may actually exist, since the user defined them as a wildcard pattern.
// Thus, we emit them as optional and let the downstream processor find them while not outputting
diff --git a/plugins/catalog-backend/src/ingestion/processors/BitbucketDiscoveryProcessor.test.ts b/plugins/catalog-backend/src/ingestion/processors/BitbucketDiscoveryProcessor.test.ts
index 2a63605b0d..3f8d0ba0fb 100644
--- a/plugins/catalog-backend/src/ingestion/processors/BitbucketDiscoveryProcessor.test.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/BitbucketDiscoveryProcessor.test.ts
@@ -208,6 +208,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.mycompany.com/projects/backstage/repos/backstage/browse/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -217,6 +218,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.mycompany.com/projects/demo/repos/demo/browse/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -242,6 +244,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.mycompany.com/projects/backstage/repos/techdocs-cli/browse/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -263,6 +266,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.mycompany.com/projects/backstage/repos/test/browse/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -291,6 +295,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.mycompany.com/projects/backstage/repos/techdocs-cli/browse/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -334,6 +339,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -343,6 +349,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-two/src/master/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -370,6 +377,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-one/src/master/my/nested/path/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -379,6 +387,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-two/src/master/my/nested/path/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -406,6 +415,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -415,6 +425,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-two/src/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -441,6 +452,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -468,6 +480,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-three/src/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -493,6 +506,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -528,6 +542,7 @@ describe('BitbucketDiscoveryProcessor', () => {
type: 'url',
target:
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
diff --git a/plugins/catalog-backend/src/ingestion/processors/GitLabDiscoveryProcessor.test.ts b/plugins/catalog-backend/src/ingestion/processors/GitLabDiscoveryProcessor.test.ts
index a0e44d7648..311de05673 100644
--- a/plugins/catalog-backend/src/ingestion/processors/GitLabDiscoveryProcessor.test.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/GitLabDiscoveryProcessor.test.ts
@@ -201,6 +201,7 @@ describe('GitlabDiscoveryProcessor', () => {
location: {
type: 'url',
target: 'https://gitlab.fake/1/-/blob/main/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
},
@@ -209,6 +210,7 @@ describe('GitlabDiscoveryProcessor', () => {
location: {
type: 'url',
target: 'https://gitlab.fake/2/-/blob/master/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
},
@@ -246,6 +248,7 @@ describe('GitlabDiscoveryProcessor', () => {
location: {
type: 'url',
target: 'https://gitlab.fake/1/-/blob/master/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
},
diff --git a/plugins/catalog-backend/src/ingestion/processors/GitLabDiscoveryProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/GitLabDiscoveryProcessor.ts
index 445f02829e..70ccd44793 100644
--- a/plugins/catalog-backend/src/ingestion/processors/GitLabDiscoveryProcessor.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/GitLabDiscoveryProcessor.ts
@@ -113,6 +113,7 @@ export class GitLabDiscoveryProcessor implements CatalogProcessor {
// The alternative is using the `buildRawUrl` function, which does not support subgroups, so providing a raw
// URL here won't work either.
target: `${project.web_url}/-/blob/${project_branch}/${catalogPath}`,
+ presence: 'optional',
},
true,
),
diff --git a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts
index 12d9e66659..59c25bb051 100644
--- a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts
@@ -157,6 +157,7 @@ describe('GithubDiscoveryProcessor', () => {
type: 'url',
target:
'https://github.com/backstage/backstage/blob/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -165,6 +166,7 @@ describe('GithubDiscoveryProcessor', () => {
location: {
type: 'url',
target: 'https://github.com/backstage/demo/blob/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -197,6 +199,7 @@ describe('GithubDiscoveryProcessor', () => {
type: 'url',
target:
'https://github.com/backstage/tech-docs/blob/main/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -251,6 +254,7 @@ describe('GithubDiscoveryProcessor', () => {
type: 'url',
target:
'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -306,6 +310,7 @@ describe('GithubDiscoveryProcessor', () => {
type: 'url',
target:
'https://github.com/backstage/techdocs-cli/blob/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -315,6 +320,7 @@ describe('GithubDiscoveryProcessor', () => {
type: 'url',
target:
'https://github.com/backstage/techdocs-container/blob/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
@@ -370,6 +376,7 @@ describe('GithubDiscoveryProcessor', () => {
location: {
type: 'url',
target: 'https://github.com/backstage/test/blob/master/catalog.yaml',
+ presence: 'optional',
},
optional: true,
});
diff --git a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts
index b104d87542..9bd6cc775e 100644
--- a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts
@@ -125,6 +125,7 @@ export class GithubDiscoveryProcessor implements CatalogProcessor {
{
type: 'url',
target: `${repository.url}${path}`,
+ presence: 'optional',
},
// Not all locations may actually exist, since the user defined them as a wildcard pattern.
// Thus, we emit them as optional and let the downstream processor find them while not outputting
diff --git a/plugins/catalog-backend/src/ingestion/processors/bitbucket/BitbucketRepositoryParser.test.ts b/plugins/catalog-backend/src/ingestion/processors/bitbucket/BitbucketRepositoryParser.test.ts
index bc6c5a540f..397d259bae 100644
--- a/plugins/catalog-backend/src/ingestion/processors/bitbucket/BitbucketRepositoryParser.test.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/bitbucket/BitbucketRepositoryParser.test.ts
@@ -29,6 +29,7 @@ describe('BitbucketRepositoryParser', () => {
{
type: 'url',
target: `${browseUrl}${path}`,
+ presence: 'optional',
},
true,
),
diff --git a/plugins/catalog-backend/src/ingestion/processors/bitbucket/BitbucketRepositoryParser.ts b/plugins/catalog-backend/src/ingestion/processors/bitbucket/BitbucketRepositoryParser.ts
index 27f07d58a2..34a9284b3e 100644
--- a/plugins/catalog-backend/src/ingestion/processors/bitbucket/BitbucketRepositoryParser.ts
+++ b/plugins/catalog-backend/src/ingestion/processors/bitbucket/BitbucketRepositoryParser.ts
@@ -30,6 +30,7 @@ export const defaultRepositoryParser: BitbucketRepositoryParser =
{
type: 'url',
target: target,
+ presence: 'optional',
},
// Not all locations may actually exist, since the user defined them as a wildcard pattern.
// Thus, we emit them as optional and let the downstream processor find them while not outputting
diff --git a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingOrchestrator.ts b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingOrchestrator.ts
index b42c8839cf..756b6a3639 100644
--- a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingOrchestrator.ts
+++ b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingOrchestrator.ts
@@ -284,7 +284,7 @@ export class DefaultCatalogProcessingOrchestrator
entity: LocationEntity,
context: Context,
): Promise {
- const { type = context.location.type } = entity.spec;
+ const { type = context.location.type, presence = 'required' } = entity.spec;
const targets = new Array();
if (entity.spec.target) {
targets.push(entity.spec.target);
@@ -318,9 +318,9 @@ export class DefaultCatalogProcessingOrchestrator
{
type,
target,
- presence: 'required',
+ presence,
},
- false,
+ presence === 'optional',
context.collector.onEmit,
this.options.parser,
context.cache.forProcessor(processor, target),
diff --git a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts
index 436038db66..b0c46b4b9f 100644
--- a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts
+++ b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts
@@ -105,8 +105,9 @@ export class ProcessorOutputCollector {
this.deferredEntities.push({ entity, locationKey: location });
} else if (i.type === 'location') {
+ const presence = i.optional ? 'optional' : 'required';
const entity = locationSpecToLocationEntity(
- i.location,
+ { presence, ...i.location },
this.parentEntity,
);
const locationKey = getEntityLocationRef(entity);
diff --git a/plugins/catalog-backend/src/util/conversion.ts b/plugins/catalog-backend/src/util/conversion.ts
index a834f81255..559a472c25 100644
--- a/plugins/catalog-backend/src/util/conversion.ts
+++ b/plugins/catalog-backend/src/util/conversion.ts
@@ -81,6 +81,7 @@ export function locationSpecToLocationEntity(
spec: {
type: location.type,
target: location.target,
+ presence: location.presence,
},
};
diff --git a/plugins/catalog-common/.eslintrc.js b/plugins/catalog-common/.eslintrc.js
new file mode 100644
index 0000000000..13573efa9c
--- /dev/null
+++ b/plugins/catalog-common/.eslintrc.js
@@ -0,0 +1,3 @@
+module.exports = {
+ extends: [require.resolve('@backstage/cli/config/eslint')],
+};
diff --git a/plugins/catalog-common/README.md b/plugins/catalog-common/README.md
new file mode 100644
index 0000000000..2566a737d8
--- /dev/null
+++ b/plugins/catalog-common/README.md
@@ -0,0 +1,9 @@
+# Catalog Common
+
+Shared isomorphic code for the catalog plugin.
+
+## Links
+
+- [Frontend part of the plugin](https://github.com/backstage/backstage/tree/master/plugins/catalog)
+- [Backend part of the plugin](https://github.com/backstage/backstage/tree/master/plugins/catalog-backend)
+- [The Backstage homepage](https://backstage.io)
diff --git a/plugins/catalog-common/api-report.md b/plugins/catalog-common/api-report.md
new file mode 100644
index 0000000000..8e03fc16b5
--- /dev/null
+++ b/plugins/catalog-common/api-report.md
@@ -0,0 +1,31 @@
+## API Report File for "@backstage/plugin-catalog-common"
+
+> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
+
+```ts
+import { Permission } from '@backstage/plugin-permission-common';
+
+// @public
+export const catalogEntityDeletePermission: Permission;
+
+// @public
+export const catalogEntityReadPermission: Permission;
+
+// @public
+export const catalogEntityRefreshPermission: Permission;
+
+// @public
+export const catalogLocationCreatePermission: Permission;
+
+// @public
+export const catalogLocationDeletePermission: Permission;
+
+// @public
+export const catalogLocationReadPermission: Permission;
+
+// @public (undocumented)
+export const RESOURCE_TYPE_CATALOG_ENTITY = 'catalog-entity';
+
+// @public (undocumented)
+export const RESOURCE_TYPE_CATALOG_LOCATION = 'catalog-location';
+```
diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json
new file mode 100644
index 0000000000..439a76fe58
--- /dev/null
+++ b/plugins/catalog-common/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "@backstage/plugin-catalog-common",
+ "description": "Common functionalities for the catalog plugin",
+ "version": "0.0.0",
+ "main": "src/index.ts",
+ "types": "src/index.ts",
+ "license": "Apache-2.0",
+ "private": false,
+ "publishConfig": {
+ "access": "public",
+ "main": "dist/index.cjs.js",
+ "module": "dist/index.esm.js",
+ "types": "dist/index.d.ts"
+ },
+ "homepage": "https://backstage.io",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/backstage/backstage",
+ "directory": "plugins/catalog-common"
+ },
+ "keywords": [
+ "backstage"
+ ],
+ "scripts": {
+ "build": "backstage-cli build",
+ "lint": "backstage-cli lint",
+ "test": "backstage-cli test --passWithNoTests",
+ "prepack": "backstage-cli prepack",
+ "postpack": "backstage-cli postpack",
+ "clean": "backstage-cli clean"
+ },
+ "dependencies": {
+ "@backstage/plugin-permission-common": "^0.2.0"
+ },
+ "devDependencies": {
+ "@backstage/cli": "^0.10.0"
+ },
+ "files": [
+ "dist"
+ ]
+}
diff --git a/plugins/catalog-common/src/index.ts b/plugins/catalog-common/src/index.ts
new file mode 100644
index 0000000000..a38a5ed93b
--- /dev/null
+++ b/plugins/catalog-common/src/index.ts
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Provides shared objects useful for interacting with the catalog and its
+ * entities, such as catalog permissions.
+ *
+ * @packageDocumentation
+ */
+
+export {
+ RESOURCE_TYPE_CATALOG_ENTITY,
+ RESOURCE_TYPE_CATALOG_LOCATION,
+ catalogEntityReadPermission,
+ catalogEntityDeletePermission,
+ catalogEntityRefreshPermission,
+ catalogLocationReadPermission,
+ catalogLocationCreatePermission,
+ catalogLocationDeletePermission,
+} from './permissions';
diff --git a/plugins/catalog-common/src/permissions.ts b/plugins/catalog-common/src/permissions.ts
new file mode 100644
index 0000000000..eb7b01c31e
--- /dev/null
+++ b/plugins/catalog-common/src/permissions.ts
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Permission } from '@backstage/plugin-permission-common';
+
+/**
+ * {@link https://backstage.io/docs/features/software-catalog/software-catalog-overview}
+ * @public
+ */
+export const RESOURCE_TYPE_CATALOG_ENTITY = 'catalog-entity';
+
+/**
+ * {@link https://backstage.io/docs/features/software-catalog/descriptor-format#kind-location}
+ * @public
+ */
+export const RESOURCE_TYPE_CATALOG_LOCATION = 'catalog-location';
+
+/**
+ * This permission is used to authorize actions that involve reading one or more
+ * entities from the catalog.
+ *
+ * If this permission is not authorized, it will appear that the entity does not
+ * exist in the catalog — both in the frontend and in API responses.
+ * @public
+ */
+export const catalogEntityReadPermission: Permission = {
+ name: 'catalog.entity.read',
+ attributes: {
+ action: 'read',
+ },
+ resourceType: RESOURCE_TYPE_CATALOG_ENTITY,
+};
+
+/**
+ * This permission is used to designate actions that involve removing one or
+ * more entities from the catalog.
+ * @public
+ */
+export const catalogEntityDeletePermission: Permission = {
+ name: 'catalog.entity.delete',
+ attributes: {
+ action: 'delete',
+ },
+ resourceType: RESOURCE_TYPE_CATALOG_ENTITY,
+};
+
+/**
+ * This permission is used to designate refreshing one or more entities from the
+ * catalog.
+ * @public
+ */
+export const catalogEntityRefreshPermission: Permission = {
+ name: 'catalog.entity.refresh',
+ attributes: {
+ action: 'update',
+ },
+ resourceType: RESOURCE_TYPE_CATALOG_ENTITY,
+};
+
+/**
+ * This permission is used to designate actions that involve reading one or more
+ * locations from the catalog.
+ *
+ * If this permission is not authorized, it will appear that the location does
+ * not exist in the catalog — both in the frontend and in API responses.
+ * @public
+ */
+export const catalogLocationReadPermission: Permission = {
+ name: 'catalog.location.read',
+ attributes: {
+ action: 'read',
+ },
+ resourceType: RESOURCE_TYPE_CATALOG_LOCATION,
+};
+
+/**
+ * This permission is used to designate actions that involve creating catalog
+ * locations.
+ * @public
+ */
+export const catalogLocationCreatePermission: Permission = {
+ name: 'catalog.location.create',
+ attributes: {
+ action: 'create',
+ },
+ resourceType: RESOURCE_TYPE_CATALOG_LOCATION,
+};
+
+/**
+ * This permission is used to designate actions that involve deleting locations
+ * from the catalog.
+ * @public
+ */
+export const catalogLocationDeletePermission: Permission = {
+ name: 'catalog.location.delete',
+ attributes: {
+ action: 'delete',
+ },
+ resourceType: RESOURCE_TYPE_CATALOG_LOCATION,
+};
diff --git a/plugins/catalog-common/src/setupTests.ts b/plugins/catalog-common/src/setupTests.ts
new file mode 100644
index 0000000000..fb7d1a181a
--- /dev/null
+++ b/plugins/catalog-common/src/setupTests.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export {};
diff --git a/plugins/catalog-graph/package.json b/plugins/catalog-graph/package.json
index b421a15265..59afadc62e 100644
--- a/plugins/catalog-graph/package.json
+++ b/plugins/catalog-graph/package.json
@@ -23,8 +23,8 @@
"dependencies": {
"@backstage/catalog-client": "^0.5.2",
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -42,8 +42,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/catalog-import/package.json b/plugins/catalog-import/package.json
index d417a337df..e017c45d09 100644
--- a/plugins/catalog-import/package.json
+++ b/plugins/catalog-import/package.json
@@ -33,8 +33,8 @@
"dependencies": {
"@backstage/catalog-client": "^0.5.2",
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.3",
"@backstage/integration": "^0.6.10",
"@backstage/integration-react": "^0.1.15",
@@ -56,8 +56,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/catalog-react/CHANGELOG.md b/plugins/catalog-react/CHANGELOG.md
index c628735ef1..0f7e08ead2 100644
--- a/plugins/catalog-react/CHANGELOG.md
+++ b/plugins/catalog-react/CHANGELOG.md
@@ -1,5 +1,21 @@
# @backstage/plugin-catalog-react
+## 0.6.7
+
+### Patch Changes
+
+- 6156fb8730: `useEntityTypeFilter`: Skip updating selected types if a kind filter change did not change them.
+- Updated dependencies
+ - @backstage/core-plugin-api@0.3.1
+ - @backstage/core-components@0.8.1
+ - @backstage/catalog-model@0.9.8
+
+## 0.6.6
+
+### Patch Changes
+
+- 4c0f0b2003: Removed dependency on `@backstage/core-app-api`.
+
## 0.6.5
### Patch Changes
diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md
index c4aa254226..d5cf06107c 100644
--- a/plugins/catalog-react/api-report.md
+++ b/plugins/catalog-react/api-report.md
@@ -9,6 +9,7 @@ import { ApiRef } from '@backstage/core-plugin-api';
import { AsyncState } from 'react-use/lib/useAsync';
import { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';
import { CatalogApi } from '@backstage/catalog-client';
+import { CatalogListResponse } from '@backstage/catalog-client';
import { ComponentEntity } from '@backstage/catalog-model';
import { ComponentProps } from 'react';
import { Context } from 'react';
@@ -271,14 +272,13 @@ export const EntityRefLink: React_2.ForwardRefExoticComponent<
| 'children'
| 'key'
| 'id'
- | 'className'
| 'classes'
- | 'innerRef'
| 'defaultChecked'
| 'defaultValue'
| 'suppressContentEditableWarning'
| 'suppressHydrationWarning'
| 'accessKey'
+ | 'className'
| 'contentEditable'
| 'contextMenu'
| 'draggable'
@@ -519,6 +519,7 @@ export const EntityRefLink: React_2.ForwardRefExoticComponent<
| 'onTransitionEndCapture'
| 'component'
| 'variant'
+ | 'innerRef'
| 'download'
| 'href'
| 'hrefLang'
@@ -847,6 +848,12 @@ export function useEntityOwnership(): {
// @public
export function useEntityTypeFilter(): EntityTypeReturn;
+// @public
+export function useOwnedEntities(allowedKinds?: string[]): {
+ loading: boolean;
+ ownedEntities: CatalogListResponse | undefined;
+};
+
// Warning: (ae-missing-release-tag) "useOwnUser" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
diff --git a/plugins/catalog-react/package.json b/plugins/catalog-react/package.json
index b5a6884fa5..0bdffc0724 100644
--- a/plugins/catalog-react/package.json
+++ b/plugins/catalog-react/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/plugin-catalog-react",
"description": "A frontend library that helps other Backstage plugins interact with the catalog",
- "version": "0.6.5",
+ "version": "0.6.7",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -30,10 +30,9 @@
},
"dependencies": {
"@backstage/catalog-client": "^0.5.2",
- "@backstage/catalog-model": "^0.9.7",
- "@backstage/core-app-api": "^0.2.0",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/catalog-model": "^0.9.8",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.4",
"@backstage/integration": "^0.6.10",
"@backstage/types": "^0.1.1",
@@ -53,7 +52,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^11.2.5",
diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts
index bbbca3a501..a6684732ce 100644
--- a/plugins/catalog-react/src/hooks/index.ts
+++ b/plugins/catalog-react/src/hooks/index.ts
@@ -42,3 +42,4 @@ export {
useEntityOwnership,
loadIdentityOwnerRefs,
} from './useEntityOwnership';
+export { useOwnedEntities } from './useOwnedEntities';
diff --git a/plugins/catalog-react/src/hooks/useEntityTypeFilter.tsx b/plugins/catalog-react/src/hooks/useEntityTypeFilter.tsx
index 5a8ed6775a..bf5777becc 100644
--- a/plugins/catalog-react/src/hooks/useEntityTypeFilter.tsx
+++ b/plugins/catalog-react/src/hooks/useEntityTypeFilter.tsx
@@ -16,6 +16,7 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { useAsync } from 'react-use';
+import isEqual from 'lodash/isEqual';
import { useApi } from '@backstage/core-plugin-api';
import { catalogApiRef } from '../api';
import { useEntityListProvider } from './useEntityListProvider';
@@ -107,7 +108,9 @@ export function useEntityTypeFilter(): EntityTypeReturn {
const stillValidTypes = selectedTypes.filter(value =>
newTypes.includes(value),
);
- setSelectedTypes(stillValidTypes);
+ if (!isEqual(selectedTypes, stillValidTypes)) {
+ setSelectedTypes(stillValidTypes);
+ }
}, [loading, kind, selectedTypes, setSelectedTypes, entities]);
useEffect(() => {
diff --git a/plugins/catalog-react/src/hooks/useOwnedEntities.ts b/plugins/catalog-react/src/hooks/useOwnedEntities.ts
new file mode 100644
index 0000000000..f9191364cb
--- /dev/null
+++ b/plugins/catalog-react/src/hooks/useOwnedEntities.ts
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { catalogApiRef } from './../api';
+import {
+ loadCatalogOwnerRefs,
+ loadIdentityOwnerRefs,
+} from './useEntityOwnership';
+import { identityApiRef, useApi } from '@backstage/core-plugin-api';
+import { Entity, RELATION_OWNED_BY } from '@backstage/catalog-model';
+import { CatalogListResponse } from '@backstage/catalog-client';
+import { useAsync } from 'react-use';
+import { useMemo } from 'react';
+
+/**
+ * Takes the relevant parts of the Backstage identity, and translates them into
+ * a list of entities which are owned by the user. Takes an optional parameter
+ * to filter the entities based on allowedKinds
+ *
+ * @public
+ *
+ * @param allowedKinds - Array of allowed kinds to filter the entities
+ * @returns CatalogListResponse
+ */
+export function useOwnedEntities(allowedKinds?: string[]): {
+ loading: boolean;
+ ownedEntities: CatalogListResponse | undefined;
+} {
+ const identityApi = useApi(identityApiRef);
+ const catalogApi = useApi(catalogApiRef);
+
+ const { loading, value: refs } = useAsync(async () => {
+ const identityRefs = await loadIdentityOwnerRefs(identityApi);
+ const catalogRefs = await loadCatalogOwnerRefs(catalogApi, identityRefs);
+ const catalogs = await catalogApi.getEntities(
+ allowedKinds
+ ? {
+ filter: {
+ kind: allowedKinds,
+ [`relations.${RELATION_OWNED_BY}`]:
+ [...identityRefs, ...catalogRefs] || [],
+ },
+ }
+ : {
+ filter: {
+ [`relations.${RELATION_OWNED_BY}`]:
+ [...identityRefs, ...catalogRefs] || [],
+ },
+ },
+ );
+ return catalogs;
+ }, []);
+
+ const ownedEntities = useMemo(() => {
+ return refs;
+ }, [refs]);
+
+ return useMemo(() => ({ loading, ownedEntities }), [loading, ownedEntities]);
+}
diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md
index 2be7fc8575..80271c89af 100644
--- a/plugins/catalog/api-report.md
+++ b/plugins/catalog/api-report.md
@@ -66,7 +66,7 @@ export type BackstageOverrides = Overrides & {
// Warning: (ae-missing-release-tag) "CatalogClientWrapper" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
-// @public
+// @public @deprecated
export class CatalogClientWrapper implements CatalogApi {
constructor(options: { client: CatalogClient; identityApi: IdentityApi });
// (undocumented)
diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json
index 57e14b5475..00504d7777 100644
--- a/plugins/catalog/package.json
+++ b/plugins/catalog/package.json
@@ -33,8 +33,8 @@
"dependencies": {
"@backstage/catalog-client": "^0.5.2",
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.3",
"@backstage/integration-react": "^0.1.15",
"@backstage/plugin-catalog-react": "^0.6.5",
@@ -53,8 +53,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/catalog/src/CatalogClientWrapper.ts b/plugins/catalog/src/CatalogClientWrapper.ts
index 0463cbf30e..c5f072e96c 100644
--- a/plugins/catalog/src/CatalogClientWrapper.ts
+++ b/plugins/catalog/src/CatalogClientWrapper.ts
@@ -30,6 +30,13 @@ import { IdentityApi } from '@backstage/core-plugin-api';
/**
* CatalogClient wrapper that injects identity token for all requests
+ *
+ * @deprecated The default catalog client now uses the `fetchApiRef`
+ * implementation, which in turn by default issues tokens just the same as this
+ * class used to assist in doing. If you use a custom `fetchApiRef`
+ * implementation that does NOT issue tokens, or use a custom `catalogApiRef`
+ * implementation which does not use the default `fetchApiRef`, you can wrap
+ * your catalog API in this class to get back the old behavior.
*/
export class CatalogClientWrapper implements CatalogApi {
private readonly identityApi: IdentityApi;
diff --git a/plugins/catalog/src/plugin.ts b/plugins/catalog/src/plugin.ts
index 20f937b2e7..66fdf4638f 100644
--- a/plugins/catalog/src/plugin.ts
+++ b/plugins/catalog/src/plugin.ts
@@ -22,7 +22,6 @@ import {
entityRouteRef,
starredEntitiesApiRef,
} from '@backstage/plugin-catalog-react';
-import { CatalogClientWrapper } from './CatalogClientWrapper';
import { createComponentRouteRef, viewTechDocRouteRef } from './routes';
import {
createApiFactory,
@@ -30,7 +29,7 @@ import {
createPlugin,
createRoutableExtension,
discoveryApiRef,
- identityApiRef,
+ fetchApiRef,
storageApiRef,
} from '@backstage/core-plugin-api';
@@ -39,14 +38,13 @@ export const catalogPlugin = createPlugin({
apis: [
createApiFactory({
api: catalogApiRef,
- deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },
- factory: ({ discoveryApi, identityApi }) =>
- new CatalogClientWrapper({
- client: new CatalogClient({ discoveryApi }),
- identityApi,
- }),
+ deps: {
+ discoveryApi: discoveryApiRef,
+ fetchApi: fetchApiRef,
+ },
+ factory: ({ discoveryApi, fetchApi }) =>
+ new CatalogClient({ discoveryApi, fetchApi }),
}),
-
createApiFactory({
api: starredEntitiesApiRef,
deps: { storageApi: storageApiRef },
diff --git a/plugins/circleci/package.json b/plugins/circleci/package.json
index e2aa415043..f449e5556c 100644
--- a/plugins/circleci/package.json
+++ b/plugins/circleci/package.json
@@ -33,8 +33,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -52,8 +52,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/cloudbuild/package.json b/plugins/cloudbuild/package.json
index 6e91b22fcb..44dafc8245 100644
--- a/plugins/cloudbuild/package.json
+++ b/plugins/cloudbuild/package.json
@@ -32,8 +32,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -49,8 +49,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/code-coverage/package.json b/plugins/code-coverage/package.json
index 951a93110a..c5cb3e3acb 100644
--- a/plugins/code-coverage/package.json
+++ b/plugins/code-coverage/package.json
@@ -23,8 +23,8 @@
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
"@backstage/config": "^0.1.11",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.4",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
@@ -43,8 +43,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/config-schema/package.json b/plugins/config-schema/package.json
index 59d34cc00d..accf5e2d01 100644
--- a/plugins/config-schema/package.json
+++ b/plugins/config-schema/package.json
@@ -22,8 +22,8 @@
},
"dependencies": {
"@backstage/config": "^0.1.11",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.5",
"@backstage/theme": "^0.2.14",
"@backstage/types": "^0.1.1",
@@ -38,8 +38,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/cost-insights/package.json b/plugins/cost-insights/package.json
index 45975163e4..94ec2bb5fe 100644
--- a/plugins/cost-insights/package.json
+++ b/plugins/cost-insights/package.json
@@ -32,8 +32,8 @@
},
"dependencies": {
"@backstage/config": "^0.1.10",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -56,8 +56,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/explore/package.json b/plugins/explore/package.json
index 9975992ea5..4db5aa31e2 100644
--- a/plugins/explore/package.json
+++ b/plugins/explore/package.json
@@ -32,8 +32,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/plugin-explore-react": "^0.0.8",
"@backstage/theme": "^0.2.14",
@@ -50,8 +50,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/firehydrant/package.json b/plugins/firehydrant/package.json
index 68ee004605..784346e07c 100644
--- a/plugins/firehydrant/package.json
+++ b/plugins/firehydrant/package.json
@@ -22,8 +22,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -36,8 +36,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/fossa/package.json b/plugins/fossa/package.json
index b28c8bd89f..6542721b61 100644
--- a/plugins/fossa/package.json
+++ b/plugins/fossa/package.json
@@ -33,8 +33,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.3",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
@@ -50,8 +50,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/gcp-projects/package.json b/plugins/gcp-projects/package.json
index e73dc7736a..5580595dc8 100644
--- a/plugins/gcp-projects/package.json
+++ b/plugins/gcp-projects/package.json
@@ -31,8 +31,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -44,8 +44,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/git-release-manager/package.json b/plugins/git-release-manager/package.json
index ab11255e08..720f624fdd 100644
--- a/plugins/git-release-manager/package.json
+++ b/plugins/git-release-manager/package.json
@@ -21,8 +21,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/integration": "^0.6.10",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -40,8 +40,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/github-actions/CHANGELOG.md b/plugins/github-actions/CHANGELOG.md
index 4c4a339415..15c8f61978 100644
--- a/plugins/github-actions/CHANGELOG.md
+++ b/plugins/github-actions/CHANGELOG.md
@@ -1,5 +1,16 @@
# @backstage/plugin-github-actions
+## 0.4.27
+
+### Patch Changes
+
+- 89bd772b00: Show empty state only when workflow API call has completed
+- Updated dependencies
+ - @backstage/core-plugin-api@0.3.1
+ - @backstage/core-components@0.8.1
+ - @backstage/catalog-model@0.9.8
+ - @backstage/plugin-catalog-react@0.6.7
+
## 0.4.26
### Patch Changes
diff --git a/plugins/github-actions/package.json b/plugins/github-actions/package.json
index 434a0b6224..22cd220e9c 100644
--- a/plugins/github-actions/package.json
+++ b/plugins/github-actions/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/plugin-github-actions",
"description": "A Backstage plugin that integrates towards GitHub Actions",
- "version": "0.4.26",
+ "version": "0.4.27",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -33,11 +33,11 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/catalog-model": "^0.9.8",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/integration": "^0.6.10",
- "@backstage/plugin-catalog-react": "^0.6.5",
+ "@backstage/plugin-catalog-react": "^0.6.7",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -52,8 +52,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/github-deployments/package.json b/plugins/github-deployments/package.json
index 1965f98ef1..d593ae7ac0 100644
--- a/plugins/github-deployments/package.json
+++ b/plugins/github-deployments/package.json
@@ -22,8 +22,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.3",
"@backstage/integration": "^0.6.10",
"@backstage/integration-react": "^0.1.15",
@@ -40,8 +40,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/gitops-profiles/package.json b/plugins/gitops-profiles/package.json
index 834fd2f7cf..b6d3f2f569 100644
--- a/plugins/gitops-profiles/package.json
+++ b/plugins/gitops-profiles/package.json
@@ -32,8 +32,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -45,8 +45,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/graphiql/package.json b/plugins/graphiql/package.json
index ec5a37bf36..7f165cbef5 100644
--- a/plugins/graphiql/package.json
+++ b/plugins/graphiql/package.json
@@ -31,8 +31,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -45,8 +45,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/home/package.json b/plugins/home/package.json
index b04e4a787d..4d14388d09 100644
--- a/plugins/home/package.json
+++ b/plugins/home/package.json
@@ -21,8 +21,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -36,8 +36,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/ilert/package.json b/plugins/ilert/package.json
index 5c07bc9d21..a476abebd8 100644
--- a/plugins/ilert/package.json
+++ b/plugins/ilert/package.json
@@ -22,8 +22,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.3",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
@@ -40,8 +40,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/jenkins-backend/api-report.md b/plugins/jenkins-backend/api-report.md
index c909c54806..b8d171f9c1 100644
--- a/plugins/jenkins-backend/api-report.md
+++ b/plugins/jenkins-backend/api-report.md
@@ -52,6 +52,8 @@ export interface JenkinsInfo {
// (undocumented)
baseUrl: string;
// (undocumented)
+ crumbIssuer?: boolean;
+ // (undocumented)
headers?: Record;
// (undocumented)
jobFullName: string;
@@ -77,6 +79,8 @@ export interface JenkinsInstanceConfig {
// (undocumented)
baseUrl: string;
// (undocumented)
+ crumbIssuer?: boolean;
+ // (undocumented)
name: string;
// (undocumented)
username: string;
diff --git a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts
index 5f74259eef..a410d8ad92 100644
--- a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts
+++ b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts
@@ -411,4 +411,17 @@ describe('JenkinsApi', () => {
});
expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName);
});
+
+ it('buildProject with crumbIssuer option', async () => {
+ const info: JenkinsInfo = { ...jenkinsInfo, crumbIssuer: true };
+ await jenkinsApi.buildProject(info, jobFullName);
+
+ expect(mockedJenkins).toHaveBeenCalledWith({
+ baseUrl: jenkinsInfo.baseUrl,
+ headers: jenkinsInfo.headers,
+ promisify: true,
+ crumbIssuer: true,
+ });
+ expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName);
+ });
});
diff --git a/plugins/jenkins-backend/src/service/jenkinsApi.ts b/plugins/jenkins-backend/src/service/jenkinsApi.ts
index 13705ce049..f156259f04 100644
--- a/plugins/jenkins-backend/src/service/jenkinsApi.ts
+++ b/plugins/jenkins-backend/src/service/jenkinsApi.ts
@@ -146,6 +146,7 @@ export class JenkinsApiImpl {
baseUrl: jenkinsInfo.baseUrl,
headers: jenkinsInfo.headers,
promisify: true,
+ crumbIssuer: jenkinsInfo.crumbIssuer,
}) as any;
}
diff --git a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts
index 08439297a7..21a2022bb3 100644
--- a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts
+++ b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts
@@ -210,6 +210,7 @@ describe('DefaultJenkinsInfoProvider', () => {
expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef);
expect(info).toStrictEqual({
baseUrl: 'https://jenkins.example.com',
+ crumbIssuer: undefined,
headers: {
Authorization:
'Basic YmFja3N0YWdlIC0gYm90OjEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNlZGYwMTI=',
diff --git a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts
index 1a992e73f1..f5cb52b696 100644
--- a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts
+++ b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts
@@ -38,6 +38,7 @@ export interface JenkinsInfo {
baseUrl: string;
headers?: Record;
jobFullName: string; // TODO: make this an array
+ crumbIssuer?: boolean;
}
export interface JenkinsInstanceConfig {
@@ -45,6 +46,7 @@ export interface JenkinsInstanceConfig {
baseUrl: string;
username: string;
apiKey: string;
+ crumbIssuer?: boolean;
}
/**
@@ -70,6 +72,7 @@ export class JenkinsConfig {
baseUrl: c.getString('baseUrl'),
username: c.getString('username'),
apiKey: c.getString('apiKey'),
+ crumbIssuer: c.getOptionalBoolean('crumbIssuer'),
})) || [];
// load unnamed default config
@@ -81,6 +84,7 @@ export class JenkinsConfig {
const baseUrl = jenkinsConfig.getOptionalString('baseUrl');
const username = jenkinsConfig.getOptionalString('username');
const apiKey = jenkinsConfig.getOptionalString('apiKey');
+ const crumbIssuer = jenkinsConfig.getOptionalBoolean('crumbIssuer');
if (hasNamedDefault && (baseUrl || username || apiKey)) {
throw new Error(
@@ -98,12 +102,13 @@ export class JenkinsConfig {
if (unnamedAllPresent) {
const unnamedInstanceConfig = [
- { name: DEFAULT_JENKINS_NAME, baseUrl, username, apiKey },
+ { name: DEFAULT_JENKINS_NAME, baseUrl, username, apiKey, crumbIssuer },
] as {
name: string;
baseUrl: string;
username: string;
apiKey: string;
+ crumbIssuer: boolean;
}[];
return new JenkinsConfig([
@@ -227,6 +232,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider {
Authorization: `Basic ${creds}`,
},
jobFullName,
+ crumbIssuer: instanceConfig.crumbIssuer,
};
}
diff --git a/plugins/jenkins/api-report.md b/plugins/jenkins/api-report.md
index f33e565d89..a6926c1639 100644
--- a/plugins/jenkins/api-report.md
+++ b/plugins/jenkins/api-report.md
@@ -9,8 +9,8 @@ import { ApiRef } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
-import { EntityName } from '@backstage/catalog-model';
-import { EntityRef } from '@backstage/catalog-model';
+import type { EntityName } from '@backstage/catalog-model';
+import type { EntityRef } from '@backstage/catalog-model';
import { IdentityApi } from '@backstage/core-plugin-api';
import { InfoCardVariants } from '@backstage/core-components';
import { RouteRef } from '@backstage/core-plugin-api';
diff --git a/plugins/jenkins/package.json b/plugins/jenkins/package.json
index 2211bf54de..862c2cdfb3 100644
--- a/plugins/jenkins/package.json
+++ b/plugins/jenkins/package.json
@@ -33,8 +33,9 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
+ "@backstage/errors": "^0.1.5",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -49,8 +50,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/jenkins/src/api/JenkinsApi.ts b/plugins/jenkins/src/api/JenkinsApi.ts
index 4b23fb4292..33edf0ade3 100644
--- a/plugins/jenkins/src/api/JenkinsApi.ts
+++ b/plugins/jenkins/src/api/JenkinsApi.ts
@@ -19,7 +19,8 @@ import {
DiscoveryApi,
IdentityApi,
} from '@backstage/core-plugin-api';
-import { EntityName, EntityRef } from '@backstage/catalog-model';
+import type { EntityName, EntityRef } from '@backstage/catalog-model';
+import { ResponseError } from '@backstage/errors';
export const jenkinsApiRef = createApiRef({
id: 'plugin.jenkins.service2',
@@ -140,7 +141,7 @@ export class JenkinsClient implements JenkinsApi {
url.searchParams.append('branch', filter.branch);
}
- const idToken = await this.identityApi.getIdToken();
+ const idToken = await this.getToken();
const response = await fetch(url.href, {
method: 'GET',
headers: {
@@ -151,8 +152,8 @@ export class JenkinsClient implements JenkinsApi {
return (
(await response.json()).projects?.map((p: Project) => ({
...p,
- onRestartClick: async () => {
- await this.retry({
+ onRestartClick: () => {
+ return this.retry({
entity,
jobFullName: p.fullName,
buildNumber: String(p.lastBuild.number),
@@ -179,7 +180,7 @@ export class JenkinsClient implements JenkinsApi {
jobFullName,
)}/${encodeURIComponent(buildNumber)}`;
- const idToken = await this.identityApi.getIdToken();
+ const idToken = await this.getToken();
const response = await fetch(url, {
method: 'GET',
headers: {
@@ -207,12 +208,21 @@ export class JenkinsClient implements JenkinsApi {
jobFullName,
)}/${encodeURIComponent(buildNumber)}:rebuild`;
- const idToken = await this.identityApi.getIdToken();
- await fetch(url, {
+ const idToken = await this.getToken();
+ const response = await fetch(url, {
method: 'POST',
headers: {
...(idToken && { Authorization: `Bearer ${idToken}` }),
},
});
+
+ if (!response.ok) {
+ throw await ResponseError.fromResponse(response);
+ }
+ }
+
+ private async getToken() {
+ const { token } = await this.identityApi.getCredentials();
+ return token;
}
}
diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx
index b1eaf2c24c..a959ba39c9 100644
--- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx
+++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx
@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
-import { Box, IconButton, Link, Typography, Tooltip } from '@material-ui/core';
+import React, { useState } from 'react';
+import { Box, IconButton, Link, Tooltip, Typography } from '@material-ui/core';
import RetryIcon from '@material-ui/icons/Replay';
import JenkinsLogo from '../../../../assets/JenkinsLogo.svg';
import { Link as RouterLink } from 'react-router-dom';
import { JenkinsRunStatus } from '../Status';
import { useBuilds } from '../../../useBuilds';
import { buildRouteRef } from '../../../../plugin';
-import { Table, TableColumn } from '@backstage/core-components';
+import { Progress, Table, TableColumn } from '@backstage/core-components';
import { Project } from '../../../../api/JenkinsApi';
-import { useRouteRef } from '@backstage/core-plugin-api';
+import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';
const FailCount = ({ count }: { count: number }): JSX.Element | null => {
if (count !== 0) {
@@ -173,13 +173,46 @@ const generatedColumns: TableColumn[] = [
{
title: 'Actions',
sorting: false,
- render: (row: Partial) => (
-
-
-
-
-
- ),
+ render: (row: Partial) => {
+ const ActionWrapper = () => {
+ const [isLoadingRebuild, setIsLoadingRebuild] = useState(false);
+ const alertApi = useApi(alertApiRef);
+
+ const onRebuild = async () => {
+ if (row.onRestartClick) {
+ setIsLoadingRebuild(true);
+ try {
+ await row.onRestartClick();
+ alertApi.post({
+ message: 'Jenkins re-build has successfully executed',
+ severity: 'success',
+ });
+ } catch (e) {
+ alertApi.post({
+ message: `Jenkins re-build has failed. Error: ${e.message}`,
+ severity: 'error',
+ });
+ } finally {
+ setIsLoadingRebuild(false);
+ }
+ }
+ };
+
+ return (
+
+ <>
+ {isLoadingRebuild && }
+ {!isLoadingRebuild && (
+
+
+
+ )}
+ >
+
+ );
+ };
+ return ;
+ },
width: '10%',
},
];
diff --git a/plugins/kafka/package.json b/plugins/kafka/package.json
index 309e239a68..d3353a1f0d 100644
--- a/plugins/kafka/package.json
+++ b/plugins/kafka/package.json
@@ -22,8 +22,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -36,8 +36,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/kubernetes/CHANGELOG.md b/plugins/kubernetes/CHANGELOG.md
index 0329a9bc5b..94826738b3 100644
--- a/plugins/kubernetes/CHANGELOG.md
+++ b/plugins/kubernetes/CHANGELOG.md
@@ -1,5 +1,16 @@
# @backstage/plugin-kubernetes
+## 0.5.1
+
+### Patch Changes
+
+- 6f0c850a86: Fixed styling bug for the CronJobsAccordions and updated Completed pods to display a green dot.
+- Updated dependencies
+ - @backstage/core-plugin-api@0.3.1
+ - @backstage/core-components@0.8.1
+ - @backstage/catalog-model@0.9.8
+ - @backstage/plugin-catalog-react@0.6.7
+
## 0.5.0
### Minor Changes
diff --git a/plugins/kubernetes/package.json b/plugins/kubernetes/package.json
index 3a2ea6a9a9..02b8e85855 100644
--- a/plugins/kubernetes/package.json
+++ b/plugins/kubernetes/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/plugin-kubernetes",
"description": "A Backstage plugin that integrates towards Kubernetes",
- "version": "0.5.0",
+ "version": "0.5.1",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -31,11 +31,11 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/catalog-model": "^0.9.7",
+ "@backstage/catalog-model": "^0.9.8",
"@backstage/config": "^0.1.11",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
- "@backstage/plugin-catalog-react": "^0.6.5",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
+ "@backstage/plugin-catalog-react": "^0.6.7",
"@backstage/plugin-kubernetes-common": "^0.2.0",
"@kubernetes/client-node": "^0.16.0",
"@backstage/theme": "^0.2.14",
@@ -53,8 +53,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/kubernetes/src/components/Cluster/Cluster.tsx b/plugins/kubernetes/src/components/Cluster/Cluster.tsx
index b7a819cdbf..eb12ba20f8 100644
--- a/plugins/kubernetes/src/components/Cluster/Cluster.tsx
+++ b/plugins/kubernetes/src/components/Cluster/Cluster.tsx
@@ -148,9 +148,9 @@ export const Cluster = ({ clusterObjects, podsWithErrors }: ClusterProps) => {
-
-
-
+
+
+
diff --git a/plugins/kubernetes/src/utils/pod.tsx b/plugins/kubernetes/src/utils/pod.tsx
index bfb40750cd..50cc983b9d 100644
--- a/plugins/kubernetes/src/utils/pod.tsx
+++ b/plugins/kubernetes/src/utils/pod.tsx
@@ -63,7 +63,13 @@ export const containerStatuses = (pod: V1Pod): ReactNode => {
const renderCell = (reason: string | undefined) => (
Container: {next.name}}
+ value={
+ reason === 'Completed' ? (
+ Container: {next.name}
+ ) : (
+ Container: {next.name}
+ )
+ }
subvalue={reason}
/>
diff --git a/plugins/lighthouse/package.json b/plugins/lighthouse/package.json
index 43aabc3e3f..3820e85fdd 100644
--- a/plugins/lighthouse/package.json
+++ b/plugins/lighthouse/package.json
@@ -34,8 +34,8 @@
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
"@backstage/config": "^0.1.10",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -48,8 +48,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/newrelic/package.json b/plugins/newrelic/package.json
index b7be235b9e..9a32e23e18 100644
--- a/plugins/newrelic/package.json
+++ b/plugins/newrelic/package.json
@@ -32,8 +32,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -44,8 +44,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/org/CHANGELOG.md b/plugins/org/CHANGELOG.md
index 0576d644da..eb2599237c 100644
--- a/plugins/org/CHANGELOG.md
+++ b/plugins/org/CHANGELOG.md
@@ -1,5 +1,16 @@
# @backstage/plugin-org
+## 0.3.31
+
+### Patch Changes
+
+- fe86adbcd2: Added `entityFilterKind` property for `EntityOwnershipCard`
+- Updated dependencies
+ - @backstage/core-plugin-api@0.3.1
+ - @backstage/core-components@0.8.1
+ - @backstage/catalog-model@0.9.8
+ - @backstage/plugin-catalog-react@0.6.7
+
## 0.3.30
### Patch Changes
diff --git a/plugins/org/api-report.md b/plugins/org/api-report.md
index 88ce00fd52..60caa45134 100644
--- a/plugins/org/api-report.md
+++ b/plugins/org/api-report.md
@@ -33,9 +33,11 @@ export const EntityMembersListCard: (_props: {
// @public (undocumented)
export const EntityOwnershipCard: ({
variant,
+ entityFilterKind,
}: {
entity?: Entity | undefined;
variant?: InfoCardVariants | undefined;
+ entityFilterKind?: string[] | undefined;
}) => JSX.Element;
// Warning: (ae-missing-release-tag) "EntityUserProfileCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -75,9 +77,11 @@ export { orgPlugin as plugin };
// @public (undocumented)
export const OwnershipCard: ({
variant,
+ entityFilterKind,
}: {
entity?: Entity | undefined;
variant?: InfoCardVariants | undefined;
+ entityFilterKind?: string[] | undefined;
}) => JSX.Element;
// Warning: (ae-missing-release-tag) "UserProfileCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
diff --git a/plugins/org/package.json b/plugins/org/package.json
index 4e7f556547..def4bac002 100644
--- a/plugins/org/package.json
+++ b/plugins/org/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/plugin-org",
"description": "A Backstage plugin that helps you create entity pages for your organization",
- "version": "0.3.30",
+ "version": "0.3.31",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -21,14 +21,15 @@
"clean": "backstage-cli clean"
},
"dependencies": {
- "@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
- "@backstage/plugin-catalog-react": "^0.6.5",
+ "@backstage/catalog-model": "^0.9.8",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
+ "@backstage/plugin-catalog-react": "^0.6.7",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
+ "pluralize": "^8.0.0",
"qs": "^6.10.1",
"react-router": "6.0.0-beta.0",
"react-router-dom": "6.0.0-beta.0",
@@ -38,8 +39,9 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
+ "@backstage/catalog-client": "^0.5.2",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx
index 8d6fc1a002..439365e583 100644
--- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx
+++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx
@@ -14,7 +14,11 @@
* limitations under the License.
*/
-import { GroupEntity, UserEntity } from '@backstage/catalog-model';
+import {
+ CatalogEntitiesRequest,
+ CatalogListResponse,
+} from '@backstage/catalog-client';
+import { Entity, GroupEntity, UserEntity } from '@backstage/catalog-model';
import {
CatalogApi,
catalogApiRef,
@@ -26,6 +30,97 @@ import { queryByText } from '@testing-library/react';
import React from 'react';
import { OwnershipCard } from './OwnershipCard';
+const items = [
+ {
+ apiVersion: 'backstage.io/v1alpha1',
+ kind: 'API',
+ metadata: {
+ name: 'my-api',
+ },
+ spec: {
+ type: 'openapi',
+ },
+ relations: [
+ {
+ type: 'ownedBy',
+ target: {
+ name: 'my-team',
+ namespace: 'default',
+ kind: 'Group',
+ },
+ },
+ ],
+ },
+ {
+ kind: 'Component',
+ metadata: {
+ name: 'my-service',
+ },
+ spec: {
+ type: 'service',
+ },
+ relations: [
+ {
+ type: 'ownedBy',
+ target: {
+ name: 'my-team',
+ namespace: 'default',
+ kind: 'Group',
+ },
+ },
+ ],
+ },
+ {
+ kind: 'Component',
+ metadata: {
+ name: 'my-library',
+ namespace: 'other-namespace',
+ },
+ spec: {
+ type: 'library',
+ },
+ relations: [
+ {
+ type: 'ownedBy',
+ target: {
+ name: 'my-team',
+ namespace: 'default',
+ kind: 'Group',
+ },
+ },
+ ],
+ },
+ {
+ apiVersion: 'backstage.io/v1alpha1',
+ kind: 'System',
+ metadata: {
+ name: 'my-system',
+ },
+ relations: [
+ {
+ type: 'ownedBy',
+ target: {
+ name: 'my-team',
+ namespace: 'default',
+ kind: 'Group',
+ },
+ },
+ ],
+ },
+] as Entity[];
+
+const getEntitiesMock = (
+ request?: CatalogEntitiesRequest,
+): Promise> => {
+ const filterKinds =
+ !Array.isArray(request?.filter) && Array.isArray(request?.filter?.kind)
+ ? request?.filter?.kind ?? []
+ : []; // we expect the request to be like { filter: { kind: ['API','System'], .... }. If changed in OwnerShipCard, let's change in also here
+ return Promise.resolve({
+ items: items.filter(item => filterKinds.find(k => k === item.kind)),
+ } as CatalogListResponse);
+};
+
describe('OwnershipCard', () => {
const groupEntity: GroupEntity = {
apiVersion: 'backstage.io/v1alpha1',
@@ -49,75 +144,12 @@ describe('OwnershipCard', () => {
],
};
- const items = [
- {
- kind: 'API',
- metadata: {
- name: 'my-api',
- },
- spec: {
- type: 'openapi',
- },
- relations: [
- {
- type: 'ownedBy',
- target: {
- name: 'my-team',
- namespace: 'default',
- kind: 'Group',
- },
- },
- ],
- },
- {
- kind: 'Component',
- metadata: {
- name: 'my-service',
- },
- spec: {
- type: 'service',
- },
- relations: [
- {
- type: 'ownedBy',
- target: {
- name: 'my-team',
- namespace: 'default',
- kind: 'Group',
- },
- },
- ],
- },
- {
- kind: 'Component',
- metadata: {
- name: 'my-library',
- namespace: 'other-namespace',
- },
- spec: {
- type: 'library',
- },
- relations: [
- {
- type: 'ownedBy',
- target: {
- name: 'my-team',
- namespace: 'default',
- kind: 'Group',
- },
- },
- ],
- },
- ] as any;
-
it('displays entity counts', async () => {
const catalogApi: jest.Mocked = {
getEntities: jest.fn(),
} as any;
- catalogApi.getEntities.mockResolvedValue({
- items,
- });
+ catalogApi.getEntities.mockImplementation(getEntitiesMock);
const { getByText } = await renderInTestApp(
@@ -132,6 +164,17 @@ describe('OwnershipCard', () => {
},
);
+ expect(catalogApi.getEntities).toHaveBeenCalledWith({
+ filter: { kind: ['Component', 'API'] },
+ fields: [
+ 'kind',
+ 'metadata.name',
+ 'metadata.namespace',
+ 'spec.type',
+ 'relations',
+ ],
+ });
+
expect(getByText('OPENAPI')).toBeInTheDocument();
expect(
queryByText(getByText('OPENAPI').parentElement!, '1'),
@@ -144,6 +187,38 @@ describe('OwnershipCard', () => {
expect(
queryByText(getByText('LIBRARY').parentElement!, '1'),
).toBeInTheDocument();
+ expect(() => getByText('SYSTEM')).toThrowError();
+ });
+
+ it('applies CustomFilterDefinition', async () => {
+ const catalogApi: jest.Mocked = {
+ getEntities: jest.fn(),
+ } as any;
+
+ catalogApi.getEntities.mockImplementation(getEntitiesMock);
+
+ const { getByText } = await renderInTestApp(
+
+
+
+
+ ,
+ {
+ mountedRoutes: {
+ '/create': catalogRouteRef,
+ },
+ },
+ );
+
+ expect(getByText('SYSTEM')).toBeInTheDocument();
+ expect(
+ queryByText(getByText('SYSTEM').parentElement!, '1'),
+ ).toBeInTheDocument();
+ expect(getByText('OPENAPI')).toBeInTheDocument();
+ expect(
+ queryByText(getByText('OPENAPI').parentElement!, '1'),
+ ).toBeInTheDocument();
+ expect(() => getByText('LIBRARY')).toThrowError();
});
it('links to the catalog with the group filter', async () => {
@@ -151,9 +226,7 @@ describe('OwnershipCard', () => {
getEntities: jest.fn(),
} as any;
- catalogApi.getEntities.mockResolvedValue({
- items,
- });
+ catalogApi.getEntities.mockImplementation(getEntitiesMock);
const { getByText } = await renderInTestApp(
@@ -199,9 +272,7 @@ describe('OwnershipCard', () => {
getEntities: jest.fn(),
} as any;
- catalogApi.getEntities.mockResolvedValue({
- items,
- });
+ catalogApi.getEntities.mockImplementation(getEntitiesMock);
const { getByText } = await renderInTestApp(
diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx
index fe23191779..e8d7c44816 100644
--- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx
+++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx
@@ -40,6 +40,7 @@ import {
} from '@material-ui/core';
import qs from 'qs';
import React from 'react';
+import pluralize from 'pluralize';
import { useAsync } from 'react-use';
type EntityTypeProps = {
@@ -96,7 +97,7 @@ const EntityCountTile = ({
{counter}
- {name}
+ {pluralize(name, counter)}
@@ -128,10 +129,12 @@ const getQueryParams = (
export const OwnershipCard = ({
variant,
+ entityFilterKind,
}: {
/** @deprecated The entity is now grabbed from context instead */
entity?: Entity;
variant?: InfoCardVariants;
+ entityFilterKind?: string[];
}) => {
const { entity } = useEntity();
const catalogApi = useApi(catalogApiRef);
@@ -142,7 +145,7 @@ export const OwnershipCard = ({
error,
value: componentsWithCounters,
} = useAsync(async () => {
- const kinds = ['Component', 'API'];
+ const kinds = entityFilterKind ?? ['Component', 'API'];
const entitiesList = await catalogApi.getEntities({
filter: {
kind: kinds,
@@ -162,17 +165,17 @@ export const OwnershipCard = ({
const counts = ownedEntitiesList.reduce(
(acc: EntityTypeProps[], ownedEntity) => {
- if (typeof ownedEntity.spec?.type !== 'string') return acc;
-
const match = acc.find(
- x => x.kind === ownedEntity.kind && x.type === ownedEntity.spec?.type,
+ x =>
+ x.kind === ownedEntity.kind &&
+ x.type === (ownedEntity.spec?.type ?? ownedEntity.kind),
);
if (match) {
match.count += 1;
} else {
acc.push({
kind: ownedEntity.kind,
- type: ownedEntity.spec?.type,
+ type: ownedEntity.spec?.type?.toString() ?? ownedEntity.kind,
count: 1,
});
}
diff --git a/plugins/pagerduty/package.json b/plugins/pagerduty/package.json
index 59e76878b5..1b6c38465f 100644
--- a/plugins/pagerduty/package.json
+++ b/plugins/pagerduty/package.json
@@ -32,8 +32,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -49,8 +49,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/rollbar/package.json b/plugins/rollbar/package.json
index d6a14a5b2a..012cb24490 100644
--- a/plugins/rollbar/package.json
+++ b/plugins/rollbar/package.json
@@ -33,8 +33,8 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.9.7",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/plugin-catalog-react": "^0.6.5",
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
@@ -50,8 +50,8 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
diff --git a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts
index 00a5690c0a..56c45fa015 100644
--- a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts
+++ b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts
@@ -96,6 +96,16 @@ export function createFetchRailsAction(options: {
description: "Don't run Webpack install",
type: 'boolean',
},
+ skipTest: {
+ title: 'skipTest',
+ description: 'Skip test files',
+ type: 'boolean',
+ },
+ force: {
+ title: 'force',
+ description: 'Overwrite files that already exist',
+ type: 'boolean',
+ },
api: {
title: 'api',
description: 'Preconfigure smaller stack for API only apps',
diff --git a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsArgumentResolver.test.ts b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsArgumentResolver.test.ts
index 99a113f4f7..cced9f7ac2 100644
--- a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsArgumentResolver.test.ts
+++ b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsArgumentResolver.test.ts
@@ -27,6 +27,8 @@ describe('railsArgumentResolver', () => {
[{ api: true }, ['--api']],
[{ skipBundle: true }, ['--skip-bundle']],
[{ skipWebpackInstall: true }, ['--skip-webpack-install']],
+ [{ skipTest: true }, ['--skip-test']],
+ [{ force: true }, ['--force']],
[{ webpacker: 'vue' }, ['--webpack', 'vue']],
[{ database: 'postgresql' }, ['--database', 'postgresql']],
[{ railsVersion: 'dev' }, ['--dev']],
diff --git a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsArgumentResolver.ts b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsArgumentResolver.ts
index 60251a702d..4006ead630 100644
--- a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsArgumentResolver.ts
+++ b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsArgumentResolver.ts
@@ -51,6 +51,8 @@ export type RailsRunOptions = {
railsVersion?: RailsVersion;
skipBundle?: boolean;
skipWebpackInstall?: boolean;
+ skipTest?: boolean;
+ force?: boolean;
};
export const railsArgumentResolver = (
@@ -76,6 +78,14 @@ export const railsArgumentResolver = (
argumentsToRun.push('--skip-webpack-install');
}
+ if (options?.skipTest) {
+ argumentsToRun.push('--skip-test');
+ }
+
+ if (options?.force) {
+ argumentsToRun.push('--force');
+ }
+
if (
options?.webpacker &&
Object.values(Webpacker).includes(options?.webpacker as Webpacker)
diff --git a/plugins/scaffolder-backend/CHANGELOG.md b/plugins/scaffolder-backend/CHANGELOG.md
index 3986961f16..50d10b564c 100644
--- a/plugins/scaffolder-backend/CHANGELOG.md
+++ b/plugins/scaffolder-backend/CHANGELOG.md
@@ -1,5 +1,16 @@
# @backstage/plugin-scaffolder-backend
+## 0.15.17
+
+### Patch Changes
+
+- eec0750d8d: Makes cookiecutter a default, but optional action based on if a containerRunner argument is passed in to createRouter or createBuiltinActions
+- ed52f74ab3: Adding changes to create GitLab Merge Request using custom action
+- Updated dependencies
+ - @backstage/plugin-catalog-backend@0.19.2
+ - @backstage/backend-common@0.9.14
+ - @backstage/catalog-model@0.9.8
+
## 0.15.16
### Patch Changes
diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md
index 6ed4625f66..b7c1a9146c 100644
--- a/plugins/scaffolder-backend/api-report.md
+++ b/plugins/scaffolder-backend/api-report.md
@@ -68,7 +68,7 @@ export const createBuiltinActions: (options: {
reader: UrlReader;
integrations: ScmIntegrations;
catalogClient: CatalogApi;
- containerRunner: ContainerRunner;
+ containerRunner?: ContainerRunner;
config: Config;
}) => TemplateAction[];
@@ -179,6 +179,13 @@ export function createPublishGitlabAction(options: {
config: Config;
}): TemplateAction;
+// Warning: (ae-missing-release-tag) "createPublishGitlabMergeRequestAction" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const createPublishGitlabMergeRequestAction: (options: {
+ integrations: ScmIntegrationRegistry;
+}) => TemplateAction;
+
// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -289,7 +296,7 @@ export interface RouterOptions {
// (undocumented)
config: Config;
// (undocumented)
- containerRunner: ContainerRunner;
+ containerRunner?: ContainerRunner;
// (undocumented)
database: PluginDatabaseManager;
// (undocumented)
diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json
index 2dae658d74..3686c33c40 100644
--- a/plugins/scaffolder-backend/package.json
+++ b/plugins/scaffolder-backend/package.json
@@ -1,7 +1,7 @@
{
"name": "@backstage/plugin-scaffolder-backend",
"description": "The Backstage backend plugin that helps you create new things",
- "version": "0.15.16",
+ "version": "0.15.17",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -31,13 +31,13 @@
"build:assets": "node scripts/build-nunjucks.js"
},
"dependencies": {
- "@backstage/backend-common": "^0.9.13",
+ "@backstage/backend-common": "^0.9.14",
"@backstage/catalog-client": "^0.5.2",
- "@backstage/catalog-model": "^0.9.7",
+ "@backstage/catalog-model": "^0.9.8",
"@backstage/config": "^0.1.11",
"@backstage/errors": "^0.1.5",
"@backstage/integration": "^0.6.10",
- "@backstage/plugin-catalog-backend": "^0.19.1",
+ "@backstage/plugin-catalog-backend": "^0.19.2",
"@backstage/plugin-scaffolder-common": "^0.1.1",
"@backstage/plugin-scaffolder-backend-module-cookiecutter": "^0.1.5",
"@backstage/types": "^0.1.1",
@@ -73,7 +73,7 @@
"vm2": "^3.9.5"
},
"devDependencies": {
- "@backstage/cli": "^0.10.1",
+ "@backstage/cli": "^0.10.2",
"@backstage/test-utils": "^0.1.24",
"@types/command-exists": "^1.2.0",
"@types/fs-extra": "^9.0.1",
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts
index d38dfe3cdc..93ecceb76a 100644
--- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts
@@ -36,6 +36,7 @@ import {
createPublishGithubAction,
createPublishGithubPullRequestAction,
createPublishGitlabAction,
+ createPublishGitlabMergeRequestAction,
} from './publish';
import {
createGithubActionsDispatchAction,
@@ -46,22 +47,17 @@ export const createBuiltinActions = (options: {
reader: UrlReader;
integrations: ScmIntegrations;
catalogClient: CatalogApi;
- containerRunner: ContainerRunner;
+ containerRunner?: ContainerRunner;
config: Config;
}) => {
const { reader, integrations, containerRunner, catalogClient, config } =
options;
- return [
+ const actions = [
createFetchPlainAction({
reader,
integrations,
}),
- createFetchCookiecutterAction({
- reader,
- integrations,
- containerRunner,
- }),
createFetchTemplateAction({
integrations,
reader,
@@ -77,6 +73,9 @@ export const createBuiltinActions = (options: {
integrations,
config,
}),
+ createPublishGitlabMergeRequestAction({
+ integrations,
+ }),
createPublishBitbucketAction({
integrations,
config,
@@ -97,4 +96,16 @@ export const createBuiltinActions = (options: {
integrations,
}),
];
+
+ if (containerRunner) {
+ actions.push(
+ createFetchCookiecutterAction({
+ reader,
+ integrations,
+ containerRunner,
+ }),
+ );
+ }
+
+ return actions;
};
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts
new file mode 100644
index 0000000000..2ac369249b
--- /dev/null
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { createTemplateAction } from '../../createTemplateAction';
+import { readFile } from 'fs-extra';
+import { Gitlab } from '@gitbeaker/node';
+import globby from 'globby';
+import { Types } from '@gitbeaker/core';
+
+import { ScmIntegrationRegistry } from '@backstage/integration';
+import { InputError } from '@backstage/errors';
+import { parseRepoUrl } from './util';
+import { resolveSafeChildPath } from '@backstage/backend-common';
+
+export type GitlabMergeRequestActionInput = {
+ projectid: string;
+ repoUrl: string;
+ title: string;
+ description: string;
+ branchName: string;
+ targetPath: string;
+};
+
+export const createPublishGitlabMergeRequestAction = (options: {
+ integrations: ScmIntegrationRegistry;
+}) => {
+ const { integrations } = options;
+
+ return createTemplateAction({
+ id: 'publish:gitlab:merge-request',
+ schema: {
+ input: {
+ required: ['projectid', 'repoUrl', 'targetPath', 'branchName'],
+ type: 'object',
+ properties: {
+ repoUrl: {
+ type: 'string',
+ title: 'Repository Location',
+ description: `Accepts the format 'gitlab.com/group_name/project_name' where 'project_name' is the repository name and 'group_name' is a group or username`,
+ },
+ projectid: {
+ type: 'string',
+ title: 'projectid',
+ description: 'Project ID/Name(slug) of the Gitlab Project',
+ },
+ title: {
+ type: 'string',
+ title: 'Merge Request Name',
+ description: 'The name for the merge request',
+ },
+ description: {
+ type: 'string',
+ title: 'Merge Request Description',
+ description: 'The description of the merge request',
+ },
+ branchName: {
+ type: 'string',
+ title: 'Destination Branch name',
+ description: 'The description of the merge request',
+ },
+ targetPath: {
+ type: 'string',
+ title: 'Repository Subdirectory',
+ description: 'Subdirectory of repository to apply changes to',
+ },
+ },
+ },
+ output: {
+ type: 'object',
+ properties: {
+ projectid: {
+ title: 'Gitlab Project id/Name(slug)',
+ type: 'string',
+ },
+ mergeRequestURL: {
+ title: 'MergeRequest(MR) URL',
+ type: 'string',
+ description: 'Link to the merge request in GitLab',
+ },
+ },
+ },
+ },
+ async handler(ctx) {
+ const repoUrl = ctx.input.repoUrl;
+ const { host } = parseRepoUrl(repoUrl, integrations);
+ const integrationConfig = integrations.gitlab.byHost(host);
+
+ const actions: Types.CommitAction[] = [];
+
+ const destinationBranch = ctx.input.branchName;
+
+ if (!integrationConfig) {
+ throw new InputError(
+ `No matching integration configuration for host ${host}, please check your integrations config`,
+ );
+ }
+
+ if (!integrationConfig.config.token) {
+ throw new InputError(`No token available for host ${host}`);
+ }
+
+ const api = new Gitlab({
+ host: integrationConfig.config.baseUrl,
+ token: integrationConfig.config.token,
+ });
+
+ const fileRoot = ctx.workspacePath;
+ const localFilePaths = await globby([`${ctx.input.targetPath}/**`], {
+ cwd: fileRoot,
+ gitignore: true,
+ dot: true,
+ });
+
+ const fileContents = await Promise.all(
+ localFilePaths.map(p => readFile(resolveSafeChildPath(fileRoot, p))),
+ );
+
+ const repoFilePaths = localFilePaths.map(repoFilePath => {
+ return repoFilePath;
+ });
+
+ for (let i = 0; i < repoFilePaths.length; i++) {
+ actions.push({
+ action: 'create',
+ filePath: repoFilePaths[i],
+ content: fileContents[i].toString(),
+ });
+ }
+
+ const projects = await api.Projects.show(ctx.input.projectid);
+
+ const { default_branch: defaultBranch } = projects;
+
+ try {
+ await api.Branches.create(
+ ctx.input.projectid,
+ destinationBranch,
+ String(defaultBranch),
+ );
+ } catch (e) {
+ throw new InputError(`The branch creation failed ${e}`);
+ }
+
+ try {
+ await api.Commits.create(
+ ctx.input.projectid,
+ destinationBranch,
+ ctx.input.title,
+ actions,
+ );
+ } catch (e) {
+ throw new InputError(
+ `Committing the changes to ${destinationBranch} failed ${e}`,
+ );
+ }
+
+ try {
+ const mergeRequestUrl = await api.MergeRequests.create(
+ ctx.input.projectid,
+ destinationBranch,
+ String(defaultBranch),
+ ctx.input.title,
+ { description: ctx.input.description },
+ ).then((mergeRequest: { web_url: string }) => {
+ return mergeRequest.web_url;
+ });
+ ctx.output('projectid', ctx.input.projectid);
+ ctx.output('mergeRequestUrl', mergeRequestUrl);
+ } catch (e) {
+ throw new InputError(`Merge request creation failed${e}`);
+ }
+ },
+ });
+};
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts
index a292438d3a..c42b04e55e 100644
--- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts
@@ -20,3 +20,4 @@ export { createPublishFileAction } from './file';
export { createPublishGithubAction } from './github';
export { createPublishGithubPullRequestAction } from './githubPullRequest';
export { createPublishGitlabAction } from './gitlab';
+export { createPublishGitlabMergeRequestAction } from './gitlabMergeRequest';
diff --git a/plugins/scaffolder-backend/src/service/router.ts b/plugins/scaffolder-backend/src/service/router.ts
index b8f2968287..9d26857ab9 100644
--- a/plugins/scaffolder-backend/src/service/router.ts
+++ b/plugins/scaffolder-backend/src/service/router.ts
@@ -55,7 +55,7 @@ export interface RouterOptions {
catalogClient: CatalogApi;
actions?: TemplateAction[];
taskWorkers?: number;
- containerRunner: ContainerRunner;
+ containerRunner?: ContainerRunner;
taskBroker?: TaskBroker;
}
diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md
index 73fd8fae72..45419e82eb 100644
--- a/plugins/scaffolder/api-report.md
+++ b/plugins/scaffolder/api-report.md
@@ -96,6 +96,24 @@ export type FieldExtensionOptions = {
validation?: CustomFieldValidator;
};
+// Warning: (ae-missing-release-tag) "OwnedEntityPicker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const OwnedEntityPicker: ({
+ onChange,
+ schema: { title, description },
+ required,
+ uiSchema,
+ rawErrors,
+ formData,
+ idSchema,
+}: FieldProps) => JSX.Element;
+
+// Warning: (ae-missing-release-tag) "OwnedEntityPickerFieldExtension" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const OwnedEntityPickerFieldExtension: () => null;
+
// Warning: (ae-missing-release-tag) "OwnerPicker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
diff --git a/plugins/scaffolder/package.json b/plugins/scaffolder/package.json
index e3aaa722b0..3d42126624 100644
--- a/plugins/scaffolder/package.json
+++ b/plugins/scaffolder/package.json
@@ -34,8 +34,8 @@
"@backstage/catalog-client": "^0.5.2",
"@backstage/catalog-model": "^0.9.7",
"@backstage/config": "^0.1.11",
- "@backstage/core-components": "^0.8.0",
- "@backstage/core-plugin-api": "^0.3.0",
+ "@backstage/core-components": "^0.8.1",
+ "@backstage/core-plugin-api": "^0.3.1",
"@backstage/errors": "^0.1.5",
"@backstage/integration": "^0.6.10",
"@backstage/integration-react": "^0.1.15",
@@ -66,10 +66,10 @@
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
- "@backstage/plugin-catalog": "^0.7.4",
- "@backstage/cli": "^0.10.1",
- "@backstage/core-app-api": "^0.2.0",
+ "@backstage/cli": "^0.10.2",
+ "@backstage/core-app-api": "^0.2.1",
"@backstage/dev-utils": "^0.2.14",
+ "@backstage/plugin-catalog": "^0.7.4",
"@backstage/test-utils": "^0.1.24",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^11.2.5",
diff --git a/plugins/scaffolder/src/components/fields/EntityPicker/EntityPicker.tsx b/plugins/scaffolder/src/components/fields/EntityPicker/EntityPicker.tsx
index a8ef524a13..452a5d97b1 100644
--- a/plugins/scaffolder/src/components/fields/EntityPicker/EntityPicker.tsx
+++ b/plugins/scaffolder/src/components/fields/EntityPicker/EntityPicker.tsx
@@ -22,7 +22,7 @@ import { TextField } from '@material-ui/core';
import FormControl from '@material-ui/core/FormControl';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { FieldProps } from '@rjsf/core';
-import React from 'react';
+import React, { useCallback, useEffect } from 'react';
import { useAsync } from 'react-use';
export const EntityPicker = ({
@@ -48,9 +48,18 @@ export const EntityPicker = ({
formatEntityRefTitle(e, { defaultKind }),
);
- const onSelect = (_: any, value: string | null) => {
- onChange(value || '');
- };
+ const onSelect = useCallback(
+ (_: any, value: string | null) => {
+ onChange(value || '');
+ },
+ [onChange],
+ );
+
+ useEffect(() => {
+ if (entityRefs?.length === 1) {
+ onChange(entityRefs[0]);
+ }
+ }, [entityRefs, onChange]);
return (
0 && !formData}
>
) => {
+ const allowedKinds = uiSchema['ui:options']?.allowedKinds as string[];
+ const defaultKind = uiSchema['ui:options']?.defaultKind as string | undefined;
+ const { ownedEntities, loading } = useOwnedEntities(allowedKinds);
+
+ const entityRefs = ownedEntities?.items
+ .map(e => formatEntityRefTitle(e, { defaultKind }))
+ .filter(n => n);
+
+ const onSelect = (_: any, value: string | null) => {
+ onChange(value || '');
+ };
+
+ return (
+ 0 && !formData}
+ >
+ (
+
+ )}
+ />
+
+ );
+};
diff --git a/plugins/scaffolder/src/components/fields/OwnedEntityPicker/index.ts b/plugins/scaffolder/src/components/fields/OwnedEntityPicker/index.ts
new file mode 100644
index 0000000000..7cf5add6eb
--- /dev/null
+++ b/plugins/scaffolder/src/components/fields/OwnedEntityPicker/index.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export { OwnedEntityPicker } from './OwnedEntityPicker';
diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx
index c4b1e79262..92261b6cac 100644
--- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx
+++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx
@@ -13,19 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React, { useCallback, useEffect } from 'react';
-import { FieldProps } from '@rjsf/core';
-import { scaffolderApiRef } from '../../../api';
+import {
+ Progress,
+ Select,
+ SelectedItems,
+ SelectItem,
+} from '@backstage/core-components';
+import { useApi } from '@backstage/core-plugin-api';
import { scmIntegrationsApiRef } from '@backstage/integration-react';
-import { useAsync } from 'react-use';
-import Select from '@material-ui/core/Select';
-import InputLabel from '@material-ui/core/InputLabel';
-import Input from '@material-ui/core/Input';
import FormControl from '@material-ui/core/FormControl';
import FormHelperText from '@material-ui/core/FormHelperText';
-
-import { useApi } from '@backstage/core-plugin-api';
-import { Progress } from '@backstage/core-components';
+import Input from '@material-ui/core/Input';
+import InputLabel from '@material-ui/core/InputLabel';
+import { FieldProps } from '@rjsf/core';
+import React, { useCallback, useEffect } from 'react';
+import { useAsync } from 'react-use';
+import { scaffolderApiRef } from '../../../api';
function splitFormData(url: string | undefined, allowedOwners?: string[]) {
let host = undefined;
@@ -106,10 +109,10 @@ export const RepoUrlPicker = ({
allowedOwners,
);
const updateHost = useCallback(
- (evt: React.ChangeEvent<{ name?: string; value: unknown }>) => {
+ (value: SelectedItems) => {
onChange(
serializeFormData({
- host: evt.target.value as string,
+ host: value as string,
owner,
repo,
organization,
@@ -121,6 +124,21 @@ export const RepoUrlPicker = ({
[onChange, owner, repo, organization, workspace, project],
);
+ const updateOwnerSelect = useCallback(
+ (value: SelectedItems) =>
+ onChange(
+ serializeFormData({
+ host,
+ owner: value as string,
+ repo,
+ organization,
+ workspace,
+ project,
+ }),
+ ),
+ [onChange, host, repo, organization, workspace, project],
+ );
+
const updateOwner = useCallback(
(evt: React.ChangeEvent<{ name?: string; value: unknown }>) =>
onChange(
@@ -224,6 +242,16 @@ export const RepoUrlPicker = ({
return ;
}
+ const hostsOptions: SelectItem[] = integrations
+ ? integrations
+ .filter(i => allowedHosts?.includes(i.host))
+ .map(i => ({ label: i.title, value: i.host }))
+ : [{ label: 'Loading...', value: 'loading' }];
+
+ const ownersOptions: SelectItem[] = allowedOwners
+ ? allowedOwners.map(i => ({ label: i, value: i }))
+ : [{ label: 'Loading...', value: 'loading' }];
+
return (
<>
0 && !host}
>
- Host
-
+
+
The host where the repository will be created
@@ -330,24 +353,15 @@ export const RepoUrlPicker = ({
required
error={rawErrors?.length > 0 && !owner}
>
- Owner Available
+ label="Owner Available"
+ onChange={updateOwnerSelect}
+ disabled={ownersOptions.length === 1}
+ selected={owner}
+ items={ownersOptions}
+ />
+
The organization, user or project that this repo will belong to
diff --git a/plugins/scaffolder/src/components/fields/index.ts b/plugins/scaffolder/src/components/fields/index.ts
index 5adc3d3141..299470e220 100644
--- a/plugins/scaffolder/src/components/fields/index.ts
+++ b/plugins/scaffolder/src/components/fields/index.ts
@@ -18,3 +18,4 @@ export * from './EntityPicker';
export * from './OwnerPicker';
export * from './RepoUrlPicker';
export * from './TextValuePicker';
+export * from './OwnedEntityPicker';
diff --git a/plugins/scaffolder/src/extensions/default.ts b/plugins/scaffolder/src/extensions/default.ts
index be934546b3..12a29809e0 100644
--- a/plugins/scaffolder/src/extensions/default.ts
+++ b/plugins/scaffolder/src/extensions/default.ts
@@ -24,6 +24,7 @@ import {
RepoUrlPicker,
} from '../components/fields/RepoUrlPicker';
import { FieldExtensionOptions } from './types';
+import { OwnedEntityPicker } from '../components/fields/OwnedEntityPicker';
export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS: FieldExtensionOptions[] = [
{
@@ -44,4 +45,8 @@ export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS: FieldExtensionOptions[] = [
component: OwnerPicker,
name: 'OwnerPicker',
},
+ {
+ component: OwnedEntityPicker,
+ name: 'OwnedEntityPicker',
+ },
];
diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts
index 0180c24b90..dfbd2af296 100644
--- a/plugins/scaffolder/src/index.ts
+++ b/plugins/scaffolder/src/index.ts
@@ -31,6 +31,7 @@ export {
EntityPickerFieldExtension,
EntityNamePickerFieldExtension,
OwnerPickerFieldExtension,
+ OwnedEntityPickerFieldExtension,
RepoUrlPickerFieldExtension,
ScaffolderPage,
scaffolderPlugin as plugin,
@@ -42,6 +43,7 @@ export {
OwnerPicker,
RepoUrlPicker,
TextValuePicker,
+ OwnedEntityPicker,
} from './components/fields';
export { FavouriteTemplate } from './components/FavouriteTemplate';
export { TemplateList } from './components/TemplateList';
diff --git a/plugins/scaffolder/src/plugin.ts b/plugins/scaffolder/src/plugin.ts
index b6ef0ebe17..95cad50eba 100644
--- a/plugins/scaffolder/src/plugin.ts
+++ b/plugins/scaffolder/src/plugin.ts
@@ -35,6 +35,7 @@ import {
discoveryApiRef,
identityApiRef,
} from '@backstage/core-plugin-api';
+import { OwnedEntityPicker } from './components/fields/OwnedEntityPicker';
export const scaffolderPlugin = createPlugin({
id: 'scaffolder',
@@ -95,3 +96,10 @@ export const ScaffolderPage = scaffolderPlugin.provide(
mountPoint: rootRouteRef,
}),
);
+
+export const OwnedEntityPickerFieldExtension = scaffolderPlugin.provide(
+ createScaffolderFieldExtension({
+ component: OwnedEntityPicker,
+ name: 'OwnedEntityPicker',
+ }),
+);
diff --git a/plugins/search-backend-module-elasticsearch/CHANGELOG.md b/plugins/search-backend-module-elasticsearch/CHANGELOG.md
index f36078c503..52ca5efaff 100644
--- a/plugins/search-backend-module-elasticsearch/CHANGELOG.md
+++ b/plugins/search-backend-module-elasticsearch/CHANGELOG.md
@@ -1,5 +1,12 @@
# @backstage/plugin-search-backend-module-elasticsearch
+## 0.0.7
+
+### Patch Changes
+
+- 68512f5178: Add `newClient()` method to re-use the configuration of the elastic search
+ engine with custom clients
+
## 0.0.6
### Patch Changes
diff --git a/plugins/search-backend-module-elasticsearch/api-report.md b/plugins/search-backend-module-elasticsearch/api-report.md
index 1e798119c3..6dc0256586 100644
--- a/plugins/search-backend-module-elasticsearch/api-report.md
+++ b/plugins/search-backend-module-elasticsearch/api-report.md
@@ -3,18 +3,103 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
-import { Client } from '@elastic/elasticsearch';
+///
+
import { Config } from '@backstage/config';
+import type { ConnectionOptions } from 'tls';
import { IndexableDocument } from '@backstage/search-common';
import { Logger as Logger_2 } from 'winston';
import { SearchEngine } from '@backstage/search-common';
import { SearchQuery } from '@backstage/search-common';
import { SearchResultSet } from '@backstage/search-common';
+// Warning: (ae-missing-release-tag) "ElasticSearchClientOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-search-backend-module-elasticsearch" does not have an export "ElasticSearchEngine"
+//
+// @public
+export interface ElasticSearchClientOptions {
+ // Warning: (ae-forgotten-export) The symbol "ElasticSearchAgentOptions" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ agent?: ElasticSearchAgentOptions | ((opts?: any) => unknown) | false;
+ // Warning: (ae-forgotten-export) The symbol "ElasticSearchAuth" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ auth?: ElasticSearchAuth;
+ // (undocumented)
+ cloud?: {
+ id: string;
+ username?: string;
+ password?: string;
+ };
+ // (undocumented)
+ compression?: 'gzip';
+ // Warning: (ae-forgotten-export) The symbol "ElasticSearchConnectionConstructor" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ Connection?: ElasticSearchConnectionConstructor;
+ // (undocumented)
+ disablePrototypePoisoningProtection?: boolean | 'proto' | 'constructor';
+ // (undocumented)
+ enableMetaHeader?: boolean;
+ // (undocumented)
+ headers?: Record;
+ // (undocumented)
+ maxRetries?: number;
+ // (undocumented)
+ name?: string | symbol;
+ // Warning: (ae-forgotten-export) The symbol "ElasticSearchNodeOptions" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ node?:
+ | string
+ | string[]
+ | ElasticSearchNodeOptions
+ | ElasticSearchNodeOptions[];
+ // (undocumented)
+ nodeFilter?: (connection: any) => boolean;
+ // (undocumented)
+ nodes?:
+ | string
+ | string[]
+ | ElasticSearchNodeOptions
+ | ElasticSearchNodeOptions[];
+ // (undocumented)
+ nodeSelector?: ((connections: any[]) => any) | string;
+ // (undocumented)
+ opaqueIdPrefix?: string;
+ // (undocumented)
+ pingTimeout?: number;
+ // (undocumented)
+ provider?: 'aws' | 'elastic';
+ // (undocumented)
+ proxy?: string | URL;
+ // (undocumented)
+ requestTimeout?: number;
+ // (undocumented)
+ resurrectStrategy?: 'ping' | 'optimistic' | 'none';
+ // (undocumented)
+ sniffEndpoint?: string;
+ // (undocumented)
+ sniffInterval?: number | boolean;
+ // (undocumented)
+ sniffOnConnectionFault?: boolean;
+ // (undocumented)
+ sniffOnStart?: boolean;
+ // (undocumented)
+ ssl?: ConnectionOptions;
+ // (undocumented)
+ suggestCompression?: boolean;
+ // Warning: (ae-forgotten-export) The symbol "ElasticSearchTransportConstructor" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ Transport?: ElasticSearchTransportConstructor;
+}
+
// @public (undocumented)
export class ElasticSearchSearchEngine implements SearchEngine {
constructor(
- elasticSearchClient: Client,
+ elasticSearchClientOptions: ElasticSearchClientOptions,
aliasPostfix: string,
indexPrefix: string,
logger: Logger_2,
@@ -22,11 +107,15 @@ export class ElasticSearchSearchEngine implements SearchEngine {
// Warning: (ae-forgotten-export) The symbol "ElasticSearchOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
- static fromConfig(
- options: ElasticSearchOptions,
- ): Promise;
+ static fromConfig({
+ logger,
+ config,
+ aliasPostfix,
+ indexPrefix,
+ }: ElasticSearchOptions): Promise