-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add OSCALJsonEditor Component #265
Conversation
Added conditional checks for `isRestMode` and added the react-split control so that when `isRestMode` is `true` the `OSCALLoader` component will render a split pane.
The `maxWidth` value of `xl` was added which overrides the default of large. This was done so that the JSON editor can be accomodated in the application.
The split pane defaults were updated so that the JSON Editor and viewer share a 50/50 split. The `minSize` value was also updated to 500 as a sensible default, because collapsing a pane to 0 can cause issues.
The updates improve the look and feel based on the margins and grid layout. The editor was also made sticky so that it follows veritical scrolling.
Removed overflow attributes, since they cause conflicts with sticky HTML elements.
The split pane defaults were updated so that the JSON Editor and viewer share a 50/50 split. The `minSize` value was also updated to 500 as a sensible default, because collapsing a pane to 0 can cause issues.
The split pane defaults were updated so that the JSON Editor and viewer share a 50/50 split. The `minSize` value was also updated to 500 as a sensible default, because collapsing a pane to 0 can cause issues.
…eact-library into feature/json-editor
Seems like the content uses ~100% of the display width in non-REST mode now. Is that an intentional change? Other small nitpicks on UI stuff:
|
Intentional, based on the screenshot that @rgauss shared with us on the potential design of including an editor. If we change the display width between rest/non-rest mode, the layout changes pretty dramatically which leads to some cognitive load. Nonetheless, this has been factored by a very small change to
Worked this in already, the changes will be up soon.
I tried not to modify existing layout/style decisions. Prior to this PR, the header was not fixed, so no change there. However changing it to be fixed isn't that hard.
This was intentional, so that when you do scroll past a certain point (i.e. when the top nav and selector are past the scroll port), the editor (including the buttons) fills up the viewport vertical space. Eventually the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. There are things it might be sorta nice to fix in future tickets but that I don't think should slow down our progress here. A few of them are:
- base64 encoding should be handled as part of the build process, we should avoid directly writing b64 strings directly into the application (we do have Webpack here which may help)
- it would be cool if the browser find functionality worked within the JSON editor. it has it's own (better) find functionality but you have to click within it and if you don't the browser doesn't see any of the Editor content
- TABS?! 😆
Webpack should help here, after doing some exploratory testing, I feel like this should be improved as part of another PR, since there are some decisions that need to be made around which one of the following paths we should use to bundle/package the library:
Currently we are using the microbundle-crl to create the bundle. If in the future we decide to use webpack, it will help optimize packaging; and IMO my least favorite option is to use webpack + microbundle-crl because it will introduce too much complexity in packaging.
Confirmed that I can replicate this, the browser find only matches text in the current viewport, this is because the editor is maintains the rest of the text in virtual DOM. Not sure how we get around it, unless we render all the lines. However, the OSCAL JSON files can sometimes be 70K+ lines, which when rendered might lead to a poor experience. Maybe there is a better way that I just haven't discovered yet 🤷
Note for future improvement: Tab Trapping. |
src/components/OSCALLoader.js
Outdated
result = isRestMode ? ( | ||
<Split className={classes.split} minSize={500} sizes={[50, 50]}> | ||
<Box> | ||
<OSCALJsonEditor value={oscalData} onSave={handleRestPut} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here oscalData
will often contain fields other than what's returned in the REST response due to things like profile resolution. For example, SSPs will contain a resolvedControls
array that should not be shown in source and should not be sent in the PUT
REST request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled the removal of resolvedControls
in cf83ad1. If there are any others that need to be removed, please let me know. It's pretty opaque to me how those got in added to oscalData
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the additional fields are populated and passed in the resolvers (example) is currently a bit sloppy.
At some point we should revisit how we pass that additional info around to the components, but for now, perhaps we should consider shoving the original response string in something like oscalData.oscalSource
rather than the approach of copying and removing what was added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolvedControls
was just one example, modifications
is another.
perhaps we should consider shoving the original response string in something like
oscalData.oscalSource
rather than the approach of copying and removing what was added?
Update layout of editor, hide `resolvedControls` attribute, and minor changes that improve testing. Tests were added in OSCALJsonEditor.test.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI looks great tested locally. Would like to see the toggle functionality as Ray described but other than that ready to merge.
Based on @rgauss's comments, I am going to dismiss my review and withold approval until those issues are resolved.
This change adds the a `Fab` button that floats over the enitre viewer via a toolbar. Upon clicking the button, the JSON editor is toggled to either be displayed or hidden.
a833ac5
to
b9e70d3
Compare
Preserved oscalSource and UI Changes
@kylelaker, have your concerns been addressed here? |
@rgauss I think so for the most part. I had previously approved and I think then dismissed because others had raised concerns. I haven't been following the developments on this branch super closely but I have no objections to merging it. |
Uses
react-split
to create a vertically split element into two panes. This only manifests in REST mode and starts off with 50/50 split for the two panes. The end user is then able to adjust the width of the pane up to a certain limit.OSCALJsonEditor
component which consists of a configured instance of the@monaco-editor
component. The editor is does take up 100% of the vertical height of the HTML page, instead, it adapts to screen height and is positioned relative to thescrollport
based on sticky positioning.OSCALLoader
components.TO DOs:
makeStyles
used by MUIReferences