Skip to content

feat: Add type mismatch warning when quick-adding entry to Cloud Config array parameter #2875

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

Merged
merged 5 commits into from
Jul 9, 2025

Conversation

mtrezza
Copy link
Member

@mtrezza mtrezza commented Jul 9, 2025

Summary

  • determine the last array element type when opening the add-entry dialog
  • warn the user if the entered value type differs from the last element

Testing

  • npm test (fails: dashboard e2e test requires network)
  • npm run lint

https://chatgpt.com/codex/tasks/task_e_686db1a92488832d822746877e20f412

Summary by CodeRabbit

  • New Features

    • Added a warning prompt when adding an array entry with a type different from the previous one, requiring user confirmation.
    • The "Add Array Entry" dialog now displays the type of the last array entry for improved context and consistency.
  • Bug Fixes

    • Enhanced validation to prevent accidental confirmation of type mismatched entries, reducing data inconsistency risks.

@mtrezza mtrezza added the codex label Jul 9, 2025 — with ChatGPT Connector
Copy link

parse-github-assistant bot commented Jul 9, 2025

🚀 Thanks for opening this pull request!

Copy link

coderabbitai bot commented Jul 9, 2025

Warning

Rate limit exceeded

@mtrezza has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 34 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d972f7c and ced15cc.

📒 Files selected for processing (1)
  • src/dashboard/Data/Config/AddArrayEntryDialog.react.js (3 hunks)
📝 Walkthrough

Walkthrough

The changes implement type checking when adding new entries to array parameters in the dashboard. When a user attempts to add an entry, the system checks if the type matches the previous entry. If there is a mismatch, a warning modal prompts the user for confirmation before proceeding. Supporting methods and state variables are added to manage type detection and warning logic.

Changes

File(s) Change Summary
src/dashboard/Data/Config/AddArrayEntryDialog.react.js Added state for mismatch confirmation, methods for type detection and confirmation handling, updated validation logic, and conditional rendering of a confirmation checkbox on type mismatch.
src/dashboard/Data/Config/Config.react.js Added method to determine entry type, tracked last array entry type when opening add entry dialog, and passed it as a prop to the dialog component.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Config
    participant AddArrayEntryDialog

    User->>Config: Open Add Array Entry Dialog
    Config->>Config: Determine last entry type
    Config->>AddArrayEntryDialog: Pass lastType prop

    User->>AddArrayEntryDialog: Enter new value and confirm
    AddArrayEntryDialog->>AddArrayEntryDialog: Parse value and determine type
    AddArrayEntryDialog->>AddArrayEntryDialog: Compare new type with lastType

    alt Type matches or user confirms warning
        AddArrayEntryDialog->>Config: Add entry to array
    else Type mismatch and no confirmation
        AddArrayEntryDialog->>User: Show warning modal with confirmation checkbox
        User->>AddArrayEntryDialog: Confirm or cancel
    end
Loading

Possibly related PRs

  • parse-community/parse-dashboard#2866: Introduces the initial AddArrayEntryDialog component and basic array entry addition functionality, which the current changes extend by adding type mismatch warnings.

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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

The label codex cannot be used here.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Jul 9, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

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

🧹 Nitpick comments (1)
src/dashboard/Data/Config/AddArrayEntryDialog.react.js (1)

39-47: Consider eliminating code duplication.

The getType method is identical to the getEntryType method in Config.react.js. This duplication could lead to maintenance issues if the type detection logic needs to be updated.

Consider extracting this method to a shared utility module:

// utils/typeUtils.js
export function getValueType(value) {
  if (Array.isArray(value)) {
    return 'array';
  }
  if (value === null) {
    return 'null';
  }
  return typeof value;
}

Then import and use it in both components:

import { getValueType } from 'utils/typeUtils';

// In both components, replace the local method with:
const entryType = getValueType(parsed);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cfd0bce and dddcf8d.

📒 Files selected for processing (2)
  • src/dashboard/Data/Config/AddArrayEntryDialog.react.js (3 hunks)
  • src/dashboard/Data/Config/Config.react.js (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/dashboard/Data/Config/AddArrayEntryDialog.react.js (1)
Learnt from: mtrezza
PR: parse-community/parse-dashboard#2828
File: src/dashboard/Data/Browser/Browser.react.js:1605-1607
Timestamp: 2025-05-27T12:09:47.644Z
Learning: In script execution dialogs in Parse Dashboard (specifically the `confirmExecuteScriptRows` method in `src/dashboard/Data/Browser/Browser.react.js`), individual `setState` calls to update `processedScripts` counter should be kept as-is rather than batched, because this provides real-time progress feedback to users in the dialog UI.
⏰ 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). (1)
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (10)
src/dashboard/Data/Config/Config.react.js (5)

51-51: Good addition for type tracking state.

The addEntryLastType state property is properly initialized to null and will be used to track the type of the last array entry. This aligns well with the existing state structure.


212-220: Well-implemented type detection method.

The getEntryType method correctly handles the main JavaScript type distinctions:

  • Arrays are explicitly identified as 'array' (not 'object')
  • Null values are explicitly identified as 'null' (not 'object')
  • Other types use JavaScript's native typeof operator

This implementation provides the granular type information needed for meaningful type mismatch warnings.


505-517: Robust implementation of type detection logic.

The openAddEntryDialog method correctly:

  • Retrieves the current array parameter value
  • Safely checks if it's an array with length > 0
  • Determines the type of the last element using the new getEntryType method
  • Stores the type in state for use by the dialog

The defensive programming approach with null checks and array validation ensures the feature works reliably across different scenarios.


519-525: Proper state cleanup in dialog close handler.

The closeAddEntryDialog method correctly resets both the parameter name and the last type state to their initial values. This prevents stale state from affecting subsequent dialog operations.


126-126: Correctly passing type information to child component.

The lastType prop properly passes the tracked type information to the AddArrayEntryDialog component, enabling it to perform type mismatch detection. This establishes the necessary data flow between parent and child components.

src/dashboard/Data/Config/AddArrayEntryDialog.react.js (5)

17-17: Well-structured state extension for warning functionality.

The state is properly extended with:

  • showWarning: Boolean flag to control warning modal visibility
  • parsedValue: Cached parsed value to avoid re-parsing
  • parsedType: Cached type information for display in warning

The initialization values are appropriate and the structure supports the warning workflow.


49-59: Solid implementation of type mismatch detection and warning logic.

The handleConfirm method correctly:

  • Parses the input value once and caches it
  • Determines the entry type using the local getType method
  • Compares with the last type prop from parent component
  • Shows warning only if there's a mismatch and no warning is currently shown
  • Proceeds with confirmation if no mismatch or if warning was already shown
  • Properly resets warning state after confirmation

The logic handles edge cases well, including the scenario where lastType is null (empty array).


62-90: Good separation of modal concerns.

Extracting the main modal into a separate variable (addEntryModal) improves readability and prepares for the dual-modal structure. The modal configuration remains unchanged, maintaining existing functionality.


92-106: Well-designed warning modal with clear user messaging.

The warning modal:

  • Uses appropriate modal type (WARNING) and icon
  • Provides clear, informative title and message
  • Shows both the expected type and actual type in the message
  • Offers intuitive action buttons (Add/Cancel)
  • Properly handles both confirmation and cancellation

The conditional rendering ensures the modal only appears when needed.


108-113: Proper dual-modal rendering structure.

The render method correctly returns both modals wrapped in a React fragment, allowing for the seamless transition between the main dialog and the warning modal. This approach maintains clean component structure while supporting the enhanced workflow.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 9, 2025
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

🧹 Nitpick comments (1)
src/dashboard/Data/Config/AddArrayEntryDialog.react.js (1)

51-59: Handle undefined values explicitly

The getType method correctly handles arrays and null, but consider explicitly handling undefined values for clarity.

 getType(value) {
   if (Array.isArray(value)) {
     return 'array';
   }
   if (value === null) {
     return 'null';
   }
+  if (value === undefined) {
+    return 'undefined';
+  }
   return typeof value;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dddcf8d and 88d4ef2.

📒 Files selected for processing (1)
  • src/dashboard/Data/Config/AddArrayEntryDialog.react.js (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/dashboard/Data/Config/AddArrayEntryDialog.react.js (1)
Learnt from: mtrezza
PR: parse-community/parse-dashboard#2828
File: src/dashboard/Data/Browser/Browser.react.js:1605-1607
Timestamp: 2025-05-27T12:09:47.644Z
Learning: In script execution dialogs in Parse Dashboard (specifically the `confirmExecuteScriptRows` method in `src/dashboard/Data/Browser/Browser.react.js`), individual `setState` calls to update `processedScripts` counter should be kept as-is rather than batched, because this provides real-time progress feedback to users in the dialog UI.
⏰ 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). (1)
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (7)
src/dashboard/Data/Config/AddArrayEntryDialog.react.js (7)

13-13: LGTM: Clean import addition

The Checkbox import is correctly added and used for the type mismatch confirmation feature.


18-23: LGTM: Well-structured state management

The state variables are appropriately named and serve clear purposes:

  • showMismatchRow: Controls warning visibility
  • mismatchConfirmed: Tracks user confirmation
  • parsedType: Stores the detected type for display

33-41: LGTM: Comprehensive validation logic

The validation correctly prevents confirmation when:

  1. Input is empty
  2. Type mismatch warning is shown but not confirmed

This ensures proper user flow and prevents accidental submissions.


61-87: LGTM: Robust confirmation flow with proper state management

The method implements a clear two-step confirmation process:

  1. Shows warning on first confirmation attempt when types mismatch
  2. Proceeds only after explicit user confirmation

The state reset logic ensures clean state for subsequent operations.


98-98: LGTM: Correct method binding

The confirm handler is properly bound to use the new handleConfirm method instead of directly calling onConfirm.


113-119: LGTM: Smart UX design for input changes

Resetting mismatch state when the input changes provides intuitive user experience - the warning disappears when the user modifies their input, allowing them to potentially resolve the type mismatch.


123-138: LGTM: Clear and informative mismatch warning UI

The conditional rendering provides:

  • Clear type information showing both previous and new types
  • Intuitive checkbox confirmation requirement
  • Proper state binding for user interaction

The description text effectively communicates the type mismatch to users.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 9, 2025
@mtrezza mtrezza changed the title Add type mismatch warning to AddArrayEntryDialog feat: Add type mismatch warning to Cloud Config parameter quick-add button Jul 9, 2025
@mtrezza mtrezza changed the title feat: Add type mismatch warning to Cloud Config parameter quick-add button feat: Add type mismatch warning to Cloud Config array parameter quick-add button Jul 9, 2025
@mtrezza mtrezza changed the title feat: Add type mismatch warning to Cloud Config array parameter quick-add button feat: Add type mismatch warning when quick-adding entry to Cloud Config array parameter Jul 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 9, 2025
@mtrezza mtrezza merged commit bb1837f into alpha Jul 9, 2025
11 checks passed
@mtrezza mtrezza deleted the codex/add-type-mismatch-warning-on-config-page branch July 9, 2025 01:00
parseplatformorg pushed a commit that referenced this pull request Jul 9, 2025
# [7.3.0-alpha.3](7.3.0-alpha.2...7.3.0-alpha.3) (2025-07-09)

### Features

* Add type mismatch warning when quick-adding entry to Cloud Config array parameter ([#2875](#2875)) ([bb1837f](bb1837f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.3.0-alpha.3

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released-alpha Released as alpha version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants