Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core-*-api: backport support for external route ref default targets + config route binding #24777

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Rugvip
Copy link
Member

@Rugvip Rugvip commented May 15, 2024

Hey, I just made a Pull Request!

The new frontend system supports route binding through static configuration, for example:

app:
  routes:
    bindings:
      catalog.createComponent: catalog-import.importPage

It also lets you define default targets for external route references, for example:

export const registerComponentRouteRef = createExternalRouteRef({
  optional: true,
  defaultTarget: 'catalog-import.importPage',
});

This adds support for both of these features in the existing frontend system.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

Rugvip added 10 commits May 15, 2024 10:53
…nd route binding through config

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
…ets and route binding through config

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
@Rugvip Rugvip requested review from a team as code owners May 15, 2024 08:53
@github-actions github-actions bot added documentation Improvements or additions to documentation area:catalog Related to the Catalog Project Area area:scaffolder Everything and all things related to the scaffolder project area labels May 15, 2024
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented May 15, 2024

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @backstage/backend-defaults
  • @backstage/backend-test-utils

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
example-app packages/app none v0.2.98-next.1
@backstage/backend-defaults packages/backend-defaults none v0.3.0-next.1
@backstage/backend-test-utils packages/backend-test-utils none v0.4.0-next.1
@backstage/core-app-api packages/core-app-api patch v1.12.5
@backstage/core-compat-api packages/core-compat-api patch v0.2.6-next.0
@backstage/core-plugin-api packages/core-plugin-api patch v1.9.2
@backstage/plugin-api-docs plugins/api-docs patch v0.11.6-next.0
@backstage/plugin-catalog-graph plugins/catalog-graph patch v0.4.6-next.0
@backstage/plugin-catalog plugins/catalog minor v1.20.1-next.1
@backstage/plugin-org plugins/org patch v0.6.26-next.0
@backstage/plugin-scaffolder plugins/scaffolder minor v1.20.2-next.1

Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label May 29, 2024
@freben freben removed the stale label May 29, 2024
Copy link
Member

@freben freben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

docs/frontend-system/architecture/07-routes.md Outdated Show resolved Hide resolved
routeValidationError = error;
throw error;
}
} else if (routeValidationError) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structure kinda assumes that resolveRouteBindings never throws. Could have the if (routeValidationError) check at the very top instead, and then a try/catch around both resolveRouteBindings and the validation. Or do you want this to potentially retry over and over if the resolutions failed the first time?

return undefined;
},
// This might already be implemented in the legacy ref, but we override it just to be sure
getDefaultTarget: newRef.getDefaultTarget,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getDefaultTarget: newRef.getDefaultTarget,
getDefaultTarget: newRef.getDefaultTarget?.bind(newRef),

or is that paranoid? :D

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:catalog Related to the Catalog Project Area area:scaffolder Everything and all things related to the scaffolder project area documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants