Skip to content

Conversation

mguetta1
Copy link
Collaborator

@mguetta1 mguetta1 commented Sep 2, 2025

Resolves: https://issues.redhat.com/browse/MTA-6025
Resolves: https://issues.redhat.com/browse/MTA-6024
Resolves: #2592
Resolves: #2591

Before:
Screenshot_20250902_160539

After:
Screenshot_20250902_160602

Summary by CodeRabbit

  • Refactor

    • Removed the editor’s Save button and manual save flow; edits are now applied automatically when valid JSON is detected and propagated immediately.
    • Download behavior updated: exported schema uses the base name "my-schema-download" without a preset file extension.
  • Documentation

    • Clarified that changes save automatically on valid edits and downloads no longer append “.json” by default.

Copy link

coderabbitai bot commented Sep 2, 2025

Walkthrough

Removed Save UI/logic and the onDocumentSaved prop across schema editor components; editor now uses onDocumentChanged for edits. Adjusted editor focus position and changed download filename to omit the .json extension.

Changes

Cohort / File(s) Summary
Schema as code editor — UI & behavior
client/src/app/components/schema-defined-fields/SchemaAsCodeEditor.tsx
- Removed SaveControl import, handleSave, okToSave state, and custom Save controls
- Removed onDocumentSaved from props and all save-related invocation; now relies on onDocumentChanged only
- Replaced previous validation/save logic with a commented validation placeholder
- Changed editor focus position column from 0 to 1
Schema fields component — prop surface
client/src/app/components/schema-defined-fields/SchemaAsFields.tsx
- Removed onDocumentSaved from SchemaAsFieldsProps and component destructured props
Schema defined field aggregator — prop forwarding
client/src/app/components/schema-defined-fields/SchemaDefinedFields.tsx
- Removed onDocumentSaved from ISchemaDefinedFieldProps and component signature
- Removed internal onSavedHandler and forwarding of onDocumentSaved to children; now forwards only onDocumentChanged
Download filename change
client/src/app/components/schema-defined-fields/SchemaAsCodeEditor.tsx
- Changed CodeEditor downloadFileName from "my-schema-download.json" to "my-schema-download" (extension removed)

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Remove redundant Save button in Discover Applications wizard (#2591)
Fix duplicated .json extension in downloaded schema file (#2592)

Suggested reviewers

  • ibolton336
  • rszwajko

Poem

🐇 I hopped through lines and pressed delete,
The extra Save made room for neat.
Downloads shed the double dot,
Clean schema files—now quite a lot!
A rabbit cheers: tidy code complete.


📜 Recent 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 4b92aaf and cc9f81f.

📒 Files selected for processing (3)
  • client/src/app/components/schema-defined-fields/SchemaAsCodeEditor.tsx (4 hunks)
  • client/src/app/components/schema-defined-fields/SchemaAsFields.tsx (0 hunks)
  • client/src/app/components/schema-defined-fields/SchemaDefinedFields.tsx (0 hunks)
💤 Files with no reviewable changes (2)
  • client/src/app/components/schema-defined-fields/SchemaAsFields.tsx
  • client/src/app/components/schema-defined-fields/SchemaDefinedFields.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • client/src/app/components/schema-defined-fields/SchemaAsCodeEditor.tsx
⏰ 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
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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 in ISchemaAsCodeEditorProps and remove it from the destructured props in SchemaAsCodeEditor (lines 27–28, 35).
  • In client/src/app/components/schema-defined-fields/SchemaDefinedFields.tsx (lines 69 & 78), replace
    onDocumentSaved={onSavedHandler}
    with
    onDocumentChanged={onSavedHandler}
    (or the appropriate change handler) so callers are guided to use the new prop.
🧹 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.

📥 Commits

Reviewing files that changed from the base of the PR and between a89124f and 4b92aaf.

📒 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

@sjd78 sjd78 force-pushed the remove-save-button branch from 1c98003 to cc9f81f Compare September 3, 2025 21:53
Copy link
Member

@sjd78 sjd78 left a 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.

@sjd78 sjd78 merged commit dae9770 into konveyor:main Sep 3, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants