-
Notifications
You must be signed in to change notification settings - Fork 50
🐛 Remove save button and functionality from SchemaAsCodeEditor #2593
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
Conversation
WalkthroughRemoved Save UI/logic and the Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as SchemaAsCodeEditor
participant CE as CodeEditor
participant Validator as JSON Validator
rect rgb(250,250,255)
Note over User,CE: Edit flow (Save removed)
User->>CE: Edit JSON
CE-->>UI: onDocumentChanged(jsonText)
UI->>Validator: Validate(jsonText)
Validator-->>UI: Valid / Invalid
UI-->>CE: updateErrors / state
end
rect rgb(245,255,245)
Note over User,CE: Download flow (no .json duplication)
User->>CE: Click Download
CE-->>User: Download file "my-schema-download"
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Assessment against linked issues
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (3)
💤 Files with no reviewable changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
client/src/app/components/schema-defined-fields/SchemaAsCodeEditor.tsx (1)
27-28
: Deprecate onDocumentSaved, remove its destructuring, and update remaining call sites
- Mark
onDocumentSaved
as deprecated inISchemaAsCodeEditorProps
and remove it from the destructured props inSchemaAsCodeEditor
(lines 27–28, 35).- In
client/src/app/components/schema-defined-fields/SchemaDefinedFields.tsx
(lines 69 & 78), replacewithonDocumentSaved={onSavedHandler}(or the appropriate change handler) so callers are guided to use the new prop.onDocumentChanged={onSavedHandler}
🧹 Nitpick comments (3)
client/src/app/components/schema-defined-fields/SchemaAsCodeEditor.tsx (3)
96-101
: Ensure the downloaded file has a .json extension (once) and correct MIME type.With PatternFly’s default onDownload, the file is saved exactly as downloadFileName (no auto-extension) and Blob type is "text". Setting downloadFileName without ".json" will produce a file without an extension. Add a custom onDownload to append ".json" only if missing and use application/json. (patternfly.org)
Apply this diff:
isReadOnly={isReadOnly} height={height} downloadFileName="my-schema-download" language={Language.json} code={currentCode} onChange={handleCodeChange} + onDownload={(value, fileName) => { + const name = fileName.endsWith(".json") ? fileName : `${fileName}.json`; + const blob = new Blob([value], { type: "application/json;charset=utf-8" }); + const a = document.createElement("a"); + a.href = URL.createObjectURL(blob); + a.download = name; + a.click(); + URL.revokeObjectURL(a.href); + }} onEditorDidMount={(editor, monaco) => {
51-51
: Remove dead state and validator side-effect.okToSave is no longer used; editorProps.onValidate only updates that dead state. Drop both to avoid unnecessary renders.
Apply this diff:
- const [okToSave, setOkToSave] = React.useState(true);
- editorProps={{ - onValidate: (markers) => { - setOkToSave(markers.every(({ severity }) => severity !== 8)); - }, - }}Also applies to: 117-120
61-66
: Use 1-based column for Monaco position.Monaco positions are 1-based; set column to 1.
Apply this diff:
- editorRef.current.setPosition({ column: 0, lineNumber: 1 }); + editorRef.current.setPosition({ column: 1, lineNumber: 1 });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
client/src/app/components/schema-defined-fields/SchemaAsCodeEditor.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: unit-test
- GitHub Check: build-and-upload-for-global-ci
Signed-off-by: Maayan Hadasi <[email protected]>
Signed-off-by: Scott J Dickerson <[email protected]>
1c98003
to
cc9f81f
Compare
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.
LGTM
I removed the onDocumentSave
function support since it is no longer relevant.
Resolves: https://issues.redhat.com/browse/MTA-6025
Resolves: https://issues.redhat.com/browse/MTA-6024
Resolves: #2592
Resolves: #2591
Before:

After:

Summary by CodeRabbit
Refactor
Documentation