-
-
Notifications
You must be signed in to change notification settings - Fork 806
Add alert and confirm modal system for tsunami apps #2484
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
abe38c9
Initial plan
Copilot 78e1f7f
Implement alert and confirm modal system for tsunami
Copilot 6202fc2
Add modaltest demo app to demonstrate modal functionality
Copilot 660c9f2
Final review and cleanup
Copilot 015d9f0
Revert unintended changes to demo app go.mod/go.sum files
Copilot 5a6f8cc
updates to modal style, add inline tw classes
sawka db42eaf
Close modals on Resync flag instead of SSE disconnect
Copilot b2e2eb9
fix comment
sawka 74b413e
fix locking for modalmap in clientimpl
sawka 6e5240e
modalids should just be uuids. add panic handlers. fix weird double…
sawka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "github.com/wavetermdev/waveterm/tsunami/app" | ||
| "github.com/wavetermdev/waveterm/tsunami/vdom" | ||
| ) | ||
|
|
||
| const AppTitle = "Modal Test (Tsunami Demo)" | ||
| const AppShortDesc = "Test alert and confirm modals in Tsunami" | ||
|
|
||
| var App = app.DefineComponent("App", func(_ struct{}) any { | ||
| // State to track modal results | ||
| alertResult := app.UseLocal("") | ||
| confirmResult := app.UseLocal("") | ||
|
|
||
| // Hook for alert modal | ||
| alertOpen, triggerAlert := app.UseAlertModal() | ||
|
|
||
| // Hook for confirm modal | ||
| confirmOpen, triggerConfirm := app.UseConfirmModal() | ||
|
|
||
| // Event handlers for alert | ||
| handleShowAlert := func() { | ||
| triggerAlert(app.ModalConfig{ | ||
| Icon: "⚠️", | ||
| Title: "Alert Message", | ||
| Text: "This is an alert modal. Click OK to dismiss.", | ||
| OnClose: func() { | ||
| alertResult.Set("Alert dismissed") | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| handleShowAlertSimple := func() { | ||
| triggerAlert(app.ModalConfig{ | ||
| Title: "Simple Alert", | ||
| Text: "This alert has no icon and custom OK text.", | ||
| OkText: "Got it!", | ||
| OnClose: func() { | ||
| alertResult.Set("Simple alert dismissed") | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| // Event handlers for confirm | ||
| handleShowConfirm := func() { | ||
| triggerConfirm(app.ModalConfig{ | ||
| Icon: "❓", | ||
| Title: "Confirm Action", | ||
| Text: "Do you want to proceed with this action?", | ||
| OnResult: func(confirmed bool) { | ||
| if confirmed { | ||
| confirmResult.Set("User confirmed the action") | ||
| } else { | ||
| confirmResult.Set("User cancelled the action") | ||
| } | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| handleShowConfirmCustom := func() { | ||
| triggerConfirm(app.ModalConfig{ | ||
| Icon: "🗑️", | ||
| Title: "Delete Item", | ||
| Text: "Are you sure you want to delete this item? This action cannot be undone.", | ||
| OkText: "Delete", | ||
| CancelText: "Keep", | ||
| OnResult: func(confirmed bool) { | ||
| if confirmed { | ||
| confirmResult.Set("Item deleted") | ||
| } else { | ||
| confirmResult.Set("Item kept") | ||
| } | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| // Read state values | ||
| currentAlertResult := alertResult.Get() | ||
| currentConfirmResult := confirmResult.Get() | ||
|
|
||
| return vdom.H("div", map[string]any{ | ||
| "className": "max-w-4xl mx-auto p-8", | ||
| }, | ||
| vdom.H("h1", map[string]any{ | ||
| "className": "text-3xl font-bold mb-6 text-white", | ||
| }, "Tsunami Modal Test"), | ||
|
|
||
| // Alert Modal Section | ||
| vdom.H("div", map[string]any{ | ||
| "className": "mb-8 p-6 bg-gray-800 rounded-lg border border-gray-700", | ||
| }, | ||
| vdom.H("h2", map[string]any{ | ||
| "className": "text-2xl font-semibold mb-4 text-white", | ||
| }, "Alert Modals"), | ||
| vdom.H("div", map[string]any{ | ||
| "className": "flex gap-4 mb-4", | ||
| }, | ||
| vdom.H("button", map[string]any{ | ||
| "className": "px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed", | ||
| "onClick": handleShowAlert, | ||
| "disabled": alertOpen, | ||
| }, "Show Alert with Icon"), | ||
| vdom.H("button", map[string]any{ | ||
| "className": "px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed", | ||
| "onClick": handleShowAlertSimple, | ||
| "disabled": alertOpen, | ||
| }, "Show Simple Alert"), | ||
| ), | ||
| vdom.If(currentAlertResult != "", vdom.H("div", map[string]any{ | ||
| "className": "mt-4 p-3 bg-gray-700 rounded text-gray-200", | ||
| }, "Result: ", currentAlertResult)), | ||
| ), | ||
|
|
||
| // Confirm Modal Section | ||
| vdom.H("div", map[string]any{ | ||
| "className": "mb-8 p-6 bg-gray-800 rounded-lg border border-gray-700", | ||
| }, | ||
| vdom.H("h2", map[string]any{ | ||
| "className": "text-2xl font-semibold mb-4 text-white", | ||
| }, "Confirm Modals"), | ||
| vdom.H("div", map[string]any{ | ||
| "className": "flex gap-4 mb-4", | ||
| }, | ||
| vdom.H("button", map[string]any{ | ||
| "className": "px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed", | ||
| "onClick": handleShowConfirm, | ||
| "disabled": confirmOpen, | ||
| }, "Show Confirm Modal"), | ||
| vdom.H("button", map[string]any{ | ||
| "className": "px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed", | ||
| "onClick": handleShowConfirmCustom, | ||
| "disabled": confirmOpen, | ||
| }, "Show Delete Confirm"), | ||
| ), | ||
| vdom.If(currentConfirmResult != "", vdom.H("div", map[string]any{ | ||
| "className": "mt-4 p-3 bg-gray-700 rounded text-gray-200", | ||
| }, "Result: ", currentConfirmResult)), | ||
| ), | ||
|
|
||
| // Status info | ||
| vdom.H("div", map[string]any{ | ||
| "className": "p-6 bg-gray-800 rounded-lg border border-gray-700", | ||
| }, | ||
| vdom.H("h2", map[string]any{ | ||
| "className": "text-2xl font-semibold mb-4 text-white", | ||
| }, "Modal Status"), | ||
| vdom.H("div", map[string]any{ | ||
| "className": "text-gray-300", | ||
| }, | ||
| vdom.H("div", nil, "Alert Modal Open: ", vdom.IfElse(alertOpen, "Yes", "No")), | ||
| vdom.H("div", nil, "Confirm Modal Open: ", vdom.IfElse(confirmOpen, "Yes", "No")), | ||
| ), | ||
| ), | ||
| ) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module github.com/wavetermdev/waveterm/tsunami/demo/modaltest | ||
|
|
||
| go 1.24.6 | ||
|
|
||
| require github.com/wavetermdev/waveterm/tsunami v0.0.0-00010101000000-000000000000 | ||
|
|
||
| require ( | ||
| github.com/google/uuid v1.6.0 // indirect | ||
| github.com/outrigdev/goid v0.3.0 // indirect | ||
| ) | ||
|
|
||
| replace github.com/wavetermdev/waveterm/tsunami => /Users/mike/work/waveterm/tsunami | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | ||
| github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
| github.com/outrigdev/goid v0.3.0 h1:t/otQD3EXc45cLtQVPUnNgEyRaTQA4cPeu3qVcrsIws= | ||
| github.com/outrigdev/goid v0.3.0/go.mod h1:hEH7f27ypN/GHWt/7gvkRoFYR0LZizfUBIAbak4neVE= |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace directive uses hardcoded absolute path that breaks portability.
The replace directive references
/Users/mike/work/waveterm/tsunami, which is specific to one developer's machine. This will fail on other machines and in CI/CD pipelines.Use a relative path instead:
Alternatively, if the repository uses Go workspaces (
go.workat the repository root), consider removing this replace directive and relying on the workspace configuration instead.📝 Committable suggestion
🤖 Prompt for AI Agents