Skip to content

Commit 6f5ef33

Browse files
sarg3ntclaude
andcommitted
fix: redirect to plugins page after server creation, add Done button
After creating a new server, redirect to the plugins settings page (instead of the boxes list) so the user can enable plugins immediately. Add a "Done" button to the plugins page that navigates to the home dashboard. Remove the empty-dashboard redirect logic from ViewDashboard since the user now goes through plugin setup first. Closes #6 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent aee5d00 commit 6f5ef33

3 files changed

Lines changed: 13 additions & 38 deletions

File tree

gearbox/internal/framework/handler/dashboard.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -120,42 +120,6 @@ func (h *DashboardHandler) ViewDashboard(w http.ResponseWriter, r *http.Request)
120120
return
121121
}
122122

123-
// If dashboard is empty and editable, guide the user to set up their dashboard
124-
if dash.Editable && len(dash.Widgets) == 0 {
125-
// Determine the current server ID to check plugin state
126-
boxID := h.boxID
127-
if boxID == "" {
128-
// Fall back to the first enabled server
129-
if servers, err := h.db.GetEnabledBoxes(); err == nil && len(servers) > 0 {
130-
boxID = servers[0].BoxID
131-
}
132-
}
133-
134-
// Check if any plugins are enabled for this server.
135-
// If not, send them to the plugins page first so they can enable plugins
136-
// (which registers widgets they can then add to dashboards).
137-
if boxID != "" {
138-
enabledPlugins, err := h.db.GetEnabledPlugins(boxID)
139-
if err == nil {
140-
hasEnabledPlugin := false
141-
for _, enabled := range enabledPlugins {
142-
if enabled {
143-
hasEnabledPlugin = true
144-
break
145-
}
146-
}
147-
if !hasEnabledPlugin {
148-
http.Redirect(w, r, "/settings/plugins", http.StatusSeeOther)
149-
return
150-
}
151-
}
152-
}
153-
154-
// Plugins are enabled, redirect to edit mode with widget palette open
155-
http.Redirect(w, r, "/dashboards/"+slug+"/edit?open_palette=1", http.StatusSeeOther)
156-
return
157-
}
158-
159123
// Render dashboard
160124
content, err := h.renderer.Render(r.Context(), dash, h.boxID, h.userID)
161125
if err != nil {

gearbox/internal/framework/handler/haproxy_config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"net/http"
7+
"net/url"
78
"strconv"
89
"strings"
910

@@ -136,8 +137,8 @@ func (h *Handler) HAProxyBoxCreatePost(w http.ResponseWriter, r *http.Request) {
136137
}
137138
}
138139

139-
// Redirect to servers list page
140-
http.Redirect(w, r, "/settings/boxes", http.StatusSeeOther)
140+
// Redirect to plugins page so user can enable plugins for this new server
141+
http.Redirect(w, r, "/settings/plugins?server="+url.QueryEscape(server.BoxID), http.StatusSeeOther)
141142
}
142143

143144
// HAProxyBoxEditPage shows the form for editing a server.

gearbox/internal/framework/templates/pages/plugins.templ

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ templ PluginsPage(user *models.User, servers []models.BoxConfig, currentServerID
7272
}
7373
</div>
7474

75+
<!-- Done button to navigate to main dashboard -->
76+
<div class="mt-8 flex justify-end">
77+
<a
78+
href="/"
79+
class="px-6 py-2.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors"
80+
>
81+
Done
82+
</a>
83+
</div>
84+
7585
<script src="/static/js/plugins/plugins-page.js"></script>
7686
</div>
7787
}

0 commit comments

Comments
 (0)