Refactor comment widget to use config map context#185
Conversation
Signed-off-by: Ryan Wang <i@ryanc.cc>
Signed-off-by: Ryan Wang <i@ryanc.cc>
Signed-off-by: Ryan Wang <i@ryanc.cc>
There was a problem hiding this comment.
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 |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #184
Changed to frontend fetching comment widget configuration via API to simplify the code.