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

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

Merged
merged 1 commit into from
May 30, 2024

Conversation

gashcrumb
Copy link
Member

@gashcrumb gashcrumb commented May 8, 2024

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:

  • GitHub Actions are completed and successful
  • Unit Tests are updated and passing
  • E2E Tests are updated and passing
  • Documentation is updated if necessary (requirement for new features)
  • Add a screenshot if the change is UX/UI related

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)'

@gashcrumb gashcrumb requested a review from a team as a code owner May 8, 2024 17:29
Copy link
Contributor

github-actions bot commented May 8, 2024

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

Copy link
Contributor

github-actions bot commented May 8, 2024

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

Copy link
Contributor

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

@gashcrumb
Copy link
Member Author

/retest

Copy link
Contributor

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

Copy link
Contributor

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

@ciiay
Copy link
Contributor

ciiay commented May 16, 2024

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
Copy link
Contributor

ciiay commented May 16, 2024

/lgtm

@debsmita1
Copy link
Member

debsmita1 commented May 30, 2024

verfied the changes locally
/lgtm
/approve

@invincibleJai
Copy link
Member

/approve

@openshift-ci openshift-ci bot removed the approved label May 30, 2024
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.

Signed-off-by: Stan Lewis <gashcrumb@gmail.com>
@gashcrumb gashcrumb reopened this May 30, 2024
Copy link

sonarcloud bot commented May 30, 2024

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
Copy link
Member

/lgtm

Copy link

openshift-ci bot commented May 30, 2024

[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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

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

@gashcrumb
Copy link
Member Author

/retest

@gashcrumb
Copy link
Member Author

/retest

@gashcrumb
Copy link
Member Author

github happy path tests seem to have:

image

@gashcrumb
Copy link
Member Author

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit 0bee20b into janus-idp:main May 30, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants