Skip to content

Commit aee5d00

Browse files
sarg3ntclaude
andcommitted
fix: redirect to plugins page when no plugins enabled on empty dashboard
When an empty editable dashboard is viewed, check if any plugins are enabled for the current server. If none are enabled, redirect to the plugins settings page so the user can enable plugins first (which registers widgets). Only redirect to the dashboard editor with the widget palette open when plugins are already enabled. Closes #6 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e2e9e97 commit aee5d00

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

gearbox/internal/framework/handler/dashboard.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,38 @@ func (h *DashboardHandler) ViewDashboard(w http.ResponseWriter, r *http.Request)
120120
return
121121
}
122122

123-
// If dashboard is empty and editable, redirect to edit mode with palette open
123+
// If dashboard is empty and editable, guide the user to set up their dashboard
124124
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
125155
http.Redirect(w, r, "/dashboards/"+slug+"/edit?open_palette=1", http.StatusSeeOther)
126156
return
127157
}

0 commit comments

Comments
 (0)