Skip to content

Refactor comment widget to use config map context#185

Merged
f2c-ci-robot[bot] merged 7 commits into
halo-dev:mainfrom
ruibaby:refactor/config
Aug 7, 2025
Merged

Refactor comment widget to use config map context#185
f2c-ci-robot[bot] merged 7 commits into
halo-dev:mainfrom
ruibaby:refactor/config

Conversation

@ruibaby
Copy link
Copy Markdown
Member

@ruibaby ruibaby commented Aug 6, 2025

Fixes #184

Changed to frontend fetching comment widget configuration via API to simplify the code.

None

@f2c-ci-robot f2c-ci-robot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Aug 6, 2025
@f2c-ci-robot f2c-ci-robot Bot requested review from JohnNiang and guqing August 6, 2025 15:43
ruibaby added 5 commits August 7, 2025 10:52
Signed-off-by: Ryan Wang <i@ryanc.cc>
Signed-off-by: Ryan Wang <i@ryanc.cc>
Signed-off-by: Ryan Wang <i@ryanc.cc>
Signed-off-by: Ryan Wang <i@ryanc.cc>
@ruibaby ruibaby changed the title WIP: Refactor comment widget to use config map context Refactor comment widget to use config map context Aug 7, 2025
@f2c-ci-robot f2c-ci-robot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 7, 2025
@ruibaby ruibaby requested a review from Copilot August 7, 2025 04:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the comment widget to use a configuration map context instead of passing configuration values through component properties. The refactor simplifies the code by having the frontend fetch configuration via API rather than having it passed through from the backend template.

  • Introduces a new config endpoint to expose comment widget configuration via API
  • Removes hardcoded configuration properties from component interfaces and templates
  • Creates a centralized configuration context system for better state management

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/resources/extensions/role-templates.yaml Adds API permissions for the new config endpoint
src/main/java/run/halo/comment/widget/DefaultCommentWidget.java Removes server-side configuration injection from template rendering
src/main/java/run/halo/comment/widget/ConfigEndpoint.java New endpoint to serve configuration data from ConfigMap
packages/widget/src/index.ts Removes configuration properties from widget initialization interface
packages/comment-widget/src/types/index.ts Defines TypeScript interfaces for configuration data structure
packages/comment-widget/src/index.ts Adds CommentList export and reorders imports
packages/comment-widget/src/context/index.ts Replaces individual config contexts with unified configMapDataContext
packages/comment-widget/src/comment-widget.ts Refactors to fetch config via API and delegates comment list management
packages/comment-widget/src/comment-replies.ts Updates to use configuration from context instead of individual properties
packages/comment-widget/src/comment-list.ts New component extracted from comment-widget for comment list management
packages/comment-widget/src/comment-item.ts Updates to use configuration context and fixes formatting
packages/comment-widget/src/base-form.ts Updates captcha logic to use configuration context and improves formatting
packages/comment-widget/package.json Adds localization build scripts

Comment thread src/main/java/run/halo/comment/widget/ConfigEndpoint.java
Comment thread packages/comment-widget/src/base-form.ts
Signed-off-by: Ryan Wang <i@ryanc.cc>
Comment thread src/main/java/run/halo/comment/widget/ConfigEndpoint.java
Copy link
Copy Markdown
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

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

/lgtm

@f2c-ci-robot f2c-ci-robot Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2025
@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Aug 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 7, 2025
@f2c-ci-robot f2c-ci-robot Bot merged commit b4a419d into halo-dev:main Aug 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a public endpoint to expose configuration

3 participants