Skip to content

fix the logical judgment for configuration addition, deletion, and modification.#5432

Merged
nobodyiam merged 4 commits into
apolloconfig:masterfrom
ForgeTerra:fix-2025071401
Jul 15, 2025
Merged

fix the logical judgment for configuration addition, deletion, and modification.#5432
nobodyiam merged 4 commits into
apolloconfig:masterfrom
ForgeTerra:fix-2025071401

Conversation

@ForgeTerra
Copy link
Copy Markdown
Contributor

@ForgeTerra ForgeTerra commented Jul 14, 2025

What's the purpose of this PR

您好,我在使用apollo的过程中,发现了一个问题,对于未发布的配置,增删改的判断有一些问题,做了下修复

Which issue(s) this PR fixes:

Fixes #

Brief changelog

一、复现步骤

1、原始数据如下:

image

2、修改第二条数据,value设为1; 删除第三条数据

image

可以看到第二条和第三条数据的标识出现了错误,发布页面也有同样的问题

image

二、问题修复
1、对配置的增删改判断逻辑做下了修改,效果如下:

image image

Summary by CodeRabbit

  • Bug Fixes

    • Improved accuracy of status labels for configuration items, clearly distinguishing between newly added and modified items in the namespace panel and release modal.
    • Updated release notes to document the correction in logical judgment for configuration changes.
  • New Features

    • Added explicit visual indication for newly added configuration items in relevant UI panels.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 14, 2025

Walkthrough

A new boolean field isNewlyAdded was introduced to the ItemBO class and is now set in the NamespaceService to explicitly identify newly added configuration items. AngularJS templates were updated to use this field for status labeling, and documentation was updated to reflect a related fix.

Changes

File(s) Change Summary
CHANGES.md Added a release note entry documenting a fix for logical judgment of configuration addition, deletion, and modification.
apollo-portal/src/main/java/com/.../entity/bo/ItemBO.java Added isNewlyAdded boolean field with getter and setter methods to the ItemBO class.
apollo-portal/src/main/java/com/.../service/NamespaceService.java Enhanced transformItem2BO to set the isNewlyAdded property based on item presence in release items.
apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html Updated AngularJS template logic to use isNewlyAdded for status labels in multiple table sections.
apollo-portal/src/main/resources/static/views/component/release-modal.html Updated label display logic to use isNewlyAdded for identifying new and modified items in the release modal.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend (AngularJS)
    participant Backend (NamespaceService)
    participant ItemBO

    User->>Frontend (AngularJS): View configuration items
    Frontend (AngularJS)->>Backend (NamespaceService): Request item list
    Backend (NamespaceService)->>ItemBO: Create ItemBO for each item
    Backend (NamespaceService)->>ItemBO: Set isNewlyAdded based on releaseItems
    Backend (NamespaceService)-->>Frontend (AngularJS): Return item list with isNewlyAdded flag
    Frontend (AngularJS)->>User: Display items with "New Added", "Modified", or "Deleted" labels based on flags
Loading

Suggested labels

lgtm

Suggested reviewers

  • nobodyiam

Poem

A bunny hopped through code today,
Marking what's new in a clever way.
With isNewlyAdded now in tow,
The UI labels clearly show—
What's fresh, what's changed, what's gone astray!
🐇✨


📜 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 e6af770 and 3880e25.

📒 Files selected for processing (2)
  • apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html (3 hunks)
  • apollo-portal/src/main/resources/static/views/component/release-modal.html (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apollo-portal/src/main/resources/static/views/component/release-modal.html
  • apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html
⏰ 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). (4)
  • GitHub Check: build (17)
  • GitHub Check: build (11)
  • GitHub Check: build (8)
  • GitHub Check: license

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 docstrings to generate docstrings for this 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.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 14, 2025
Copy link
Copy Markdown
Contributor

@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: 4

🔭 Outside diff range comments (1)
apollo-portal/src/main/resources/static/views/component/release-modal.html (1)

94-103: Ensure all status labels use the new isNewlyAdded flag

The branch‐tab template still uses the old config.isModified && !config.oldValue logic instead of the new config.isNewlyAdded flag. To keep UI behavior consistent, please update the label spans in:

• apollo-portal/src/main/resources/static/views/component/namespace-panel-branch-tab.html

Replace the existing status spans with:

<span class="label label-success"
      ng-if="config.isNewlyAdded"
      data-tooltip="tooltip" data-placement="bottom"
      title="{{'Component.Namespace.Branch.Body.NewAddedTips' | translate}}">
  {{'Component.Namespace.Branch.Body.Added'     | translate}}
</span>
<span class="label label-info"
      ng-if="config.isModified && !config.isNewlyAdded && !config.isDeleted"
      data-tooltip="tooltip" data-placement="bottom"
      title="{{'Component.Namespace.Branch.Body.ModifiedTips' | translate}}">
  {{'Component.Namespace.Branch.Body.Modified'  | translate}}
</span>
<span class="label label-danger"
      ng-if="config.isDeleted"
      data-tooltip="tooltip" data-placement="bottom"
      title="{{'Component.Namespace.Branch.Body.DeletedTips' | translate}}">
  {{'Component.Namespace.Branch.Body.Deleted'   | translate}}
</span>

After updating, please scan other HTML templates for any remaining config.isModified && !config.oldValue patterns and apply the same change.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca217f and e6af770.

📒 Files selected for processing (5)
  • CHANGES.md (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java (2 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java (1 hunks)
  • apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html (3 hunks)
  • apollo-portal/src/main/resources/static/views/component/release-modal.html (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). (1)
  • GitHub Check: build (8)
🔇 Additional comments (7)
CHANGES.md (1)

20-20: Changelog entry looks good.

The entry accurately documents the fix for configuration change logic and references the correct PR.

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java (1)

425-425: Excellent logic improvement for identifying newly added items.

The new approach using !releaseItems.containsKey(key) is more reliable than inferring from oldValue presence. This explicitly tracks whether an item is newly added versus modified, addressing the core issue described in the PR.

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java (2)

25-25: New field correctly added.

The isNewlyAdded field is properly positioned with other boolean flags and follows Java naming conventions.


69-75: Getter and setter methods properly implemented.

The methods follow standard Java bean conventions with correct naming and implementation for the boolean field.

apollo-portal/src/main/resources/static/views/component/release-modal.html (2)

94-96: Improved condition for "New Added" label.

Using the explicit config.isNewlyAdded flag is much clearer and more reliable than the previous implicit logic based on oldValue presence.


98-100: Enhanced condition for "Modified" label with proper exclusion.

The updated condition config.isModified && !config.isNewlyAdded && !config.isDeleted creates clear mutual exclusion between "New Added" and "Modified" labels, preventing incorrect labeling issues.

apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html (1)

355-357: Good refinement of “Modified” condition

Switching to !config.isNewlyAdded instead of the old config.oldValue check removes a brittle heuristic and aligns with the dedicated flag introduced on the backend.
Looks correct. Verify that isNewlyAdded is always accompanied by isModified to keep existing “No Publish” banner logic intact.

Copy link
Copy Markdown
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

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

LGTM

@nobodyiam nobodyiam merged commit 98df5e6 into apolloconfig:master Jul 15, 2025
8 checks passed
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 15, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2025
@nobodyiam nobodyiam added this to the 2.5.0 milestone Feb 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants