janus-idp / backstage-showcase

This repo is moving to https://github.com/redhat-developer/red-hat-developer-hub
https://showcase.janus-idp.io
Apache License 2.0
110 stars 143 forks source link

fix(app): RHIDP-2266 add condition error handling #1245

Closed gashcrumb closed 4 months ago

gashcrumb commented 5 months ago

Description

This change adds exception handling to the two points where plugin supplied condition functions are evaluated, once when rendering the catalog entity tabs, and a second time when a plugin's mountpoint configuration is being checked. This change also makes the ApiHolder context object available as a 2nd argument; available at the second evaluation point.

Which issue(s) does this PR fix

PR acceptance criteria

Please make sure that the following steps are complete:

How to test changes / Special notes to the reviewer

An easy way to test this is to throw an exception from here and use this plugin. The configuration for this would look like:

    backstage-plugin-simple-test-components:
      mountPoints:
        - mountPoint: entity.page.overview/cards
          importName: SimpleTestComponentsPage
          config:
            layout:
              gridColumn: "span 1"
              gridRow: "span 1"
            if:
              allOf:
                - isAvailableYes
            props:
              text: 'Content Block Two (always available)'
github-actions[bot] commented 5 months ago

The image is available at: quay.io/janus-idp/backstage-showcase:pr-1245!

github-actions[bot] commented 5 months ago

The image is available at: quay.io/janus-idp/backstage-showcase:pr-1245!

github-actions[bot] commented 4 months ago

The image is available at: quay.io/janus-idp/backstage-showcase:pr-1245!

gashcrumb commented 4 months ago

/retest

github-actions[bot] commented 4 months ago

The image is available at: quay.io/janus-idp/backstage-showcase:pr-1245!

github-actions[bot] commented 4 months ago

The image is available at: quay.io/janus-idp/backstage-showcase:pr-1245!

ciiay commented 4 months ago

Verified this is working great. I have this config

          if:
            allOf:
            - isAvailableUsingContext

As well as an exception in simple-test-components/src/plugin.ts

export const isAvailableUsingContext = (
  _entity: Entity,
  _context: { apis: ApiHolder }
) => {
  throw new Error("Test exception for isAvailableUsingContext");
};

When tested on main branch it throws an error and breaks the entire UI. While with this PR's update it loads the rest of catalog entity tabs only the simple-test-component doesn't get load. Also the warning in console shows up as expected.

image

ciiay commented 4 months ago

/lgtm

debsmita1 commented 4 months ago

verfied the changes locally /lgtm /approve

invincibleJai commented 4 months ago

/approve

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

invincibleJai commented 4 months ago

/lgtm

openshift-ci[bot] commented 4 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ciiay, debsmita1, invincibleJai

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/janus-idp/backstage-showcase/blob/main/OWNERS)~~ [invincibleJai] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
github-actions[bot] commented 4 months ago

The image is available at: quay.io/janus-idp/backstage-showcase:pr-1245!

gashcrumb commented 4 months ago

/retest

gashcrumb commented 4 months ago

/retest

gashcrumb commented 4 months ago

github happy path tests seem to have:

image

gashcrumb commented 4 months ago

/retest