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 Component Viewer When Invalid URLs are Loaded #51

Merged
merged 2 commits into from
Jun 16, 2021
Merged

Conversation

tuckerzp
Copy link
Contributor

@tuckerzp tuckerzp commented Jun 9, 2021

OSCALComponent was setting an error without dealing with it. This caused the Component Viewer to not load at all when loading an invalid default URL. OSCALLoader now passes an onError() function to OSCALComponent that allows:

  1. OSCALComponent to throw an error
  2. OSCALLoader to catch that error
  3. OSCALLoader displays the existing, defined error of: "Something went wrong loading the OSCAL data {error}"

Testing

By default the Component should display an error due to the issue usnistgov/oscal-content#69.

To test a successful component you must:

  1. Download and extract example-component.json from example-component.zip
  2. Place that file in public folder
  3. Load http://localhost:3000/example-component.json into the component viewer
  4. Optional: Set defaultOSCALComponentUrl in OSCALLoader to:
    const defaultOSCALComponentUrl = http://localhost:3000/example-component.json

Copy link
Contributor

@rgauss rgauss left a comment

Choose a reason for hiding this comment

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

Minor changes requested.

src/OSCALLoader.js Outdated Show resolved Hide resolved
src/OSCALLoader.js Show resolved Hide resolved
@tuckerzp tuckerzp requested a review from rgauss June 10, 2021 14:23
@tuckerzp tuckerzp self-assigned this Jun 10, 2021
@rgauss
Copy link
Contributor

rgauss commented Jun 14, 2021

This probably should have gone straight into the develop branch since it's not specific to the Profile viewer, but we can leave as is.

Copy link
Contributor

@kylelaker kylelaker left a comment

Choose a reason for hiding this comment

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

@tuckerzp you need to fix your commits' author data on this branch. Perhaps that'd be a good time to reorg to be on top of develop instead of EGRC-261.

OSCALLoader did not catch errors thrown in OSCALComponentDefinition.
When created, OSCALComponentDefinition is now passed an onError()
function. OSCALLoader catches that error and displays the existing,
defined error of: "Something went wrong loading the OSCAL data"
OSCALComponentDefinition was setting the error and did nothing with it
when resolving sources. It now throws the error to OSCALLoader.
@tuckerzp tuckerzp changed the base branch from EGRC-261 to develop June 15, 2021 12:58
@tuckerzp
Copy link
Contributor Author

@rgauss with @kylelaker's help, I changed the branch we are merging into to develop

@tuckerzp tuckerzp requested a review from kylelaker June 15, 2021 13:01
@kylelaker kylelaker dismissed their stale review June 15, 2021 14:42

My concern has been addressed

@tuckerzp tuckerzp merged commit 3cfde25 into develop Jun 16, 2021
@rgauss rgauss deleted the EGRC-393 branch June 16, 2021 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants