diff --git a/.changeset/cold-pets-retire.md b/.changeset/cold-pets-retire.md
new file mode 100644
index 0000000000..1ab64f919e
--- /dev/null
+++ b/.changeset/cold-pets-retire.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-scaffolder': patch
+---
+
+Remove beta labels
diff --git a/.changeset/fuzzy-swans-remain.md b/.changeset/fuzzy-swans-remain.md
new file mode 100644
index 0000000000..0446470307
--- /dev/null
+++ b/.changeset/fuzzy-swans-remain.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-scaffolder-backend': patch
+---
+
+Added new `github:issues:label` action to apply labels to issues, and also output `pullRequestNumber` from `publish:github:pull-request`.
diff --git a/.changeset/healthy-lions-sin.md b/.changeset/healthy-lions-sin.md
new file mode 100644
index 0000000000..632b87067c
--- /dev/null
+++ b/.changeset/healthy-lions-sin.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-scaffolder': patch
+---
+
+The `ScaffolderPage` now uses the `CatalogFilterLayout`, which means the filters are put in a drawer on smaller screens.
diff --git a/.changeset/lucky-scissors-play.md b/.changeset/lucky-scissors-play.md
new file mode 100644
index 0000000000..dca966d515
--- /dev/null
+++ b/.changeset/lucky-scissors-play.md
@@ -0,0 +1,9 @@
+---
+'@backstage/plugin-catalog': patch
+---
+
+**DEPRECATION**: The `FilteredEntityLayout` and related components have been moved to `@backstage/plugin-catalog-react` and renamed. The original components are now deprecated and should be replaced as follows:
+
+- `FilteredEntityLayout` -> `CatalogFilterLayout`
+- `FilterContainer` -> `CatalogFilterLayout.Filters`
+- `EntityListContainer` -> `CatalogFilterLayout.Content`
diff --git a/.changeset/nasty-chefs-dream.md b/.changeset/nasty-chefs-dream.md
new file mode 100644
index 0000000000..198f280fcc
--- /dev/null
+++ b/.changeset/nasty-chefs-dream.md
@@ -0,0 +1,16 @@
+---
+'@backstage/plugin-catalog-react': patch
+---
+
+Added `CatalogFilterLayout`, which replaces `FilteredEntityLayout` from `@backstage/plugin-catalog`, as well as `FilterContainer` and `EntityListContainer`. It is used like this:
+
+```tsx
+
+
+ {/* filter drawer, for example and friends */}
+
+
+ {/* content view, for example a */}
+
+
+```
diff --git a/.changeset/new-cougars-beam.md b/.changeset/new-cougars-beam.md
new file mode 100644
index 0000000000..c1c03ce848
--- /dev/null
+++ b/.changeset/new-cougars-beam.md
@@ -0,0 +1,30 @@
+---
+'@backstage/plugin-catalog-backend-module-msgraph': minor
+---
+
+**BREAKING**: `MicrosoftGraphOrgEntityProvider.fromConfig` now requires a `schedule` field in its options, which simplifies scheduling. If you want to retain the old behavior of calling its `run()` method manually, you can set the new field value to the string `'manual'`. But you may prefer to instead give it a scheduled task runner from the backend tasks package:
+
+```diff
+ // packages/backend/src/plugins/catalog.ts
++import { Duration } from 'luxon';
++import { MicrosoftGraphOrgEntityProvider } from '@backstage/plugin-catalog-backend-module-msgraph';
+
+ export default async function createPlugin(
+ env: PluginEnvironment,
+ ): Promise {
+ const builder = await CatalogBuilder.create(env);
+
++ // The target parameter below needs to match one of the providers' target
++ // value specified in your app-config.
++ builder.addEntityProvider(
++ MicrosoftGraphOrgEntityProvider.fromConfig(env.config, {
++ id: 'production',
++ target: 'https://graph.microsoft.com/v1.0',
++ logger: env.logger,
++ schedule: env.scheduler.createScheduledTaskRunner({
++ frequency: Duration.fromObject({ minutes: 5 }),
++ timeout: Duration.fromObject({ minutes: 3 }),
++ }),
++ }),
++ );
+```
diff --git a/.changeset/nice-seals-decide.md b/.changeset/nice-seals-decide.md
new file mode 100644
index 0000000000..999b2db6a5
--- /dev/null
+++ b/.changeset/nice-seals-decide.md
@@ -0,0 +1,6 @@
+---
+'@backstage/plugin-api-docs': patch
+'@backstage/plugin-techdocs': patch
+---
+
+Switched to using `CatalogFilterLayout` from `@backstage/plugin-catalog-react`.
diff --git a/.changeset/quiet-dots-raise.md b/.changeset/quiet-dots-raise.md
new file mode 100644
index 0000000000..237cf47c81
--- /dev/null
+++ b/.changeset/quiet-dots-raise.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-badges': patch
+---
+
+Fixed an error caused by the `EntityBadgesDialog` trying to access the entity before it is loaded.
diff --git a/.changeset/shy-seals-deny.md b/.changeset/shy-seals-deny.md
new file mode 100644
index 0000000000..1687ccaa75
--- /dev/null
+++ b/.changeset/shy-seals-deny.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-catalog': patch
+---
+
+Fix for `EntitySwitch` not properly falling back to render the default entity page when the entity is missing.
diff --git a/.changeset/wild-sheep-mate.md b/.changeset/wild-sheep-mate.md
new file mode 100644
index 0000000000..f105a68cb2
--- /dev/null
+++ b/.changeset/wild-sheep-mate.md
@@ -0,0 +1,7 @@
+---
+'@backstage/plugin-catalog-backend': patch
+'@backstage/plugin-catalog-backend-module-github': patch
+'@backstage/plugin-catalog-backend-module-ldap': patch
+---
+
+Made sure to move the catalog-related github and ldap config into their right places
diff --git a/.github/styles/vocab.txt b/.github/styles/vocab.txt
index b8e432dd98..9e57785b3e 100644
--- a/.github/styles/vocab.txt
+++ b/.github/styles/vocab.txt
@@ -27,6 +27,7 @@ Billett
bitbucket
Bitrise
Blackbox
+Brex
bool
boolean
builtins
@@ -151,6 +152,7 @@ Leasot
lerna
Lerna
LocalStack
+lockdown
lockfile
lunr
Luxon
@@ -268,6 +270,7 @@ seb
semlas
semver
Serverless
+shoutout
siloed
Sinon
Snyk
diff --git a/docs/features/software-catalog/catalog-customization.md b/docs/features/software-catalog/catalog-customization.md
index 80c9458aee..1b5535a464 100644
--- a/docs/features/software-catalog/catalog-customization.md
+++ b/docs/features/software-catalog/catalog-customization.md
@@ -41,16 +41,16 @@ export const CustomCatalogPage = ({
All your software catalog entities
-
-
+
+
-
-
+
+
-
-
+
+
@@ -151,18 +151,18 @@ export const CustomCatalogPage = ({
return (
...
-
-
+
+
+
-
-
+
+
-
-
+
+
...
};
diff --git a/docs/features/software-catalog/index.md b/docs/features/software-catalog/index.md
index f5296f38e1..0326292e41 100644
--- a/docs/features/software-catalog/index.md
+++ b/docs/features/software-catalog/index.md
@@ -1,6 +1,6 @@
---
id: software-catalog-overview
-title: Backstage Software Catalog (alpha)
+title: Backstage Software Catalog
sidebar_label: Overview
# prettier-ignore
description: The Backstage Software Catalog
diff --git a/microsite/blog/2022-03-16-backstage-turns-two.md b/microsite/blog/2022-03-16-backstage-turns-two.md
new file mode 100644
index 0000000000..172fb7b971
--- /dev/null
+++ b/microsite/blog/2022-03-16-backstage-turns-two.md
@@ -0,0 +1,68 @@
+---
+title: Backstage Turns Two!
+author: Lee Mills, Spotify
+authorURL: https://github.com/leemills83
+authorImageURL: https://avatars1.githubusercontent.com/u/1236238?s=460&v=4
+---
+
+
+
+**TLDR:** Backstage has turned two. Of course, this is software, so we expect things to move fast. But when you have a passionate, worldwide community building together, we’ve now seen firsthand just how fast that can be. We’re marking our second year as a community by becoming a CNCF incubating project, reaching 100 public adopters, releasing version 1.0 of the core app, and other very nice birthday gifts. Rather than a toddler finding their feet, Backstage today is beginning to look awfully grown-up for a two-year-old.
+
+
+
+## Out of the Sandbox and into Incubation
+
+Two years ago, a small team at Spotify launched Backstage into open source during our internal Hack Week. We knew we had something special on our hands and that Backstage could potentially be the most ambitious open source project in Spotify’s history (you can listen to me wax philosophical on this topic more in [Episode 2 of the new NerdOut@Spotify podcast](https://open.spotify.com/episode/332yTwGiILGKTS7dsHCj2P?si=pX9xTzB2SgmsROdlLLr24A).)
+
+When Spotify donated the project to the CNCF, we saw it as the first promising step toward making Backstage an industry standard. As the home to Kubernetes, Envoy, and so many other game-changing open technologies, the CNCF and its community has had a wide-ranging impact on the daily lives of developers everywhere. And that’s what we hoped for Backstage, even back then.
+
+But we couldn't have envisioned where we’d be two years later — part of an ever-growing community of people that feel as passionate as we do about unlocking better developer experience for every engineering organization.
+
+Yesterday, the CNCF announced that its [Technical Oversight Committee](https://github.com/cncf/toc) (TOC) voted to accept Backstage as a [CNCF incubating project](https://www.cncf.io/blog/2022/03/15/backstage-project-joins-the-cncf-incubator/). The move from the CNCF Sandbox to Incubation is an important step forward for the project’s technical governance.
+
+It’s also recognition for all the work the Backstage open source community has done to advance and grow this project since we launched the repo on GitHub just a few weeks after that Hack Week. We still have a long way to go to becoming the standard, but moving out of the CNCF Sandbox and beginning the Incubation phase is further validation of those aspirations.
+
+## What do retailers, gaming studios, banks, airlines, streamers, startups, and enterprise software makers all have in common?
+
+Developers, developers, developers — that’s what all companies have in common. Developers dealing with [more complexity](https://youtu.be/85TQEpNCaU0) than they’ve ever had to deal with before. Developers who want to be able to go from idea to bug fix or feature faster.
+
+Two years in, the Backstage ecosystem has grown by leaps and bounds. More than 5,000 contributors have joined the project and are submitting bugs, adding new features, and building valuable plugins that benefit the greater community. From [Expedia Group](https://backstage.spotify.com/blog/measuring-backstage-proof-of-value-at-expedia/) (adopter No.18) to Unity (adopter No.67), Backstage now has [100 publicly listed adopters](https://github.com/backstage/backstage/blob/master/ADOPTERS.md) across a variety of industries, including retail, gaming, financial services, manufacturing, and government.
+
+We have companies like [Roadie](http://roadie.io) providing hosting solutions and ThoughtWorks [providing technology and consulting services](https://www.thoughtworks.com/en-us/about-us/news/2021/thoughtworks-is-collaborating-with-spotify-to-deliver-better-dev) to teams looking to stand up Backstage in their own orgs. We’re starting to see more and more job listings for Backstage developers which tells us that companies of all shapes and sizes are going all-in on Backstage and developer effectiveness.
+
+Also, I’ll pause now to give a special shoutout to our early adopters. They stuck with us through all the bumps and breaking changes. But because of their early commitment, we now see instances of Backstage up and running in so many different kinds of engineering organizations. From [Zalando](https://youtu.be/6sg5uMCLxTA) to [American Airlines](https://backstage.spotify.com/blog/adopter-spotlight/american-airlines-runway/) and [Brex](https://backstage.spotify.com/blog/community-session/11-brex-backstage-upgrade-helper/), the growing pains of our earliest adopters helped pave the way for smoother adoptions for all who follow them.
+
+A few more numbers that make us proud:
+
+- 2,000+ project forks
+- 20,000+ commits
+- 10,000+ PRs & issues
+- 15,000+ stars on GitHub
+- 60+ open source plugins in the [Backstage Plugin Marketplace](https://backstage.io/plugins)
+
+## A global community of friendly, helpful contributors
+
+We open sourced Backstage in March 2020 and then almost immediately went into lockdown. When you think about this project in the context of the pandemic, it's really remarkable how much this community has been able to achieve.
+
+The Backstage community is truly global with adopters and contributors from almost every continent (sorry, Antarctica!) coming together to share what they’ve worked on and demo cool stuff in our monthly Community Sessions. The repo and the Discord server truly never sleep as a growing group of dedicated Backstage experts outside Spotify support one another and offer help 24/7.
+
+We asked a few contributors and maintainers to share their thoughts around this two-year milestone.
+
+
+
+Warms the heart, doesn’t it? Thanks again to all our contributors for making this possible. Seriously. We’re proud of what the community has accomplished and how we’ve accomplished it. All along, it’s your enthusiasm and warm/collaborative/positive vibes that have carried us and this project through.
+
+## Version 1.0 and beyond
+
+Tomorrow, we’ll be releasing version 1.0 of the Backstage core framework, including Software Catalog, Software Templates, TechDocs, and API Reference. With Backstage 1.0, the project’s core components are coming out of beta and into production with regular versioning and release cycle commitments (check back on this blog for more details!).
+
+v1.0 paves the way for more adoption, a bigger community, more contributions — and with this continued growth in the ecosystem, we expect even greater innovation on the platform just on the horizon with exchange of features and plugins.
+
+What comes next for Backstage is — in many ways — entirely up to you. We are looking to this community to [help us shape the next year](https://backstage.io/docs/overview/roadmap).
+
+If you’re already a part of this community, thank you for your hard work and dedication. Backstage wouldn’t be where it is today without you. We’ve come a long way together, but there’s still so much to do.
+
+And if you haven’t signed up yet, there’s plenty of room on this party boat! And there’s never been a better time to hop on board. As Irma ([@Irma12](https://github.com/Irma12)) said so beautifully: where else is there an opportunity to have so many people look at your code, hear you out, and help you out?
+
+Take a look at how to [start contributing](https://github.com/backstage/backstage/blob/master/CONTRIBUTING.md) and [join the community](https://github.com/backstage/community)!
diff --git a/microsite/blog/assets/22-03-16/backstage-2nd-birthday.gif b/microsite/blog/assets/22-03-16/backstage-2nd-birthday.gif
new file mode 100644
index 0000000000..bb830efa2a
Binary files /dev/null and b/microsite/blog/assets/22-03-16/backstage-2nd-birthday.gif differ
diff --git a/microsite/pages/en/index.js b/microsite/pages/en/index.js
index 3804c45478..2f7c030c2a 100644
--- a/microsite/pages/en/index.js
+++ b/microsite/pages/en/index.js
@@ -109,15 +109,7 @@ class Index extends React.Component {
className="Block__GIF"
src={`${baseUrl}animations/backstage-software-catalog-icon-1.gif`}
/>
-
- Backstage Software Catalog{' '}
-
- (alpha)
-
-
+ Backstage Software Catalog
Build an ecosystem, not a wilderness
@@ -200,7 +192,7 @@ class Index extends React.Component {
Learn more about the software catalog
Read
@@ -213,15 +205,7 @@ class Index extends React.Component {
className="Block__GIF"
src={`${baseUrl}animations/backstage-software-templates-icon-5.gif`}
/>
-
- Backstage Software Templates{' '}
-
- (beta)
-
-
+ Backstage Software TemplatesStandards can set you free
-
- Backstage TechDocs{' '}
-
- (beta)
-
-
+ Backstage TechDocsDocs like code
-
+ boolean}>
@@ -191,7 +192,7 @@ export const cicdContent = (
-
+ boolean}>
@@ -234,7 +235,7 @@ const cicdCard = (
-
+ boolean}>
@@ -326,7 +327,9 @@ const overviewContent = (
{cicdCard}
- Boolean(isGithubInsightsAvailable(e))}>
+ boolean}
+ >
@@ -346,7 +349,9 @@ const overviewContent = (
- Boolean(isGithubPullRequestsAvailable(e))}>
+ boolean}
+ >
diff --git a/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx b/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx
index d38383f004..9fc6b2c3c2 100644
--- a/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx
+++ b/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx
@@ -24,13 +24,7 @@ import {
TableProps,
} from '@backstage/core-components';
import { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';
-import {
- CatalogTable,
- CatalogTableRow,
- FilteredEntityLayout,
- EntityListContainer,
- FilterContainer,
-} from '@backstage/plugin-catalog';
+import { CatalogTable, CatalogTableRow } from '@backstage/plugin-catalog';
import {
EntityKindPicker,
EntityLifecyclePicker,
@@ -40,6 +34,7 @@ import {
EntityTypePicker,
UserListFilterKind,
UserListPicker,
+ CatalogFilterLayout,
} from '@backstage/plugin-catalog-react';
import React from 'react';
import { registerComponentRouteRef } from '../../routes';
@@ -95,22 +90,22 @@ export const DefaultApiExplorerPage = ({
All your APIs
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/plugins/badges/src/components/EntityBadgesDialog.tsx b/plugins/badges/src/components/EntityBadgesDialog.tsx
index 1ae5f69326..422dbc96a3 100644
--- a/plugins/badges/src/components/EntityBadgesDialog.tsx
+++ b/plugins/badges/src/components/EntityBadgesDialog.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { useEntity } from '@backstage/plugin-catalog-react';
+import { useAsyncEntity } from '@backstage/plugin-catalog-react';
import {
Box,
Button,
@@ -44,7 +44,7 @@ type Props = {
export const EntityBadgesDialog = ({ open, onClose }: Props) => {
const theme = useTheme();
- const { entity } = useEntity();
+ const { entity } = useAsyncEntity();
const fullScreen = useMediaQuery(theme.breakpoints.down('sm'));
const badgesApi = useApi(badgesApiRef);
diff --git a/plugins/catalog-backend-module-github/config.d.ts b/plugins/catalog-backend-module-github/config.d.ts
new file mode 100644
index 0000000000..a1702799c2
--- /dev/null
+++ b/plugins/catalog-backend-module-github/config.d.ts
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+export interface Config {
+ catalog?: {
+ processors?: {
+ /**
+ * GithubMultiOrgReaderProcessor configuration
+ */
+ githubMultiOrg?: {
+ /**
+ * The configuration parameters for each GitHub org to process.
+ */
+ orgs: Array<{
+ /**
+ * The name of the GitHub org to process.
+ */
+ name: string;
+ /**
+ * The namespace of the group created for this org.
+ *
+ * Defaults to org name if omitted.
+ */
+ groupNamespace?: string;
+
+ /**
+ * The namespace of the users created from this org.
+ *
+ * Defaults to empty string if omitted.
+ */
+ userNamespace?: string;
+ }>;
+ };
+ };
+ };
+}
diff --git a/plugins/catalog-backend-module-github/package.json b/plugins/catalog-backend-module-github/package.json
index 0e63cf9da2..04bc5b7b07 100644
--- a/plugins/catalog-backend-module-github/package.json
+++ b/plugins/catalog-backend-module-github/package.json
@@ -52,6 +52,8 @@
"@types/lodash": "^4.14.151"
},
"files": [
- "dist"
- ]
+ "dist",
+ "config.d.ts"
+ ],
+ "configSchema": "config.d.ts"
}
diff --git a/plugins/catalog-backend-module-ldap/api-report.md b/plugins/catalog-backend-module-ldap/api-report.md
index edeef4cb82..3c6cd4849b 100644
--- a/plugins/catalog-backend-module-ldap/api-report.md
+++ b/plugins/catalog-backend-module-ldap/api-report.md
@@ -134,7 +134,7 @@ export class LdapOrgReaderProcessor implements CatalogProcessor {
});
// (undocumented)
static fromConfig(
- config: Config,
+ configRoot: Config,
options: {
logger: Logger;
groupTransformer?: GroupTransformer;
diff --git a/plugins/catalog-backend-module-ldap/config.d.ts b/plugins/catalog-backend-module-ldap/config.d.ts
index 2605eb62f3..8ae3145811 100644
--- a/plugins/catalog-backend-module-ldap/config.d.ts
+++ b/plugins/catalog-backend-module-ldap/config.d.ts
@@ -17,8 +17,223 @@
import { JsonValue } from '@backstage/types';
export interface Config {
+ /**
+ * LdapOrgEntityProvider / LdapOrgReaderProcessor configuration
+ */
+ ldap?: {
+ /**
+ * The configuration parameters for each single LDAP provider.
+ */
+ providers: Array<{
+ /**
+ * The prefix of the target that this matches on, e.g.
+ * "ldaps://ds.example.net", with no trailing slash.
+ */
+ target: string;
+
+ /**
+ * The settings to use for the bind command. If none are specified,
+ * the bind command is not issued.
+ */
+ bind?: {
+ /**
+ * The DN of the user to auth as.
+ *
+ * E.g. "uid=ldap-robot,ou=robots,ou=example,dc=example,dc=net"
+ */
+ dn: string;
+ /**
+ * The secret of the user to auth as (its password).
+ *
+ * @visibility secret
+ */
+ secret: string;
+ };
+
+ /**
+ * The settings that govern the reading and interpretation of users.
+ */
+ users: {
+ /**
+ * The DN under which users are stored.
+ *
+ * E.g. "ou=people,ou=example,dc=example,dc=net"
+ */
+ dn: string;
+ /**
+ * The search options to use. The default is scope "one" and
+ * attributes "*" and "+".
+ *
+ * It is common to want to specify a filter, to narrow down the set
+ * of matching items.
+ */
+ options: {
+ scope?: 'base' | 'one' | 'sub';
+ filter?: string;
+ attributes?: string | string[];
+ sizeLimit?: number;
+ timeLimit?: number;
+ derefAliases?: number;
+ typesOnly?: boolean;
+ paged?:
+ | boolean
+ | {
+ pageSize?: number;
+ pagePause?: boolean;
+ };
+ };
+ /**
+ * JSON paths (on a.b.c form) and hard coded values to set on those
+ * paths.
+ *
+ * This can be useful for example if you want to hard code a
+ * namespace or similar on the generated entities.
+ */
+ set?: { [key: string]: JsonValue };
+ /**
+ * Mappings from well known entity fields, to LDAP attribute names
+ */
+ map?: {
+ /**
+ * The name of the attribute that holds the relative
+ * distinguished name of each entry. Defaults to "uid".
+ */
+ rdn?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the metadata.name field of the entity. Defaults to "uid".
+ */
+ name?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the metadata.description field of the entity.
+ */
+ description?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the spec.profile.displayName field of the entity. Defaults to
+ * "cn".
+ */
+ displayName?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the spec.profile.email field of the entity. Defaults to
+ * "mail".
+ */
+ email?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the spec.profile.picture field of the entity.
+ */
+ picture?: string;
+ /**
+ * The name of the attribute that shall be used for the values of
+ * the spec.memberOf field of the entity. Defaults to "memberOf".
+ */
+ memberOf?: string;
+ };
+ };
+
+ /**
+ * The settings that govern the reading and interpretation of groups.
+ */
+ groups: {
+ /**
+ * The DN under which groups are stored.
+ *
+ * E.g. "ou=people,ou=example,dc=example,dc=net"
+ */
+ dn: string;
+ /**
+ * The search options to use. The default is scope "one" and
+ * attributes "*" and "+".
+ *
+ * It is common to want to specify a filter, to narrow down the set
+ * of matching items.
+ */
+ options: {
+ scope?: 'base' | 'one' | 'sub';
+ filter?: string;
+ attributes?: string | string[];
+ sizeLimit?: number;
+ timeLimit?: number;
+ derefAliases?: number;
+ typesOnly?: boolean;
+ paged?:
+ | boolean
+ | {
+ pageSize?: number;
+ pagePause?: boolean;
+ };
+ };
+ /**
+ * JSON paths (on a.b.c form) and hard coded values to set on those
+ * paths.
+ *
+ * This can be useful for example if you want to hard code a
+ * namespace or similar on the generated entities.
+ */
+ set?: { [key: string]: JsonValue };
+ /**
+ * Mappings from well known entity fields, to LDAP attribute names
+ */
+ map?: {
+ /**
+ * The name of the attribute that holds the relative
+ * distinguished name of each entry. Defaults to "cn".
+ */
+ rdn?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the metadata.name field of the entity. Defaults to "cn".
+ */
+ name?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the metadata.description field of the entity. Defaults to
+ * "description".
+ */
+ description?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the spec.type field of the entity. Defaults to "groupType".
+ */
+ type?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the spec.profile.displayName field of the entity. Defaults to
+ * "cn".
+ */
+ displayName?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the spec.profile.email field of the entity.
+ */
+ email?: string;
+ /**
+ * The name of the attribute that shall be used for the value of
+ * the spec.profile.picture field of the entity.
+ */
+ picture?: string;
+ /**
+ * The name of the attribute that shall be used for the values of
+ * the spec.parent field of the entity. Defaults to "memberOf".
+ */
+ memberOf?: string;
+ /**
+ * The name of the attribute that shall be used for the values of
+ * the spec.children field of the entity. Defaults to "member".
+ */
+ members?: string;
+ };
+ };
+ }>;
+ };
+
/**
* Configuration options for the catalog plugin.
+ *
+ * TODO(freben): Deprecate this entire block
*/
catalog?: {
/**
diff --git a/plugins/catalog-backend-module-ldap/src/processors/LdapOrgEntityProvider.ts b/plugins/catalog-backend-module-ldap/src/processors/LdapOrgEntityProvider.ts
index bad3941767..b31b7ae266 100644
--- a/plugins/catalog-backend-module-ldap/src/processors/LdapOrgEntityProvider.ts
+++ b/plugins/catalog-backend-module-ldap/src/processors/LdapOrgEntityProvider.ts
@@ -114,17 +114,11 @@ export class LdapOrgEntityProvider implements EntityProvider {
const config =
configRoot.getOptionalConfig('ldap') ||
configRoot.getOptionalConfig('catalog.processors.ldapOrg');
- if (!config) {
- throw new TypeError(
- `There is no LDAP configuration. Please add it as "ldap.providers".`,
- );
- }
-
- const providers = readLdapConfig(config);
+ const providers = config ? readLdapConfig(config) : [];
const provider = providers.find(p => options.target === p.target);
if (!provider) {
throw new TypeError(
- `There is no LDAP configuration that matches ${options.target}. Please add a configuration entry for it under "ldap.providers".`,
+ `There is no LDAP configuration that matches "${options.target}". Please add a configuration entry for it under "ldap.providers".`,
);
}
diff --git a/plugins/catalog-backend-module-ldap/src/processors/LdapOrgReaderProcessor.ts b/plugins/catalog-backend-module-ldap/src/processors/LdapOrgReaderProcessor.ts
index bec24a1744..74a7e153b9 100644
--- a/plugins/catalog-backend-module-ldap/src/processors/LdapOrgReaderProcessor.ts
+++ b/plugins/catalog-backend-module-ldap/src/processors/LdapOrgReaderProcessor.ts
@@ -43,17 +43,20 @@ export class LdapOrgReaderProcessor implements CatalogProcessor {
private readonly userTransformer?: UserTransformer;
static fromConfig(
- config: Config,
+ configRoot: Config,
options: {
logger: Logger;
groupTransformer?: GroupTransformer;
userTransformer?: UserTransformer;
},
) {
- const c = config.getOptionalConfig('catalog.processors.ldapOrg');
+ // TODO(freben): Deprecate the old catalog.processors.ldapOrg config
+ const config =
+ configRoot.getOptionalConfig('ldap') ||
+ configRoot.getOptionalConfig('catalog.processors.ldapOrg');
return new LdapOrgReaderProcessor({
...options,
- providers: c ? readLdapConfig(c) : [],
+ providers: config ? readLdapConfig(config) : [],
});
}
@@ -85,7 +88,7 @@ export class LdapOrgReaderProcessor implements CatalogProcessor {
const provider = this.providers.find(p => location.target === p.target);
if (!provider) {
throw new Error(
- `There is no LDAP Org provider that matches ${location.target}. Please add a configuration entry for it under catalog.processors.ldapOrg.providers.`,
+ `There is no LDAP configuration that matches "${location.target}". Please add a configuration entry for it under "ldap.providers".`,
);
}
diff --git a/plugins/catalog-backend-module-msgraph/README.md b/plugins/catalog-backend-module-msgraph/README.md
index d9488486ad..741e378fd4 100644
--- a/plugins/catalog-backend-module-msgraph/README.md
+++ b/plugins/catalog-backend-module-msgraph/README.md
@@ -92,26 +92,31 @@ yarn add @backstage/plugin-catalog-backend-module-msgraph
4. The `MicrosoftGraphOrgEntityProvider` is not registered by default, so you
have to register it in the catalog plugin. Pass the target to reference a
- provider from the configuration. As entity providers are not part of the
- entity refresh loop, you have to run them manually.
+ provider from the configuration.
-```typescript
-// packages/backend/src/plugins/catalog.ts
-const msGraphOrgEntityProvider = MicrosoftGraphOrgEntityProvider.fromConfig(
- env.config,
- {
- id: 'https://graph.microsoft.com/v1.0',
- target: 'https://graph.microsoft.com/v1.0',
- logger: env.logger,
- },
-);
-builder.addEntityProvider(msGraphOrgEntityProvider);
+```diff
+ // packages/backend/src/plugins/catalog.ts
++import { Duration } from 'luxon';
++import { MicrosoftGraphOrgEntityProvider } from '@backstage/plugin-catalog-backend-module-msgraph';
-// Trigger a read every 5 minutes
-useHotCleanup(
- module,
- runPeriodically(() => msGraphOrgEntityProvider.read(), 5 * 60 * 1000),
-);
+ export default async function createPlugin(
+ env: PluginEnvironment,
+ ): Promise {
+ const builder = await CatalogBuilder.create(env);
+
++ // The target parameter below needs to match one of the providers' target
++ // value specified in your app-config (see above).
++ builder.addEntityProvider(
++ MicrosoftGraphOrgEntityProvider.fromConfig(env.config, {
++ id: 'production',
++ target: 'https://graph.microsoft.com/v1.0',
++ logger: env.logger,
++ schedule: env.scheduler.createScheduledTaskRunner({
++ frequency: Duration.fromObject({ minutes: 5 }),
++ timeout: Duration.fromObject({ minutes: 3 }),
++ }),
++ }),
++ );
```
### Using the Processor
diff --git a/plugins/catalog-backend-module-msgraph/api-report.md b/plugins/catalog-backend-module-msgraph/api-report.md
index e3840dc6f7..2e741e65fe 100644
--- a/plugins/catalog-backend-module-msgraph/api-report.md
+++ b/plugins/catalog-backend-module-msgraph/api-report.md
@@ -14,6 +14,7 @@ import { Logger } from 'winston';
import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';
import * as msal from '@azure/msal-node';
import { Response as Response_2 } from 'node-fetch';
+import { TaskRunner } from '@backstage/backend-tasks';
import { UserEntity } from '@backstage/catalog-model';
// @public
@@ -119,19 +120,23 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
connect(connection: EntityProviderConnection): Promise;
// (undocumented)
static fromConfig(
- config: Config,
- options: {
- id: string;
- target: string;
- logger: Logger;
- userTransformer?: UserTransformer;
- groupTransformer?: GroupTransformer;
- organizationTransformer?: OrganizationTransformer;
- },
+ configRoot: Config,
+ options: MicrosoftGraphOrgEntityProviderOptions,
): MicrosoftGraphOrgEntityProvider;
// (undocumented)
getProviderName(): string;
- read(): Promise;
+ read(options?: { logger?: Logger }): Promise;
+}
+
+// @public
+export interface MicrosoftGraphOrgEntityProviderOptions {
+ groupTransformer?: GroupTransformer;
+ id: string;
+ logger: Logger;
+ organizationTransformer?: OrganizationTransformer;
+ schedule: 'manual' | TaskRunner;
+ target: string;
+ userTransformer?: UserTransformer;
}
// @public
diff --git a/plugins/catalog-backend-module-msgraph/package.json b/plugins/catalog-backend-module-msgraph/package.json
index 58ff3b2b3d..119fc5004c 100644
--- a/plugins/catalog-backend-module-msgraph/package.json
+++ b/plugins/catalog-backend-module-msgraph/package.json
@@ -34,6 +34,7 @@
},
"dependencies": {
"@azure/msal-node": "^1.1.0",
+ "@backstage/backend-tasks": "^0.2.0",
"@backstage/catalog-model": "^0.13.0",
"@backstage/config": "^0.1.15",
"@backstage/plugin-catalog-backend": "^0.24.0",
@@ -42,6 +43,7 @@
"lodash": "^4.17.21",
"node-fetch": "^2.6.7",
"p-limit": "^3.0.2",
+ "uuid": "^8.0.0",
"winston": "^3.2.1",
"qs": "^6.9.4"
},
diff --git a/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.ts b/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.ts
index 71aabaeef2..dfd0a7782e 100644
--- a/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.ts
+++ b/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.ts
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import { TaskRunner } from '@backstage/backend-tasks';
import {
ANNOTATION_LOCATION,
ANNOTATION_ORIGIN_LOCATION,
@@ -25,6 +26,7 @@ import {
EntityProviderConnection,
} from '@backstage/plugin-catalog-backend';
import { merge } from 'lodash';
+import * as uuid from 'uuid';
import { Logger } from 'winston';
import {
GroupTransformer,
@@ -39,6 +41,62 @@ import {
UserTransformer,
} from '../microsoftGraph';
+/**
+ * Options for {@link MicrosoftGraphOrgEntityProvider}.
+ *
+ * @public
+ */
+export interface MicrosoftGraphOrgEntityProviderOptions {
+ /**
+ * A unique, stable identifier for this provider.
+ *
+ * @example "production"
+ */
+ id: string;
+
+ /**
+ * The target that this provider should consume.
+ *
+ * Should exactly match the "target" field of one of the providers
+ * configuration entries.
+ */
+ target: string;
+
+ /**
+ * The logger to use.
+ */
+ logger: Logger;
+
+ /**
+ * The refresh schedule to use.
+ *
+ * @remarks
+ *
+ * If you pass in 'manual', you are responsible for calling the `read` method
+ * manually at some interval.
+ *
+ * But more commonly you will pass in the result of
+ * {@link @backstage/backend-tasks#PluginTaskScheduler.createScheduledTaskRunner}
+ * to enable automatic scheduling of tasks.
+ */
+ schedule: 'manual' | TaskRunner;
+
+ /**
+ * The function that transforms a user entry in msgraph to an entity.
+ */
+ userTransformer?: UserTransformer;
+
+ /**
+ * The function that transforms a group entry in msgraph to an entity.
+ */
+ groupTransformer?: GroupTransformer;
+
+ /**
+ * The function that transforms an organization entry in msgraph to an entity.
+ */
+ organizationTransformer?: OrganizationTransformer;
+}
+
/**
* Reads user and group entries out of Microsoft Graph, and provides them as
* User and Group entities for the catalog.
@@ -47,25 +105,21 @@ import {
*/
export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
private connection?: EntityProviderConnection;
+ private scheduleFn?: () => Promise;
static fromConfig(
- config: Config,
- options: {
- id: string;
- target: string;
- logger: Logger;
- userTransformer?: UserTransformer;
- groupTransformer?: GroupTransformer;
- organizationTransformer?: OrganizationTransformer;
- },
+ configRoot: Config,
+ options: MicrosoftGraphOrgEntityProviderOptions,
) {
- const c = config.getOptionalConfig('catalog.processors.microsoftGraphOrg');
- const providers = c ? readMicrosoftGraphConfig(c) : [];
+ const config = configRoot.getOptionalConfig(
+ 'catalog.processors.microsoftGraphOrg',
+ );
+ const providers = config ? readMicrosoftGraphConfig(config) : [];
const provider = providers.find(p => options.target.startsWith(p.target));
if (!provider) {
throw new Error(
- `There is no Microsoft Graph Org provider that matches ${options.target}. Please add a configuration entry for it under catalog.processors.microsoftGraphOrg.providers.`,
+ `There is no Microsoft Graph Org provider that matches "${options.target}". Please add a configuration entry for it under "catalog.processors.microsoftGraphOrg.providers".`,
);
}
@@ -73,7 +127,7 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
target: options.target,
});
- return new MicrosoftGraphOrgEntityProvider({
+ const result = new MicrosoftGraphOrgEntityProvider({
id: options.id,
userTransformer: options.userTransformer,
groupTransformer: options.groupTransformer,
@@ -81,6 +135,10 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
logger,
provider,
});
+
+ result.schedule(options.schedule);
+
+ return result;
}
constructor(
@@ -102,19 +160,21 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
/** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */
async connect(connection: EntityProviderConnection) {
this.connection = connection;
+ await this.scheduleFn?.();
}
/**
* Runs one complete ingestion loop. Call this method regularly at some
* appropriate cadence.
*/
- async read() {
+ async read(options?: { logger?: Logger }) {
if (!this.connection) {
throw new Error('Not initialized');
}
+ const logger = options?.logger ?? this.options.logger;
const provider = this.options.provider;
- const { markReadComplete } = trackProgress(this.options.logger);
+ const { markReadComplete } = trackProgress(logger);
const client = MicrosoftGraphClient.create(this.options.provider);
const { users, groups } = await readMicrosoftGraphOrg(
@@ -130,7 +190,7 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
groupTransformer: this.options.groupTransformer,
userTransformer: this.options.userTransformer,
organizationTransformer: this.options.organizationTransformer,
- logger: this.options.logger,
+ logger: logger,
},
);
@@ -146,6 +206,34 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
markCommitComplete();
}
+
+ private schedule(
+ schedule: MicrosoftGraphOrgEntityProviderOptions['schedule'],
+ ) {
+ if (schedule === 'manual') {
+ return;
+ }
+
+ this.scheduleFn = async () => {
+ const id = `${this.getProviderName()}:refresh`;
+ await schedule.run({
+ id,
+ fn: async () => {
+ const logger = this.options.logger.child({
+ class: MicrosoftGraphOrgEntityProvider.prototype.constructor.name,
+ taskId: id,
+ taskInstanceId: uuid.v4(),
+ });
+
+ try {
+ await this.read({ logger });
+ } catch (error) {
+ logger.error(error);
+ }
+ },
+ });
+ };
+ }
}
// Helps wrap the timing and logging behaviors
@@ -173,12 +261,12 @@ function trackProgress(logger: Logger) {
// Makes sure that emitted entities have a proper location based on their uuid
export function withLocations(providerId: string, entity: Entity): Entity {
- const uuid =
+ const uid =
entity.metadata.annotations?.[MICROSOFT_GRAPH_USER_ID_ANNOTATION] ||
entity.metadata.annotations?.[MICROSOFT_GRAPH_GROUP_ID_ANNOTATION] ||
entity.metadata.annotations?.[MICROSOFT_GRAPH_TENANT_ID_ANNOTATION] ||
entity.metadata.name;
- const location = `msgraph:${providerId}/${encodeURIComponent(uuid)}`;
+ const location = `msgraph:${providerId}/${encodeURIComponent(uid)}`;
return merge(
{
metadata: {
diff --git a/plugins/catalog-backend-module-msgraph/src/processors/index.ts b/plugins/catalog-backend-module-msgraph/src/processors/index.ts
index 7f70bde994..7bc3559c8b 100644
--- a/plugins/catalog-backend-module-msgraph/src/processors/index.ts
+++ b/plugins/catalog-backend-module-msgraph/src/processors/index.ts
@@ -15,4 +15,5 @@
*/
export { MicrosoftGraphOrgEntityProvider } from './MicrosoftGraphOrgEntityProvider';
+export type { MicrosoftGraphOrgEntityProviderOptions } from './MicrosoftGraphOrgEntityProvider';
export { MicrosoftGraphOrgReaderProcessor } from './MicrosoftGraphOrgReaderProcessor';
diff --git a/plugins/catalog-backend/config.d.ts b/plugins/catalog-backend/config.d.ts
index 957f18c15f..950ed2f63c 100644
--- a/plugins/catalog-backend/config.d.ts
+++ b/plugins/catalog-backend/config.d.ts
@@ -105,38 +105,5 @@ export interface Config {
allow: Array;
}>;
}>;
-
- /**
- * List of processor-specific options and attributes
- */
- processors?: {
- /**
- * GithubMultiOrgReaderProcessor configuration
- */
- githubMultiOrg?: {
- /**
- * The configuration parameters for each GitHub org to process.
- */
- orgs: Array<{
- /**
- * The name of the GitHub org to process.
- */
- name: string;
- /**
- * The namespace of the group created for this org.
- *
- * Defaults to org name if omitted.
- */
- groupNamespace?: string;
-
- /**
- * The namespace of the users created from this org.
- *
- * Defaults to empty string if omitted.
- */
- userNamespace?: string;
- }>;
- };
- };
};
}
diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md
index 265fce417d..a1541b555e 100644
--- a/plugins/catalog-react/api-report.md
+++ b/plugins/catalog-react/api-report.md
@@ -63,6 +63,13 @@ export { CatalogApi };
// @public
export const catalogApiRef: ApiRef;
+// @public (undocumented)
+export const CatalogFilterLayout: {
+ (props: { children: React_2.ReactNode }): JSX.Element;
+ Filters: (props: { children: React_2.ReactNode }) => JSX.Element;
+ Content: (props: { children: React_2.ReactNode }) => JSX.Element;
+};
+
// @public (undocumented)
export type CatalogReactComponentsNameToClassKey = {
CatalogReactUserListPicker: CatalogReactUserListPickerClassKey;
diff --git a/plugins/catalog-react/package.json b/plugins/catalog-react/package.json
index 5ba52e8ac7..39180ad5fb 100644
--- a/plugins/catalog-react/package.json
+++ b/plugins/catalog-react/package.json
@@ -42,6 +42,7 @@
"@backstage/integration": "^0.8.0",
"@backstage/plugin-permission-common": "^0.5.2",
"@backstage/plugin-permission-react": "^0.3.3",
+ "@backstage/theme": "^0.2.15",
"@backstage/types": "^0.1.3",
"@backstage/version-bridge": "^0.1.2",
"@material-ui/core": "^4.12.2",
diff --git a/plugins/catalog/src/components/FilteredEntityLayout/FilterContainer.tsx b/plugins/catalog-react/src/components/CatalogFilterLayout/CatalogFilterLayout.tsx
similarity index 78%
rename from plugins/catalog/src/components/FilteredEntityLayout/FilterContainer.tsx
rename to plugins/catalog-react/src/components/CatalogFilterLayout/CatalogFilterLayout.tsx
index 4c0d17599d..751eb35f1d 100644
--- a/plugins/catalog/src/components/FilteredEntityLayout/FilterContainer.tsx
+++ b/plugins/catalog-react/src/components/CatalogFilterLayout/CatalogFilterLayout.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { BackstageTheme } from '@backstage/theme';
+import React, { useState } from 'react';
import {
Box,
Button,
@@ -25,10 +25,10 @@ import {
useTheme,
} from '@material-ui/core';
import FilterListIcon from '@material-ui/icons/FilterList';
-import React, { useState } from 'react';
+import { BackstageTheme } from '@backstage/theme';
/** @public */
-export function FilterContainer(props: { children: React.ReactNode }) {
+export const Filters = (props: { children: React.ReactNode }) => {
const isMidSizeScreen = useMediaQuery(theme =>
theme.breakpoints.down('md'),
);
@@ -69,4 +69,25 @@ export function FilterContainer(props: { children: React.ReactNode }) {
{props.children}
);
-}
+};
+
+/** @public */
+export const Content = (props: { children: React.ReactNode }) => {
+ return (
+
+ {props.children}
+
+ );
+};
+
+/** @public */
+export const CatalogFilterLayout = (props: { children: React.ReactNode }) => {
+ return (
+
+ {props.children}
+
+ );
+};
+
+CatalogFilterLayout.Filters = Filters;
+CatalogFilterLayout.Content = Content;
diff --git a/plugins/catalog/src/components/FilteredEntityLayout/EntityListContainer.tsx b/plugins/catalog-react/src/components/CatalogFilterLayout/index.ts
similarity index 71%
rename from plugins/catalog/src/components/FilteredEntityLayout/EntityListContainer.tsx
rename to plugins/catalog-react/src/components/CatalogFilterLayout/index.ts
index d210d551fb..b69aab56ed 100644
--- a/plugins/catalog/src/components/FilteredEntityLayout/EntityListContainer.tsx
+++ b/plugins/catalog-react/src/components/CatalogFilterLayout/index.ts
@@ -14,14 +14,4 @@
* limitations under the License.
*/
-import { Grid } from '@material-ui/core';
-import React from 'react';
-
-/** @public */
-export function EntityListContainer(props: { children: React.ReactNode }) {
- return (
-
- {props.children}
-
- );
-}
+export { CatalogFilterLayout } from './CatalogFilterLayout';
diff --git a/plugins/catalog-react/src/components/index.ts b/plugins/catalog-react/src/components/index.ts
index 807d6bb702..7a26a72bf9 100644
--- a/plugins/catalog-react/src/components/index.ts
+++ b/plugins/catalog-react/src/components/index.ts
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+export * from './CatalogFilterLayout';
export * from './EntityKindPicker';
export * from './EntityLifecyclePicker';
export * from './EntityOwnerPicker';
diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md
index 43cde23c57..eddbe913d7 100644
--- a/plugins/catalog/api-report.md
+++ b/plugins/catalog/api-report.md
@@ -283,10 +283,10 @@ export interface EntityLinksCardProps {
// @public (undocumented)
export type EntityLinksEmptyStateClassKey = 'code';
-// @public (undocumented)
-export function EntityListContainer(props: {
- children: React_2.ReactNode;
-}): JSX.Element;
+// @public @deprecated (undocumented)
+export const EntityListContainer: (props: {
+ children: ReactNode;
+}) => JSX.Element;
// @public
export function EntityOrphanWarning(): JSX.Element;
@@ -319,15 +319,13 @@ export interface EntitySwitchProps {
children: ReactNode;
}
-// @public (undocumented)
-export function FilterContainer(props: {
- children: React_2.ReactNode;
-}): JSX.Element;
+// @public @deprecated (undocumented)
+export const FilterContainer: (props: { children: ReactNode }) => JSX.Element;
-// @public (undocumented)
-export function FilteredEntityLayout(props: {
- children: React_2.ReactNode;
-}): JSX.Element;
+// @public @deprecated (undocumented)
+export const FilteredEntityLayout: (props: {
+ children: React.ReactNode;
+}) => JSX.Element;
// @public
export function hasCatalogProcessingErrors(
diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx
index 8bb9bae764..2a2861ac29 100644
--- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx
+++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx
@@ -25,6 +25,7 @@ import {
} from '@backstage/core-components';
import { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';
import {
+ CatalogFilterLayout,
EntityLifecyclePicker,
EntityListProvider,
EntityOwnerPicker,
@@ -36,11 +37,6 @@ import {
import React from 'react';
import { createComponentRouteRef } from '../../routes';
import { CatalogTable, CatalogTableRow } from '../CatalogTable';
-import {
- FilteredEntityLayout,
- EntityListContainer,
- FilterContainer,
-} from '../FilteredEntityLayout';
import { CatalogKindHeader } from '../CatalogKindHeader';
/**
@@ -71,18 +67,18 @@ export function DefaultCatalogPage(props: DefaultCatalogPageProps) {
/>
All your software catalog entities
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx
index 8768e9728e..9588327c3b 100644
--- a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx
+++ b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx
@@ -15,7 +15,10 @@
*/
import { Entity } from '@backstage/catalog-model';
-import { EntityProvider } from '@backstage/plugin-catalog-react';
+import {
+ AsyncEntityProvider,
+ EntityProvider,
+} from '@backstage/plugin-catalog-react';
import { render } from '@testing-library/react';
import React from 'react';
import { isKind } from './conditions';
@@ -76,6 +79,18 @@ describe('EntitySwitch', () => {
expect(rendered.queryByText('A')).not.toBeInTheDocument();
expect(rendered.queryByText('B')).not.toBeInTheDocument();
expect(rendered.queryByText('C')).toBeInTheDocument();
+
+ rendered.rerender(
+
+
+ {content}
+
+ ,
+ );
+
+ expect(rendered.queryByText('A')).not.toBeInTheDocument();
+ expect(rendered.queryByText('B')).not.toBeInTheDocument();
+ expect(rendered.queryByText('C')).toBeInTheDocument();
});
it('should switch child when filters switch', () => {
diff --git a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.tsx b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.tsx
index 1b8667ce2a..993e7daa80 100644
--- a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.tsx
+++ b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.tsx
@@ -63,7 +63,7 @@ export interface EntitySwitchProps {
/** @public */
export const EntitySwitch = (props: EntitySwitchProps) => {
- const { entity } = useAsyncEntity();
+ const { entity, loading } = useAsyncEntity();
const apis = useApiHolder();
const results = useElementFilter(
props.children,
@@ -75,11 +75,23 @@ export const EntitySwitch = (props: EntitySwitchProps) => {
})
.getElements()
.flatMap((element: ReactElement) => {
- if (!entity) {
+ // Nothing is rendered while loading
+ if (loading) {
return [];
}
+
const { if: condition, children: elementsChildren } =
element.props as EntitySwitchCase;
+
+ // If the entity is missing or there is an error, render the default page
+ if (!entity) {
+ return [
+ {
+ if: condition === undefined,
+ children: elementsChildren,
+ },
+ ];
+ }
return [
{
if: condition?.(entity, { apis }) ?? true,
@@ -87,7 +99,7 @@ export const EntitySwitch = (props: EntitySwitchProps) => {
},
];
}),
- [apis, entity],
+ [apis, entity, loading],
);
const hasAsyncCases = results.some(
r => typeof r.if === 'object' && 'then' in r.if,
diff --git a/plugins/catalog/src/components/FilteredEntityLayout/FilteredEntityLayout.tsx b/plugins/catalog/src/components/FilteredEntityLayout/FilteredEntityLayout.tsx
deleted file mode 100644
index 8e595fe5cd..0000000000
--- a/plugins/catalog/src/components/FilteredEntityLayout/FilteredEntityLayout.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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 { Grid } from '@material-ui/core';
-import React from 'react';
-
-/** @public */
-export function FilteredEntityLayout(props: { children: React.ReactNode }) {
- return (
-
- {props.children}
-
- );
-}
diff --git a/plugins/catalog/src/components/FilteredEntityLayout/index.ts b/plugins/catalog/src/components/FilteredEntityLayout/index.ts
index ded61a4edc..892aa34147 100644
--- a/plugins/catalog/src/components/FilteredEntityLayout/index.ts
+++ b/plugins/catalog/src/components/FilteredEntityLayout/index.ts
@@ -14,6 +14,24 @@
* limitations under the License.
*/
-export { FilteredEntityLayout } from './FilteredEntityLayout';
-export { FilterContainer } from './FilterContainer';
-export { EntityListContainer } from './EntityListContainer';
+import { CatalogFilterLayout } from '@backstage/plugin-catalog-react';
+
+/**
+ * @public
+ * @deprecated Use `FilteredCatalogLayout` from `@backstage/plugin-catalog-react` instead.
+ */
+export const FilteredEntityLayout = CatalogFilterLayout as (props: {
+ children: React.ReactNode;
+}) => JSX.Element;
+
+/**
+ * @public
+ * @deprecated Use `FilteredCatalogLayout.Filters` from `@backstage/plugin-catalog-react` instead.
+ */
+export const FilterContainer = CatalogFilterLayout.Filters;
+
+/**
+ * @public
+ * @deprecated Use `FilteredCatalogLayout.Content` from `@backstage/plugin-catalog-react` instead.
+ */
+export const EntityListContainer = CatalogFilterLayout.Content;
diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md
index c0d3595503..d454fe2e7b 100644
--- a/plugins/scaffolder-backend/api-report.md
+++ b/plugins/scaffolder-backend/api-report.md
@@ -137,6 +137,17 @@ export function createGithubActionsDispatchAction(options: {
token?: string | undefined;
}>;
+// @public
+export function createGithubIssuesLabelAction(options: {
+ integrations: ScmIntegrationRegistry;
+ githubCredentialsProvider?: GithubCredentialsProvider;
+}): TemplateAction<{
+ repoUrl: string;
+ number: number;
+ labels: string[];
+ token?: string | undefined;
+}>;
+
// @public
export interface CreateGithubPullRequestActionOptions {
clientFactory?: (
@@ -368,6 +379,7 @@ export interface OctokitWithPullRequestPluginClient {
createPullRequest(options: createPullRequest.Options): Promise<{
data: {
html_url: string;
+ number: number;
};
} | null>;
}
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts
index 250a2b4b9e..93c5991ca9 100644
--- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts
@@ -45,6 +45,7 @@ import {
import {
createGithubActionsDispatchAction,
createGithubWebhookAction,
+ createGithubIssuesLabelAction,
} from './github';
import { TemplateFilter } from '../../../lib';
import { TemplateAction } from '../types';
@@ -145,6 +146,10 @@ export const createBuiltinActions = (
integrations,
githubCredentialsProvider,
}),
+ createGithubIssuesLabelAction({
+ integrations,
+ githubCredentialsProvider,
+ }),
];
return actions as TemplateAction[];
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubIssuesLabel.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubIssuesLabel.test.ts
new file mode 100644
index 0000000000..5518662e45
--- /dev/null
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubIssuesLabel.test.ts
@@ -0,0 +1,89 @@
+/*
+ * 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 { createGithubIssuesLabelAction } from './githubIssuesLabel';
+import {
+ ScmIntegrations,
+ DefaultGithubCredentialsProvider,
+ GithubCredentialsProvider,
+} from '@backstage/integration';
+import { ConfigReader } from '@backstage/config';
+import { getVoidLogger } from '@backstage/backend-common';
+import { PassThrough } from 'stream';
+import { TemplateAction } from '../..';
+
+const mockOctokit = {
+ rest: {
+ issues: {
+ addLabels: jest.fn(),
+ },
+ },
+};
+jest.mock('octokit', () => ({
+ Octokit: class {
+ constructor() {
+ return mockOctokit;
+ }
+ },
+}));
+
+describe('github:issues:label', () => {
+ const config = new ConfigReader({
+ integrations: {
+ github: [
+ { host: 'github.com', token: 'tokenlols' },
+ { host: 'ghe.github.com' },
+ ],
+ },
+ });
+
+ const integrations = ScmIntegrations.fromConfig(config);
+ let githubCredentialsProvider: GithubCredentialsProvider;
+ let action: TemplateAction;
+
+ const mockContext = {
+ input: {
+ repoUrl: 'github.com?repo=repo&owner=owner',
+ number: '1',
+ labels: ['label1', 'label2'],
+ },
+ workspacePath: 'lol',
+ logger: getVoidLogger(),
+ logStream: new PassThrough(),
+ output: jest.fn(),
+ createTemporaryDirectory: jest.fn(),
+ };
+
+ beforeEach(() => {
+ jest.resetAllMocks();
+ githubCredentialsProvider =
+ DefaultGithubCredentialsProvider.fromIntegrations(integrations);
+ action = createGithubIssuesLabelAction({
+ integrations,
+ githubCredentialsProvider,
+ });
+ });
+
+ it('should call the githubApi for adding labels', async () => {
+ await action.handler(mockContext);
+ expect(mockOctokit.rest.issues.addLabels).toHaveBeenCalledWith({
+ owner: 'owner',
+ repo: 'repo',
+ issue_number: '1',
+ labels: ['label1', 'label2'],
+ });
+ });
+});
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubIssuesLabel.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubIssuesLabel.ts
new file mode 100644
index 0000000000..9c849edb6f
--- /dev/null
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubIssuesLabel.ts
@@ -0,0 +1,109 @@
+/*
+ * 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 {
+ GithubCredentialsProvider,
+ ScmIntegrationRegistry,
+} from '@backstage/integration';
+import { createTemplateAction } from '../../createTemplateAction';
+import { assertError, InputError } from '@backstage/errors';
+import { Octokit } from 'octokit';
+import { getOctokitOptions } from './helpers';
+import { parseRepoUrl } from '../publish/util';
+
+/**
+ * Adds labels to a pull request or issue on GitHub
+ * @public
+ */
+export function createGithubIssuesLabelAction(options: {
+ integrations: ScmIntegrationRegistry;
+ githubCredentialsProvider?: GithubCredentialsProvider;
+}) {
+ const { integrations, githubCredentialsProvider } = options;
+
+ return createTemplateAction<{
+ repoUrl: string;
+ number: number;
+ labels: string[];
+ token?: string;
+ }>({
+ id: 'github:issues:label',
+ description: 'Adds labels to a pull request or issue on GitHub.',
+ schema: {
+ input: {
+ type: 'object',
+ required: ['repoUrl', 'number', 'labels'],
+ properties: {
+ repoUrl: {
+ title: 'Repository Location',
+ description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,
+ type: 'string',
+ },
+ number: {
+ title: 'Pull Request or issue number',
+ description: 'The pull request or issue number to add labels to',
+ type: 'number',
+ },
+ labels: {
+ title: 'Labels',
+ description: 'The labels to add to the pull request or issue',
+ type: 'array',
+ items: {
+ type: 'string',
+ },
+ },
+ token: {
+ title: 'Authentication Token',
+ type: 'string',
+ description: 'The GITHUB_TOKEN to use for authorization to GitHub',
+ },
+ },
+ },
+ },
+ async handler(ctx) {
+ const { repoUrl, number, labels, token: providedToken } = ctx.input;
+
+ const { owner, repo } = parseRepoUrl(repoUrl, integrations);
+ ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);
+
+ if (!owner) {
+ throw new InputError('Invalid repository owner provided in repoUrl');
+ }
+
+ const client = new Octokit(
+ await getOctokitOptions({
+ integrations,
+ credentialsProvider: githubCredentialsProvider,
+ repoUrl: repoUrl,
+ token: providedToken,
+ }),
+ );
+
+ try {
+ await client.rest.issues.addLabels({
+ owner,
+ repo,
+ issue_number: number,
+ labels,
+ });
+ } catch (e) {
+ assertError(e);
+ ctx.logger.warn(
+ `Failed: adding labels to issue: '${number}' on repo: '${repo}', ${e.message}`,
+ );
+ }
+ },
+ });
+}
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/index.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/index.ts
index 07614e8a03..c5788afc3a 100644
--- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/index.ts
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/index.ts
@@ -16,3 +16,4 @@
export { createGithubActionsDispatchAction } from './githubActionsDispatch';
export { createGithubWebhookAction } from './githubWebhook';
+export { createGithubIssuesLabelAction } from './githubIssuesLabel';
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.test.ts
index 9956f16003..464498c0c4 100644
--- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.test.ts
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.test.ts
@@ -58,6 +58,7 @@ describe('createPublishGithubPullRequestAction', () => {
status: 201,
data: {
html_url: 'https://github.com/myorg/myrepo/pull/123',
+ number: 123,
},
};
}),
@@ -123,13 +124,14 @@ describe('createPublishGithubPullRequestAction', () => {
});
});
- it('creates outputs for the url', async () => {
+ it('creates outputs for the pull request url and number', async () => {
await instance.handler(ctx);
expect(ctx.output).toHaveBeenCalledWith(
'remoteUrl',
'https://github.com/myorg/myrepo/pull/123',
);
+ expect(ctx.output).toHaveBeenCalledWith('pullRequestNumber', 123);
});
afterEach(() => {
mockFs.restore();
@@ -254,13 +256,14 @@ describe('createPublishGithubPullRequestAction', () => {
});
});
- it('creates outputs for the url', async () => {
+ it('creates outputs for the pull request url and number', async () => {
await instance.handler(ctx);
expect(ctx.output).toHaveBeenCalledWith(
'remoteUrl',
'https://github.com/myorg/myrepo/pull/123',
);
+ expect(ctx.output).toHaveBeenCalledWith('pullRequestNumber', 123);
});
afterEach(() => {
mockFs.restore();
@@ -322,13 +325,14 @@ describe('createPublishGithubPullRequestAction', () => {
});
});
- it('creates outputs for the url', async () => {
+ it('creates outputs for the pull request url and number', async () => {
await instance.handler(ctx);
expect(ctx.output).toHaveBeenCalledWith(
'remoteUrl',
'https://github.com/myorg/myrepo/pull/123',
);
+ expect(ctx.output).toHaveBeenCalledWith('pullRequestNumber', 123);
});
afterEach(() => {
mockFs.restore();
@@ -390,13 +394,14 @@ describe('createPublishGithubPullRequestAction', () => {
});
});
- it('creates outputs for the url', async () => {
+ it('creates outputs for the pull request url and number', async () => {
await instance.handler(ctx);
expect(ctx.output).toHaveBeenCalledWith(
'remoteUrl',
'https://github.com/myorg/myrepo/pull/123',
);
+ expect(ctx.output).toHaveBeenCalledWith('pullRequestNumber', 123);
});
afterEach(() => {
mockFs.restore();
diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts
index d46457ee1b..30293f2654 100644
--- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts
+++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.ts
@@ -37,7 +37,10 @@ class GithubResponseError extends CustomErrorBase {}
/** @public */
export interface OctokitWithPullRequestPluginClient {
createPullRequest(options: createPullRequest.Options): Promise<{
- data: { html_url: string };
+ data: {
+ html_url: string;
+ number: number;
+ };
} | null>;
}
@@ -169,6 +172,11 @@ export const createPublishGithubPullRequestAction = ({
title: 'Pull Request URL',
description: 'Link to the pull request in Github',
},
+ pullRequestNumber: {
+ type: 'number',
+ title: 'Pull Request Number',
+ description: 'The pull request number',
+ },
},
},
},
@@ -263,6 +271,7 @@ export const createPublishGithubPullRequestAction = ({
}
ctx.output('remoteUrl', response.data.html_url);
+ ctx.output('pullRequestNumber', response.data.number);
} catch (e) {
throw new GithubResponseError('Pull request creation failed', e);
}
diff --git a/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx b/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx
index 0b3fccc07c..a60a60554a 100644
--- a/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx
+++ b/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx
@@ -19,7 +19,6 @@ import {
ContentHeader,
CreateButton,
Header,
- Lifecycle,
Page,
SupportButton,
} from '@backstage/core-components';
@@ -27,13 +26,13 @@ import { Entity } from '@backstage/catalog-model';
import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
import { useRouteRef } from '@backstage/core-plugin-api';
import {
+ CatalogFilterLayout,
EntityKindPicker,
EntityListProvider,
EntitySearchBar,
EntityTagPicker,
UserListPicker,
} from '@backstage/plugin-catalog-react';
-import { makeStyles } from '@material-ui/core';
import React, { ComponentType } from 'react';
import { registerComponentRouteRef } from '../../routes';
import { TemplateList } from '../TemplateList';
@@ -41,15 +40,6 @@ import { TemplateTypePicker } from '../TemplateTypePicker';
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common';
import { usePermission } from '@backstage/plugin-permission-react';
-const useStyles = makeStyles(theme => ({
- contentWrapper: {
- display: 'grid',
- gridTemplateAreas: "'filters' 'grid'",
- gridTemplateColumns: '250px 1fr',
- gridColumnGap: theme.spacing(2),
- },
-}));
-
export type ScaffolderPageProps = {
TemplateCardComponent?:
| ComponentType<{ template: TemplateEntityV1beta3 }>
@@ -66,7 +56,6 @@ export const ScaffolderPageContents = ({
TemplateCardComponent,
groups,
}: ScaffolderPageProps) => {
- const styles = useStyles();
const registerComponentLink = useRouteRef(registerComponentRouteRef);
const otherTemplatesGroup = {
title: groups ? 'Other Templates' : 'Templates',
@@ -82,11 +71,7 @@ export const ScaffolderPageContents = ({
- Create a New Component
- >
- }
+ title="Create a New Component"
subtitle="Create new software components using standard templates"
/>
@@ -104,8 +89,8 @@ export const ScaffolderPageContents = ({
-