Skip to content

feat: Add confirmation dialog before saving a Cloud Config parameter that has been modified since editing it #2770

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 12 commits into from
May 24, 2025

Conversation

dblythy
Copy link
Member

@dblythy dblythy commented Apr 27, 2025

New Pull Request Checklist

Issue Description

Closes: #2567

Approach

TODOs before merging

  • Add tests
  • Add changes to documentation (guides, repository pages, in-code descriptions)

Summary by CodeRabbit

  • New Features

    • Added a confirmation dialog to warn users when saving parameters modified by others, allowing review before overwriting.
    • Introduced loading state overlay in configuration dialogs to improve user feedback during operations.
  • Bug Fixes

    • Fixed a missing closing brace in the .noScroll CSS class for correct styling.
  • Style

    • Added a new .confirmConfig CSS class to improve modal layout.

Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: confirmation on config param update feat: Confirmation on config param update Apr 27, 2025
Copy link

parse-github-assistant bot commented Apr 27, 2025

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Apr 27, 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

uffizzi-cloud bot commented Apr 27, 2025

Uffizzi Ephemeral Environment deployment-63191

⌚ Updated Apr 27, 2025, 10:30 UTC

☁️ https://app.uffizzi.com/github.com/parse-community/parse-dashboard/pull/2770

📄 View Application Logs etc.

What is Uffizzi? Learn more

@dblythy dblythy requested a review from a team April 27, 2025 10:48
Copy link

coderabbitai bot commented Apr 28, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

