Skip to content

Conversation

zhangshanwen
Copy link
Contributor

@zhangshanwen zhangshanwen commented Sep 28, 2025

Updated ContainerBuilder's firstOrCreate method to accept a web.EventContext and use the model's Saver for object creation, ensuring proper context and transaction handling. Added ParamContainerCreate constant. Updated dependencies in gentool/go.mod and go.sum.


Note

Use ctx-aware Saver to create demo containers and propagate DB tx via context; add ParamContainerCreate; refresh gentool indirect deps.

  • Page Builder:
    • Demo container creation: ContainerBuilder.firstOrCreate now accepts ctx and uses mb.Editing().Creating().Saver instead of tx.Create, setting gorm2op.CtxKeyDB in context and flagging ParamContainerCreate in the request.
    • Call sites: Builder.firstOrCreateDemoContainers passes ctx to con.firstOrCreate.
    • Params: Add ParamContainerCreate constant in editor.go.
  • Dependencies (gentool):
    • Bump indirect versions: go-spew, go-cmp, go-difflib, testify; update go.sum.

Written by Cursor Bugbot for commit a4ed1f7. This will update automatically on new commits. Configure here.

Updated ContainerBuilder's firstOrCreate method to accept a web.EventContext and use the model's Saver for object creation, ensuring proper context and transaction handling. Added ParamContainerCreate constant. Updated dependencies in gentool/go.mod and go.sum.
Copy link

deepsource-io bot commented Sep 28, 2025

Here's the code health analysis summary for commits 2ecd7da..16f6fdb. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Go LogoGo✅ Success
🎯 53 occurences resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

cursor[bot]

This comment was marked as outdated.

Copy link

codecov bot commented Sep 28, 2025

Codecov Report

❌ Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pagebuilder/builder.go 89.28% 0 Missing and 3 partials ⚠️
Files with missing lines Coverage Δ
login/profile.go 71.76% <100.00%> (ø)
pagebuilder/editor.go 93.67% <ø> (ø)
pagebuilder/messages.go 33.33% <ø> (ø)
pagebuilder/builder.go 82.80% <89.28%> (+0.22%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@molon molon requested a review from Copilot September 28, 2025 10:52
Copy link

@Copilot 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 container creation to use web context and model savers instead of direct database transactions. The changes improve transaction handling by propagating database context through the web framework and using model-specific savers for object creation.

  • Updates ContainerBuilder's firstOrCreate method to accept web.EventContext and use model savers
  • Adds ParamContainerCreate constant for tracking container creation requests
  • Updates indirect dependencies in gentool module

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
utils/testflow/gentool/go.mod Updates indirect dependency versions for testing libraries
pagebuilder/editor.go Adds ParamContainerCreate constant
pagebuilder/builder.go Refactors container creation to use context-aware savers and proper transaction handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

ctx.R.Form.Set(ParamContainerCreate, "1")
return db.Transaction(func(tx *gorm.DB) (vErr error) {
ctx.WithContextValue(gorm2op.CtxKeyDB{}, tx)
defer ctx.WithContextValue(gorm2op.CtxKeyDB{}, nil)
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The context value is being set and then immediately cleared in the defer statement, which means the database transaction will not be available to the saver function. The defer should be moved after the saver calls or the context clearing should be removed.

Suggested change
defer ctx.WithContextValue(gorm2op.CtxKeyDB{}, nil)

Copilot uses AI. Check for mistakes.


if len(cons) == 0 {
if vErr = tx.Create(obj).Error; vErr != nil {
if vErr = saver(obj, "", ctx); vErr != nil {
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

[nitpick] The empty string parameter passed to saver is unclear. Consider using a named constant or adding a comment to explain what this parameter represents.

Copilot uses AI. Check for mistakes.

Introduces a new i18n message for shared container modification warnings and displays a tooltip when editing shared containers in the page builder. Also refines device toggle logic to check for draft status before triggering events.
@theplant-ci theplant-ci added size/L and removed size/M labels Oct 10, 2025
zhangshanwen and others added 3 commits October 10, 2025 16:09
Reorganized the tooltip and icon structure for shared containers to improve alignment and layout. The icon and content are now wrapped in a flex container for better visual consistency.
This commit fixes the style issues introduced in d910c8f according to the output
from Gofumpt.

Details: #1031
Replaces the use of the isSharedContainer param with the con.Shared field to determine if the container is shared when rendering the editing title tooltip.
zhangshanwen added a commit that referenced this pull request Oct 17, 2025
* style: format code with Gofumpt

This commit fixes the style issues introduced in d910c8f according to the output
from Gofumpt.

Details: #1031

* Use container Shared field in editing title logic

Replaces the use of the isSharedContainer param with the con.Shared field to determine if the container is shared when rendering the editing title tooltip.

---------

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
@zhangshanwen zhangshanwen merged commit 15291ed into main Oct 20, 2025
11 checks passed
@zhangshanwen zhangshanwen deleted the fix-democontainer-saver branch October 20, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants