Skip to content

Commit

Permalink
wip: setup settings component
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Oct 29, 2024
1 parent 6d3b3c5 commit c5d56fa
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 54 deletions.
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func (s *WebSrv) Start(ctx context.Context, ready server.ReadyFunc, run server.R
}

userHandler := handlers.NewUserHandler()
settingsHandlers := handlers.NewSettingsHandler()

handlers := handlers.New(store)

Expand Down Expand Up @@ -302,7 +303,7 @@ func (s *WebSrv) Start(ctx context.Context, ready server.ReadyFunc, run server.R
app.Get("/me", handlers.Me())

// Settings ...
app.Get("/settings", handlers.ShowSettings())
app.Get("/settings", htmx.NewCompFuncHandler(settingsHandlers.ListSettings, compFuncConfig))

// Preview ...
app.Post("/preview", handlers.Preview())
Expand Down
8 changes: 0 additions & 8 deletions internal/adapters/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/zeiss/service-lens/internal/controllers/me"
"github.com/zeiss/service-lens/internal/controllers/previews"
"github.com/zeiss/service-lens/internal/controllers/profiles"
"github.com/zeiss/service-lens/internal/controllers/settings"
"github.com/zeiss/service-lens/internal/controllers/tags"
"github.com/zeiss/service-lens/internal/controllers/templates"
"github.com/zeiss/service-lens/internal/controllers/workflows"
Expand Down Expand Up @@ -270,13 +269,6 @@ func (a *handlers) DeleteLens() fiber.Handler {
})
}

// ShowSettings ...
func (a *handlers) ShowSettings() fiber.Handler {
return htmx.NewHxControllerHandler(func() htmx.Controller {
return settings.NewSettingsShowController(a.store)
})
}

// NewWorkload ...
func (a *handlers) NewWorkload() fiber.Handler {
return htmx.NewHxControllerHandler(func() htmx.Controller {
Expand Down
46 changes: 46 additions & 0 deletions internal/adapters/handlers/settings_handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package handlers

import (
"github.com/gofiber/fiber/v2"
htmx "github.com/zeiss/fiber-htmx"
"github.com/zeiss/fiber-htmx/components/cards"
"github.com/zeiss/fiber-htmx/components/tailwind"
reload "github.com/zeiss/fiber-reload"
"github.com/zeiss/service-lens/internal/components"
)

type SettingsHandler struct{}

func NewSettingsHandler() *SettingsHandler {
return &SettingsHandler{}
}

func (h *SettingsHandler) ListSettings(c *fiber.Ctx) (htmx.Node, error) {
return components.DefaultLayout(
components.DefaultLayoutProps{
Path: c.Path(),
// User: d.Session().User,
Development: reload.IsDevelopment(c.UserContext()),
},
func() htmx.Node {
return htmx.Fragment(
cards.CardBordered(
cards.CardProps{
ClassNames: htmx.Merge(
htmx.ClassNames{
tailwind.M2: true,
},
),
},
cards.Body(
cards.BodyProps{},
cards.Title(
cards.TitleProps{},
htmx.Text("Settings"),
),
),
),
)
},
), nil
}
43 changes: 0 additions & 43 deletions internal/controllers/settings/show.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/ports/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ type Handlers interface {
UpdateLens() fiber.Handler
// DeleteLens ...
DeleteLens() fiber.Handler
// ShowSettings ...
ShowSettings() fiber.Handler
// CreateWorkload ...
CreateWorkload() fiber.Handler
// ListWorkloads ...
Expand Down

0 comments on commit c5d56fa

Please sign in to comment.