"""

Walkthrough

The changes introduce concurrency conflict detection when saving configuration parameters in the dashboard. The Config React component now fetches the latest parameter value from the server before saving. If the value has changed since it was last loaded, a confirmation modal prompts the user before overwriting. This is achieved by updating the saveParam method to perform the check and by adding a modal dialog for user confirmation. Additionally, a missing closing brace was fixed in the .noScroll CSS class, and a new .confirmConfig class was added. The ConfigDialog component was also updated to wrap its content in a LoaderContainer to handle loading states.

Changes

File(s) Change Summary
src/dashboard/Data/Config/Config.react.js Added concurrency check in saveParam, introduced confirmation modal, updated methods to async, and added state.
src/dashboard/Data/Config/ConfigDialog.react.js Added componentDidUpdate to sync props to state, wrapped modal content in LoaderContainer, updated disabled prop.
src/dashboard/Data/Browser/Browser.scss Fixed missing closing brace for .noScroll and added new .confirmConfig class with padding.
package.json Added new dependency fast-deep-equal version 3.1.3 for deep equality checks.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConfigComponent
    participant Server
    participant Modal

    User->>ConfigComponent: Initiate saveParam(name, value)
    ConfigComponent->>Server: Fetch latest config data
    Server-->>ConfigComponent: Return latest config data
    ConfigComponent->>ConfigComponent: Compare cached vs latest value
    alt Values differ and not override
        ConfigComponent->>Modal: Show confirmation dialog
        Modal->>User: Prompt to confirm overwrite
        User->>Modal: Click "Continue"
        Modal->>ConfigComponent: Confirm overwrite
        ConfigComponent->>ConfigComponent: Call saveParam with override
        ConfigComponent->>Server: Save parameter (override)
    else Values same or override
        ConfigComponent->>Server: Save parameter
    end
    Server-->>ConfigComponent: Save response
Loading

Assessment against linked issues

Objective Addressed Explanation
Reload Cloud Config param before updating and warn user if value has changed (#2567)

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error code ERR_SSL_WRONG_VERSION_NUMBER
npm error errno ERR_SSL_WRONG_VERSION_NUMBER
npm error request to https://10.0.0.28:4873/npm/-/npm-10.9.2.tgz failed, reason: C0CC8A01D47F0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:354:
npm error
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-01T15_16_18_443Z-debug-0.log


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 479447f and d620bec.

📒 Files selected for processing (1)
  • src/dashboard/Data/Config/Config.react.js (8 hunks)

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 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

@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 (4)
src/dashboard/Data/Browser/Browser.scss (1)

275-276: Fix the spelling error in the class name

There's a typo in the class name .confimConfig - it's missing the letter "r" and should be .confirmConfig.

-.confimConfig {
+.confirmConfig {
  padding: 10px 20px;
}
src/dashboard/Data/Config/Config.react.js (3)

108-130: Fix the class name reference to match the CSS

The implementation of the confirmation modal looks good, but there's a typo in the class name. The CSS class is misspelled as .confimConfig (missing an "r"), and the same typo is reflected here.

-          <div className={[browserStyles.confimConfig]}>
+          <div className={[browserStyles.confirmConfig]}>

This change should be made after fixing the class name in the CSS file.


274-294: Great implementation of concurrency conflict detection

The async saveParam implementation with concurrency checking is a valuable improvement that prevents accidental overwrites when multiple users edit the same parameter.

Consider the following improvements:

  1. Add error handling for the fetch operation
  2. Clean up this.confirmData after it's used to prevent memory leaks
 async saveParam({ name, value, type, masterKeyOnly, override }) {
   const cachedParams = this.cacheData.get('params');
   const cachedValue = cachedParams.get(name);

-  await this.props.config.dispatch(ActionTypes.FETCH);
+  try {
+    await this.props.config.dispatch(ActionTypes.FETCH);
+  } catch (error) {
+    // Handle fetch error gracefully
+    console.error('Failed to fetch latest config data:', error);
+    // Continue with save operation as we can't verify concurrency
+  }
   const fetchedParams = this.props.config.data.get('params');

   if (cachedValue !== fetchedParams.get(name) && !override) {
     this.setState({
       confirmModalOpen: true,
       modalOpen: false,
     });
     this.confirmData = {
       name,
       value,
       type,
       masterKeyOnly,
     };
     return;
   }

And in the onConfirm handler for the modal:

 onConfirm={() => {
   this.setState({ confirmModalOpen: false });
   this.saveParam({
     ...this.confirmData,
     override: true,
   });
+  // Clean up confirmData after use
+  this.confirmData = null;
 }}

117-123: Clean up confirmData after use

To prevent potential memory leaks, clean up the confirmData property after it's used.

onConfirm={() => {
  this.setState({ confirmModalOpen: false });
  this.saveParam({
    ...this.confirmData,
    override: true,
  });
+  // Clean up confirmData after use
+  this.confirmData = null;
}}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bcce5c5 and 334e952.

📒 Files selected for processing (2)
  • src/dashboard/Data/Browser/Browser.scss (1 hunks)
  • src/dashboard/Data/Config/Config.react.js (5 hunks)
🔇 Additional comments (4)
src/dashboard/Data/Browser/Browser.scss (1)

271-273: Good fix for the missing closing brace

Adding the missing closing brace for the .noScroll class fixes a CSS syntax error that could have caused styling issues.

src/dashboard/Data/Config/Config.react.js (3)

42-42: LGTM: Added state variable for modal control

Good addition of the confirmModalOpen state to control the visibility of the confirmation modal.


63-63: LGTM: Caching data for concurrency checks

Good approach to cache the config data for later comparison when saving parameters.


281-293:

❌ Incorrect review comment

Verify behavior when the parameter is being created

For a new parameter that doesn't exist yet, the cachedValue and fetchedParams.get(name) might both be undefined, potentially bypassing the conflict detection. Consider adding a check to handle this case.


🏁 Script executed:

#!/bin/bash
# Check if there's specific handling for new parameters in the codebase

echo "Checking how new parameters are created and saved..."
rg -A 5 -B 5 'createParameter|Adding.*parameter' --type js

echo "Looking for other saveParam calls to understand parameter creation flow..."
rg 'saveParam\(' --type js

echo "Examining whether the equality check handles undefined values correctly..."
rg 'cachedValue.*!==.*fetchedParams' --type js

Length of output: 3825


🏁 Script executed:

#!/bin/bash
sed -n '200,360p' src/dashboard/Data/Config/Config.react.js

Length of output: 4998


🏁 Script executed:

#!/bin/bash
rg -n 'cacheData' src/dashboard/Data/Config/Config.react.js

Length of output: 177


No change needed for new parameter creation

The conflict check (cachedValue !== fetchedParams.get(name)) intentionally allows both values to be undefined, so creating a brand-new parameter proceeds without triggering the confirmation modal. Special-casing the “new parameter” scenario isn’t necessary.

Likely an incorrect or invalid review comment.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 28, 2025
Signed-off-by: Manuel <[email protected]>
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 29, 2025
@mtrezza mtrezza closed this Apr 29, 2025
@mtrezza mtrezza reopened this Apr 29, 2025
@mtrezza mtrezza changed the title feat: Confirmation on config param update feat: Add confirmation dialog before saving a Cloud Config parameter that has been modified since loading the parameter Apr 29, 2025
@mtrezza mtrezza changed the title feat: Add confirmation dialog before saving a Cloud Config parameter that has been modified since loading the parameter feat: Add confirmation dialog before saving a Cloud Config parameter that has been modified since loading it Apr 29, 2025
Copy link

uffizzi-cloud bot commented Apr 29, 2025

Uffizzi Ephemeral Environment deployment-63245

⌚ Updated Apr 29, 2025, 01:30 UTC

☁️ https://app.uffizzi.com/github.com/parse-community/parse-dashboard/pull/2770

📄 View Application Logs etc.

What is Uffizzi? Learn more

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

  • Shows dialog when editing in same dashboard instance:
    https://github.com/user-attachments/assets/c3a48989-4e78-4aa8-937b-1d00350499a4
  • The most likely user behavior when seeing the dialog will be to cancel, reload the page, investigate the current value and perhaps redo the edit. It's rather unlikely that a user will just continue, without even knowing what will be overwritten. Therefore I think we should fetch the parameter from the server right before showing the edit dialog. The issue is more likely to occur the longer the dashboard page has been open, e.g. in a separate browser tab. Reloading the param right before editing will mitigate the issue in the first place.
  • How does the UI handle long loading fetch - how does the user experience while waiting?
  • How is failed fetch handled? I assume a failed save shows an error message, does this also invoke that error message?

Signed-off-by: Manuel <[email protected]>
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 29, 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/Config.react.js (1)

278-278: Remove trailing whitespace.

There are trailing spaces on lines 278, 316, and 321 that should be removed to comply with the linting rules.

-      this.setState({ loading: true });
-      
+      this.setState({ loading: true });
       
-      this.setState({ modalOpen: false });
-      
+      this.setState({ modalOpen: false });
       
-      let transformedValue = value;
-      
+      let transformedValue = value;

Also applies to: 316-316, 321-321

🧰 Tools
🪛 GitHub Check: Lint

[failure] 278-278:
Trailing spaces not allowed

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between aea4d1f and 5f652a9.

📒 Files selected for processing (2)
  • src/dashboard/Data/Config/Config.react.js (6 hunks)
  • src/dashboard/Data/Config/ConfigDialog.react.js (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/dashboard/Data/Config/ConfigDialog.react.js (2)
src/components/Modal/Modal.react.js (1)
  • Modal (24-106)
src/components/LoaderContainer/LoaderContainer.react.js (1)
  • LoaderContainer (16-29)
src/dashboard/Data/Config/Config.react.js (1)
src/components/Modal/Modal.react.js (1)
  • Modal (24-106)
🪛 GitHub Check: Lint
src/dashboard/Data/Config/Config.react.js

[failure] 321-321:
Trailing spaces not allowed


[failure] 316-316:
Trailing spaces not allowed


[failure] 278-278:
Trailing spaces not allowed

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (12)
src/dashboard/Data/Config/ConfigDialog.react.js (3)

24-24: Good addition of LoaderContainer component.

Adding the LoaderContainer component allows for providing visual feedback to users during asynchronous operations, which improves the user experience.


226-299: Good code restructuring.

Extracting the dialog content into a separate variable improves code readability and maintainability while preparing for the LoaderContainer implementation.


301-317: Well implemented loading state in the modal.

The changes effectively integrate the loading state with the modal's disabled property and wrap the content with LoaderContainer. This provides users with visual feedback during the parameter saving process and concurrent modification checks.

src/dashboard/Data/Config/Config.react.js (9)

24-24: Appropriate Modal component import.

The Modal component import supports the new confirmation dialog functionality for handling concurrency conflicts.


42-42: Good addition of confirmModalOpen state.

This state variable properly manages the visibility of the confirmation dialog when concurrent modifications are detected.


63-63: Effective data caching implementation.

Caching the configuration data enables the detection of concurrent modifications by comparing cached values with freshly fetched ones.


96-96: Good addition of loading prop.

Passing the loading state to ConfigDialog enables proper visual feedback in the UI, complementing the LoaderContainer changes in ConfigDialog.react.js.


109-131: Well-implemented confirmation modal for concurrent modifications.

The modal provides clear information to users about the concurrency conflict and offers appropriate options to proceed or cancel. This prevents accidental overwrites of changes made by other users.


275-298: Excellent concurrency conflict detection implementation.

The updated saveParam method now properly checks for concurrent modifications by fetching the latest data and comparing it with the original value. This prevents unintentional overwrites and improves data integrity.

🧰 Tools
🪛 GitHub Check: Lint

[failure] 278-278:
Trailing spaces not allowed


300-314: Good implementation of data update after save.

The code properly updates both the server and the local cache after a successful save operation, maintaining data consistency.


317-355: Well-implemented config history management.

The code effectively manages the configuration history in localStorage, including proper handling of different value types (Date, File) and respecting the configurable history limit.

🧰 Tools
🪛 GitHub Check: Lint

[failure] 321-321:
Trailing spaces not allowed


356-362: Good error handling and loading state management.

The try-catch-finally block properly handles errors during the save operation and ensures the loading state is reset regardless of the outcome.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 22, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 22, 2025
@mtrezza mtrezza closed this May 24, 2025
@mtrezza mtrezza reopened this May 24, 2025
Copy link

uffizzi-cloud bot commented May 24, 2025

Uffizzi Ephemeral Environment deployment-63882

⌚ Updated May 24, 2025, 19:22 UTC

☁️ https://app.uffizzi.com/github.com/parse-community/parse-dashboard/pull/2770

📄 View Application Logs etc.

What is Uffizzi? Learn more

coderabbitai[bot]
coderabbitai bot previously approved these changes May 24, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 24, 2025
@mtrezza mtrezza merged commit adb9b5c into parse-community:alpha May 24, 2025
8 of 11 checks passed
@mtrezza mtrezza changed the title feat: Add confirmation dialog before saving a Cloud Config parameter that has been modified since loading it feat: Add confirmation dialog before saving a Cloud Config parameter that has been modified since editing it May 24, 2025
parseplatformorg pushed a commit that referenced this pull request May 24, 2025
# [7.2.0-alpha.5](7.2.0-alpha.4...7.2.0-alpha.5) (2025-05-24)

### Features

* Add confirmation dialog before saving a Cloud Config parameter that has been modified since editing it ([#2770](#2770)) ([adb9b5c](adb9b5c))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.2.0-alpha.5

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label May 24, 2025
parseplatformorg pushed a commit that referenced this pull request Jun 1, 2025
# [7.2.0](7.1.0...7.2.0) (2025-06-01)

### Bug Fixes

* Data browser not scrolling to top when changing filter while cell selected ([#2821](#2821)) ([c2527dc](c2527dc))
* Data browser table shows loading indicator when info panel is loading ([#2782](#2782)) ([da57e5e](da57e5e))
* Improperly aligned unfolding sub-items in context menu in data browser ([#2726](#2726)) ([3fed292](3fed292))
* Notifications fade out erratically when executing a script on large number of rows ([#2822](#2822)) ([3891381](3891381))
* Pagination does not reset to page 1 when clicking on class or filter ([#2798](#2798)) ([29d1447](29d1447))
* Saving new filter in data browser overwrites filters added in other dashboard instances ([#2769](#2769)) ([46bc154](46bc154))
* Selecting a saved filter in data browser may highlight a different filter ([#2783](#2783)) ([4c6e853](4c6e853))

### Features

* Add confirmation dialog before saving a Cloud Config parameter that has been modified since editing it ([#2770](#2770)) ([adb9b5c](adb9b5c))
* Add custom CSS styling for info panel items ([#2788](#2788)) ([f031e5d](f031e5d))
* Add relative date filter in data browser for date constraints relative to when the query is run ([#2736](#2736)) ([d9dfd69](d9dfd69))
* Add script execution on parallel batches with option `script.executionBatchSize` ([#2828](#2828)) ([cee8b8d](cee8b8d))
* Keyboard Enter key can be used to select item in data browser filter dialog field dropdown ([#2771](#2771)) ([dc14710](dc14710))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.2.0

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

Successfully merging this pull request may close these issues.

Reload Cloud Config param before updating
3 participants