Skip to content

Modern Docker Management, Designed for Everyone

refactor: move settings/customize search to backend (#739)

Kyle Mendell4fe612e571aa
diff --git a/backend/internal/api/customize_handler.go b/backend/internal/api/customize_handler.go
new file mode 100644
index 000000000..62d61a1d5
--- /dev/null
+++ b/backend/internal/api/customize_handler.go
@@ -0,0 +1,55 @@
+package api
+
+import (
+ "net/http"
+ "strings"
+
+ "github.com/gin-gonic/gin"
+ "github.com/ofkm/arcane-backend/internal/dto"
+ "github.com/ofkm/arcane-backend/internal/middleware"
+ "github.com/ofkm/arcane-backend/internal/services"
+)
+
+type CustomizeHandler struct {
+ customizeSearchService *services.CustomizeSearchService
+}
+
+func NewCustomizeHandler(group *gin.RouterGroup, customizeSearchService *services.CustomizeSearchService, authMiddleware *middleware.AuthMiddleware) {
+ handler := &CustomizeHandler{
+ customizeSearchService: customizeSearchService,
+ }
+
+ // Expose customize search and categories endpoints under /api/customize
+ apiGroup := group.Group("/customize")
+ apiGroup.POST("/search", authMiddleware.WithAdminNotRequired().Add(), handler.Search)
+ apiGroup.GET("/categories", authMiddleware.WithAdminNotRequired().Add(), handler.GetCategories)
+}
+
+// Search delegates to the customize search service and returns relevance-scored results
+func (h *CustomizeHandler) Search(c *gin.Context) {
+ var req dto.CustomizeSearchRequest
+ if err := c.ShouldBindJSON(&req); err != nil {
+ c.JSON(http.StatusBadRequest, gin.H{
+ "success": false,
+ "data": dto.MessageDto{Message: "Invalid request format"},
+ })
+ return
+ }
+
+ if strings.TrimSpace(req.Query) == "" {
+ c.JSON(http.StatusBadRequest, gin.H{
+ "success": false,
+ "data": dto.MessageDto{Message: "Query parameter is required"},
+ })
+ return
+ }
+
+ results := h.customizeSearchService.Search(req.Query)
+ c.JSON(http.StatusOK, results)
+}
+
+// GetCategories returns all available customization categories with metadata
+func (h *CustomizeHandler) GetCategories(c *gin.Context) {
+ categories := h.customizeSearchService.GetCustomizeCategories()
+ c.JSON(http.StatusOK, categories)
+}
diff --git a/backend/internal/api/settings_handler.go b/backend/internal/api/settings_handler.go
index 3ee5ef441..3b13d0851 100644
--- a/backend/internal/api/settings_handler.go
+++ b/backend/internal/api/settings_handler.go
@@ -3,6 +3,7 @@ package api
import (
"net/http"
"strconv"
+ "strings"
"github.com/gin-gonic/gin"
"github.com/ofkm/arcane-backend/internal/config"
@@ -12,17 +13,55 @@ import (
)
type SettingsHandler struct {
- settingsService *services.SettingsService
+ settingsService *services.SettingsService
+ settingsSearchService *services.SettingsSearchService
}
-func NewSettingsHandler(group *gin.RouterGroup, settingsService *services.SettingsService, authMiddleware *middleware.AuthMiddleware) {
- handler := &SettingsHandler{settingsService: settingsService}
+func NewSettingsHandler(group *gin.RouterGroup, settingsService *services.SettingsService, settingsSearchService *services.SettingsSearchService, authMiddleware *middleware.AuthMiddleware) {
+ handler := &SettingsHandler{
+ settingsService: settingsService,
+ settingsSearchService: settingsSearchService,
+ }
apiGroup := group.Group("/environments/:id/settings")
apiGroup.GET("/public", handler.GetPublicSettings)
apiGroup.GET("", authMiddleware.WithAdminNotRequired().Add(), handler.GetSettings)
apiGroup.PUT("", authMiddleware.WithAdminRequired().Add(), handler.UpdateSettings)
+
+ // Also expose top-level settings search and categories endpoints under /api/settings
+ top := group.Group("/settings")
+ top.POST("/search", authMiddleware.WithAdminNotRequired().Add(), handler.Search)
+ top.GET("/categories", authMiddleware.WithAdminNotRequired().Add(), handler.GetCategories)
+}
+
+// Search delegates to the settings search service and returns relevance-scored results
+func (h *SettingsHandler) Search(c *gin.Context) {
+ var req dto.SettingsSearchRequest
+ if err := c.ShouldBindJSON(&req); err != nil {
+ c.JSON(http.StatusBadRequest, gin.H{
+ "success": false,
+ "data": dto.MessageDto{Message: "Invalid request format"},
+ })
+ return
+ }
+
+ if strings.TrimSpace(req.Query) == "" {
+ c.JSON(http.StatusBadRequest, gin.H{
+ "success": false,
+ "data": dto.MessageDto{Message: "Query parameter is required"},
+ })
+ return
+ }
+
+ results := h.settingsSearchService.Search(req.Query)
+ c.JSON(http.StatusOK, results)
+}
+
+// GetCategories returns all available settings categories with metadata
+func (h *SettingsHandler) GetCategories(c *gin.Context) {
+ categories := h.settingsSearchService.GetSettingsCategories()
+ c.JSON(http.StatusOK, categories)
}
func (h *SettingsHandler) GetSettings(c *gin.Context) {
@@ -36,7 +75,7 @@ func (h *SettingsHandler) GetSettings(c *gin.Context) {
_ = c.Error(err)
c.JSON(http.StatusInternalServerError, gin.H{
"success": false,
- "error": "Failed to map settings",
+ "data": dto.MessageDto{Message: "Failed to map settings"},
})
return
}
@@ -58,7 +97,7 @@ func (h *SettingsHandler) GetPublicSettings(c *gin.Context) {
_ = c.Error(err)
c.JSON(http.StatusInternalServerError, gin.H{
"success": false,
- "error": "Failed to map settings",
+ "data": dto.MessageDto{Message: "Failed to map settings"},
})
return
}
@@ -79,7 +118,7 @@ func (h *SettingsHandler) UpdateSettings(c *gin.Context) {
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"success": false,
- "error": "Invalid request format",
+ "data": dto.MessageDto{Message: "Invalid request format"},
})
return
}
@@ -90,7 +129,7 @@ func (h *SettingsHandler) UpdateSettings(c *gin.Context) {
req.AuthOidcConfig != nil {
c.JSON(http.StatusForbidden, gin.H{
"success": false,
- "error": "Authentication settings can only be updated from the main environment",
+ "data": dto.MessageDto{Message: "Authentication settings can only be updated from the main environment"},
})
return
}
@@ -100,7 +139,7 @@ func (h *SettingsHandler) UpdateSettings(c *gin.Context) {
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"success": false,
- "error": "Failed to update settings",
+ "data": dto.MessageDto{Message: "Failed to update settings"},
})
return
}
diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go
index fa33e54a1..f9c9ebcbd 100644
--- a/backend/internal/bootstrap/router_bootstrap.go
+++ b/backend/internal/bootstrap/router_bootstrap.go
@@ -105,7 +105,8 @@ func setupRouter(cfg *config.Config, appServices *Services) *gin.Engine {
api.NewSystemHandler(apiGroup, appServices.Docker, appServices.System, authMiddleware, cfg)
api.NewUpdaterHandler(apiGroup, appServices.Updater, authMiddleware)
api.NewVolumeHandler(apiGroup, appServices.Docker, appServices.Volume, authMiddleware)
- api.NewSettingsHandler(apiGroup, appServices.Settings, authMiddleware)
+ api.NewSettingsHandler(apiGroup, appServices.Settings, appServices.SettingsSearch, authMiddleware)
+ api.NewCustomizeHandler(apiGroup, appServices.CustomizeSearch, authMiddleware)
if cfg.Environment != "production" {
for _, registerFunc := range registerPlaywrightRoutes {
diff --git a/backend/internal/bootstrap/services_bootstrap.go b/backend/internal/bootstrap/services_bootstrap.go
index 565bf8f83..8c2a54523 100644
--- a/backend/internal/bootstrap/services_bootstrap.go
+++ b/backend/internal/bootstrap/services_bootstrap.go
@@ -17,6 +17,8 @@ type Services struct {
Project *services.ProjectService
Environment *services.EnvironmentService
Settings *services.SettingsService
+ SettingsSearch *services.SettingsSearchService
+ CustomizeSearch *services.CustomizeSearchService
Container *services.ContainerService
Image *services.ImageService
Volume *services.VolumeService
@@ -41,6 +43,8 @@ func initializeServices(ctx context.Context, db *database.DB, cfg *config.Config
if err != nil {
return nil, nil, fmt.Errorf("failed to settings service: %w", err)
}
+ svcs.SettingsSearch = services.NewSettingsSearchService()
+ svcs.CustomizeSearch = services.NewCustomizeSearchService()
svcs.AppImages = services.NewApplicationImagesService(resources.FS, svcs.Settings)
dockerClient := services.NewDockerClientService(db, cfg)
svcs.Docker = dockerClient
diff --git a/backend/internal/dto/customize_search_dto.go b/backend/internal/dto/customize_search_dto.go
new file mode 100644
index 000000000..f58e7d445
--- /dev/null
+++ b/backend/internal/dto/customize_search_dto.go
@@ -0,0 +1,31 @@
+package dto
+
+type CustomizationMeta struct {
+ Key string `json:"key"`
+ Label string `json:"label"`
+ Type string `json:"type"`
+ Keywords []string `json:"keywords,omitempty"`
+ Description string `json:"description,omitempty"`
+}
+
+type CustomizeCategory struct {
+ ID string `json:"id"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+ Icon string `json:"icon"`
+ URL string `json:"url"`
+ Keywords []string `json:"keywords"`
+ Customizations []CustomizationMeta `json:"customizations"`
+ MatchingCustomizations []CustomizationMeta `json:"matchingCustomizations,omitempty"`
+ RelevanceScore int `json:"relevanceScore,omitempty"`
+}
+
+type CustomizeSearchRequest struct {
+ Query string `json:"query" binding:"required,min=1"`
+}
+
+type CustomizeSearchResponse struct {
+ Results []CustomizeCategory `json:"results"`
+ Query string `json:"query"`
+ Count int `json:"count"`
+}
diff --git a/backend/internal/dto/settings_search_dto.go b/backend/internal/dto/settings_search_dto.go
new file mode 100644
index 000000000..e25a02295
--- /dev/null
+++ b/backend/internal/dto/settings_search_dto.go
@@ -0,0 +1,31 @@
+package dto
+
+type SettingMeta struct {
+ Key string `json:"key"`
+ Label string `json:"label"`
+ Type string `json:"type"`
+ Keywords []string `json:"keywords,omitempty"`
+ Description string `json:"description,omitempty"`
+}
+
+type SettingsCategory struct {
+ ID string `json:"id"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+ Icon string `json:"icon"`
+ URL string `json:"url"`
+ Keywords []string `json:"keywords"`
+ Settings []SettingMeta `json:"settings"`
+ MatchingSettings []SettingMeta `json:"matchingSettings,omitempty"`
+ RelevanceScore int `json:"relevanceScore,omitempty"`
+}
+
+type SettingsSearchRequest struct {
+ Query string `json:"query" binding:"required,min=1"`
+}
+
+type SettingsSearchResponse struct {
+ Results []SettingsCategory `json:"results"`
+ Query string `json:"query"`
+ Count int `json:"count"`
+}
diff --git a/backend/internal/models/customize.go b/backend/internal/models/customize.go
new file mode 100644
index 000000000..57f6dd2ee
--- /dev/null
+++ b/backend/internal/models/customize.go
@@ -0,0 +1,30 @@
+package models
+
+// CustomizeItem represents a customization configuration item
+// This struct uses reflection tags to define customization categories and metadata
+// Categories must be grouped together and use `catmeta` tag for category-level metadata
+type CustomizeItem struct {
+ // Defaults category
+ DefaultProjectTemplate CustomizeVariable `key:"defaultProjectTemplate" meta:"label=Default Project Template;type=select;keywords=template,default,project,scaffold,boilerplate,starter;category=defaults;description=Set the default template for new projects" catmeta:"id=defaults;title=Defaults;icon=file-text;url=/customize/defaults;description=Configure default templates and settings for new projects"`
+ DefaultContainerSettings CustomizeVariable `key:"defaultContainerSettings" meta:"label=Default Container Settings;type=object;keywords=container,default,settings,docker,configuration,runtime;category=defaults;description=Configure default container runtime settings"`
+ DefaultNetworkMode CustomizeVariable `key:"defaultNetworkMode" meta:"label=Default Network Mode;type=select;keywords=network,default,mode,bridge,host,none,container;category=defaults;description=Set the default network mode for containers"`
+
+ // Templates category
+ CustomTemplates CustomizeVariable `key:"customTemplates" meta:"label=Custom Templates;type=array;keywords=templates,custom,project,compose,docker-compose,yaml,stack;category=templates;description=Add and manage custom project templates" catmeta:"id=templates;title=Templates;icon=layers;url=/customize/templates;description=Manage project templates and compose file configurations"`
+ TemplateCategories CustomizeVariable `key:"templateCategories" meta:"label=Template Categories;type=array;keywords=categories,organization,grouping,tags,classification;category=templates;description=Organize templates into categories"`
+ TemplateValidation CustomizeVariable `key:"templateValidation" meta:"label=Template Validation;type=boolean;keywords=validation,check,verify,lint,syntax,schema;category=templates;description=Enable validation for template files"`
+
+ // Registries category
+ ContainerRegistries CustomizeVariable `key:"containerRegistries" meta:"label=Container Registries;type=array;keywords=registry,docker,images,hub,private,authentication,credentials;category=registries;description=Manage container registry connections" catmeta:"id=registries;title=Registries;icon=package;url=/customize/registries;description=Configure container registries and authentication"`
+ RegistryCredentials CustomizeVariable `key:"registryCredentials" meta:"label=Registry Credentials;type=secure;keywords=credentials,auth,username,password,token,login,security;category=registries;description=Configure authentication for container registries"`
+ RegistryMirrors CustomizeVariable `key:"registryMirrors" meta:"label=Registry Mirrors;type=array;keywords=mirrors,proxy,cache,performance,cdn,regional;category=registries;description=Configure registry mirrors and proxies"`
+
+ // Variables category
+ GlobalVariables CustomizeVariable `key:"globalVariables" meta:"label=Global Variables;type=object;keywords=variables,environment,env,global,config,settings,parameters;category=variables;description=Define reusable variables for all projects" catmeta:"id=variables;title=Variables;icon=code;url=/customize/variables;description=Manage global variables and environment configuration"`
+ SecretVariables CustomizeVariable `key:"secretVariables" meta:"label=Secret Variables;type=secure;keywords=secrets,sensitive,secure,encrypted,password,api,key;category=variables;description=Manage sensitive and encrypted variables"`
+ VariableTemplates CustomizeVariable `key:"variableTemplates" meta:"label=Variable Templates;type=array;keywords=templates,reusable,preset,configuration,standard,common;category=variables;description=Create reusable variable configurations"`
+}
+
+type CustomizeVariable struct {
+ Value string
+}
diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.go
index 298c33699..86236835f 100644
--- a/backend/internal/models/settings.go
+++ b/backend/internal/models/settings.go
@@ -43,41 +43,39 @@ func (s SettingVariable) AsDurationSeconds() time.Duration {
}
type Settings struct {
- // Docker
- ProjectsDirectory SettingVariable `key:"projectsDirectory"`
- DiskUsagePath SettingVariable `key:"diskUsagePath"`
- AutoUpdate SettingVariable `key:"autoUpdate"`
- AutoUpdateInterval SettingVariable `key:"autoUpdateInterval"`
- PollingEnabled SettingVariable `key:"pollingEnabled"`
- PollingInterval SettingVariable `key:"pollingInterval"`
- PruneMode SettingVariable `key:"dockerPruneMode"`
- BaseServerURL SettingVariable `key:"baseServerUrl"`
- EnableGravatar SettingVariable `key:"enableGravatar"`
- DefaultShell SettingVariable `key:"defaultShell"`
- DockerHost SettingVariable `key:"dockerHost,public,envOverride"`
- AccentColor SettingVariable `key:"accentColor,public"`
-
- // Authentication
- AuthLocalEnabled SettingVariable `key:"authLocalEnabled,public"`
- AuthOidcEnabled SettingVariable `key:"authOidcEnabled,public"`
- AuthSessionTimeout SettingVariable `key:"authSessionTimeout"`
- AuthPasswordPolicy SettingVariable `key:"authPasswordPolicy"`
- AuthOidcConfig SettingVariable `key:"authOidcConfig,sensitive"`
-
- // Onboarding
- OnboardingCompleted SettingVariable `key:"onboardingCompleted,public"`
- OnboardingSteps SettingVariable `key:"onboardingSteps"`
-
- // Navigation
- MobileNavigationMode SettingVariable `key:"mobileNavigationMode,public"`
- MobileNavigationShowLabels SettingVariable `key:"mobileNavigationShowLabels,public"`
- MobileNavigationScrollToHide SettingVariable `key:"mobileNavigationScrollToHide,public"`
- SidebarHoverExpansion SettingVariable `key:"sidebarHoverExpansion,public"`
-
- // UI/UX
- GlassEffectEnabled SettingVariable `key:"glassEffectEnabled,public"`
-
- InstanceID SettingVariable `key:"instanceId,internal"`
+ // General category
+ ProjectsDirectory SettingVariable `key:"projectsDirectory" meta:"label=Projects Directory;type=text;keywords=projects,directory,path,folder,location,storage,files,compose,docker-compose;category=general;description=Configure where project files are stored" catmeta:"id=general;title=General;icon=settings;url=/settings/general;description=Core application settings and configuration"`
+ DiskUsagePath SettingVariable `key:"diskUsagePath" meta:"label=Disk Usage Path;type=text;keywords=disk,usage,path,storage,folder,files;category=general;description=Path used for disk usage calculations"`
+ BaseServerURL SettingVariable `key:"baseServerUrl" meta:"label=Base Server URL;type=text;keywords=base,url,server,domain,host,endpoint,address,link;category=general;description=Set the base URL for the application"`
+ EnableGravatar SettingVariable `key:"enableGravatar" meta:"label=Enable Gravatar;type=boolean;keywords=gravatar,avatar,profile,picture,image,user,photo;category=general;description=Enable Gravatar profile pictures for users"`
+ DefaultShell SettingVariable `key:"defaultShell" meta:"label=Default Shell;type=text;keywords=shell,default,shellpath,path,login;category=general;description=Default shell to use for commands"`
+ AccentColor SettingVariable `key:"accentColor,public" meta:"label=Accent Color;type=text;keywords=color,accent,theme,css,appearance,ui;category=general;description=Primary accent color for UI"`
+ OnboardingCompleted SettingVariable `key:"onboardingCompleted,public" meta:"label=Onboarding Completed;type=boolean;keywords=onboarding,completed,setup,first-run;category=general;description=Whether onboarding has been completed"`
+ OnboardingSteps SettingVariable `key:"onboardingSteps" meta:"label=Onboarding Steps;type=text;keywords=onboarding,steps,progress,guide;category=general;description=Serialized onboarding steps"`
+
+ // Docker category
+ AutoUpdate SettingVariable `key:"autoUpdate" meta:"label=Auto Update;type=boolean;keywords=auto,update,automatic,upgrade,refresh,restart,deploy;category=docker;description=Automatically update containers when new images are available" catmeta:"id=docker;title=Docker;icon=database;url=/settings/docker;description=Configure Docker settings, polling, and auto-updates"`
+ AutoUpdateInterval SettingVariable `key:"autoUpdateInterval" meta:"label=Auto Update Interval;type=number;keywords=auto,update,interval,frequency,schedule,automatic,timing;category=docker;description=Interval between automatic updates"`
+ PollingEnabled SettingVariable `key:"pollingEnabled" meta:"label=Enable Polling;type=boolean;keywords=polling,check,monitor,watch,scan,detection,automatic;category=docker;description=Enable automatic checking for image updates"`
+ PollingInterval SettingVariable `key:"pollingInterval" meta:"label=Polling Interval;type=number;keywords=interval,frequency,schedule,time,minutes,period,delay;category=docker;description=How often to check for image updates"`
+ PruneMode SettingVariable `key:"dockerPruneMode" meta:"label=Docker Prune Action;type=select;keywords=prune,cleanup,clean,remove,delete,unused,dangling,space,disk;category=docker;description=Configure how unused Docker images are cleaned up"`
+ DockerHost SettingVariable `key:"dockerHost,public,envOverride" meta:"label=Docker Host;type=text;keywords=docker,host,daemon,socket,unix,remote;category=docker;description=URI for Docker daemon"`
+
+ // Security category
+ AuthLocalEnabled SettingVariable `key:"authLocalEnabled,public" meta:"label=Local Authentication;type=boolean;keywords=local,auth,authentication,username,password,login,credentials;category=security;description=Enable local username/password authentication" catmeta:"id=security;title=Security;icon=shield;url=/settings/security;description=Manage authentication and security settings"`
+ AuthOidcEnabled SettingVariable `key:"authOidcEnabled,public" meta:"label=OIDC Authentication;type=boolean;keywords=oidc,openid,connect,sso,oauth,external,provider,federation;category=security;description=Enable OpenID Connect (OIDC) authentication"`
+ AuthSessionTimeout SettingVariable `key:"authSessionTimeout" meta:"label=Session Timeout;type=number;keywords=session,timeout,expire,duration,lifetime,minutes,logout;category=security;description=How long user sessions remain active"`
+ AuthPasswordPolicy SettingVariable `key:"authPasswordPolicy" meta:"label=Password Policy;type=select;keywords=password,policy,strength,complexity,requirements,security,rules;category=security;description=Set password strength requirements"`
+ AuthOidcConfig SettingVariable `key:"authOidcConfig,sensitive" meta:"label=OIDC Config;type=text;keywords=oidc,config,client,id,issuer,secret,oauth;category=security;description=OIDC provider configuration"`
+
+ // Navigation category
+ MobileNavigationMode SettingVariable `key:"mobileNavigationMode,public" meta:"label=Mobile Navigation Mode;type=select;keywords=mode,style,type,floating,docked,position,layout,design,appearance,bottom;category=navigation;description=Choose between floating or docked navigation on mobile" catmeta:"id=navigation;title=Navigation;icon=navigation;url=/settings/navigation;description=Customize navigation and interface behavior"`
+ MobileNavigationShowLabels SettingVariable `key:"mobileNavigationShowLabels,public" meta:"label=Show Navigation Labels;type=boolean;keywords=labels,text,icons,display,show,hide,names,captions,titles,visible,toggle;category=navigation;description=Display text labels alongside navigation icons"`
+ MobileNavigationScrollToHide SettingVariable `key:"mobileNavigationScrollToHide,public" meta:"label=Scroll to Hide;type=boolean;keywords=scroll,hide,auto-hide,behavior,down,up,automatic,disappear,vanish,minimize,collapse;category=navigation;description=Automatically hide navigation when scrolling down"`
+ SidebarHoverExpansion SettingVariable `key:"sidebarHoverExpansion,public" meta:"label=Sidebar Hover Expansion;type=boolean;keywords=sidebar,hover,expansion,expand,desktop,mouse,over,collapsed,collapsible,icon,labels,text,preview,peek,tooltip,overlay,temporary,quick,access,navigation,menu,items,submenu,nested;category=navigation;description=Expand sidebar on hover in desktop mode"`
+ GlassEffectEnabled SettingVariable `key:"glassEffectEnabled,public" meta:"label=Glass Effect;type=boolean;keywords=glass,glassmorphism,blur,backdrop,frosted,effect,gradient,ambient,design,ui,appearance,modern,visual,style,theme,transparency,translucent;category=navigation;description=Enable modern glassmorphism design with blur, gradients, and ambient effects"`
+
+ InstanceID SettingVariable `key:"instanceId,internal" meta:"label=Instance ID;type=text;keywords=instance,id,uuid,identifier;category=internal;description=Unique instance identifier"`
}
func (SettingVariable) TableName() string {
diff --git a/backend/internal/services/customize_search_service.go b/backend/internal/services/customize_search_service.go
new file mode 100644
index 000000000..4027b1d80
--- /dev/null
+++ b/backend/internal/services/customize_search_service.go
@@ -0,0 +1,236 @@
+package services
+
+import (
+ "reflect"
+ "sort"
+ "strings"
+ "sync"
+
+ "github.com/ofkm/arcane-backend/internal/dto"
+ "github.com/ofkm/arcane-backend/internal/models"
+ "github.com/ofkm/arcane-backend/internal/utils"
+)
+
+type CustomizeSearchService struct {
+ categories []dto.CustomizeCategory
+ once sync.Once
+}
+
+func NewCustomizeSearchService() *CustomizeSearchService {
+ s := &CustomizeSearchService{}
+ s.initCategories()
+ return s
+}
+
+func (s *CustomizeSearchService) initCategories() {
+ s.once.Do(func() {
+ s.categories = s.buildCategoriesFromModel()
+ })
+}
+
+// GetCustomizeCategories returns all available customization categories with their metadata
+func (s *CustomizeSearchService) GetCustomizeCategories() []dto.CustomizeCategory {
+ return s.categories
+}
+
+func (s *CustomizeSearchService) buildCategoriesFromModel() []dto.CustomizeCategory {
+ // Extract category metadata from struct tags (catmeta)
+ catMetaMap := utils.ExtractCategoryMetadata(models.CustomizeItem{}, nil)
+
+ // map category id -> list of customizations
+ categories := map[string][]dto.CustomizationMeta{}
+ categoryOrder := []string{} // Track order from first appearance in struct
+
+ rt := reflect.TypeOf(models.CustomizeItem{})
+ for i := 0; i < rt.NumField(); i++ {
+ field := rt.Field(i)
+ keyTag := field.Tag.Get("key")
+ key, _, _ := strings.Cut(keyTag, ",")
+ if key == "" {
+ continue
+ }
+
+ meta := utils.ParseMetaTag(field.Tag.Get("meta"))
+ label := meta["label"]
+ if label == "" {
+ label = key
+ }
+ typ := meta["type"]
+ if typ == "" {
+ typ = "text"
+ }
+ desc := meta["description"]
+ keywords := utils.ParseKeywords(meta["keywords"])
+ categoryID := meta["category"]
+ if categoryID == "" {
+ categoryID = "defaults"
+ }
+
+ // Track category order from first appearance
+ if len(categories[categoryID]) == 0 && !utils.Contains(categoryOrder, categoryID) {
+ categoryOrder = append(categoryOrder, categoryID)
+ }
+
+ cm := dto.CustomizationMeta{
+ Key: key,
+ Label: label,
+ Type: typ,
+ Description: desc,
+ Keywords: keywords,
+ }
+
+ categories[categoryID] = append(categories[categoryID], cm)
+ }
+
+ // Build final category list in struct order
+ result := []dto.CustomizeCategory{}
+ for _, catID := range categoryOrder {
+ catMeta := catMetaMap[catID]
+ if catMeta == nil {
+ continue
+ }
+
+ // Parse keywords from catmeta
+ keywords := utils.ParseKeywords(catMeta["keywords"])
+ if keywords == nil {
+ keywords = []string{}
+ }
+
+ result = append(result, dto.CustomizeCategory{
+ ID: catMeta["id"],
+ Title: catMeta["title"],
+ Description: catMeta["description"],
+ Icon: catMeta["icon"],
+ URL: catMeta["url"],
+ Keywords: keywords,
+ Customizations: categories[catID],
+ })
+ }
+
+ return result
+}
+
+// Search performs a relevance-scored search across all customization categories and items
+func (s *CustomizeSearchService) Search(query string) dto.CustomizeSearchResponse {
+ query = strings.ToLower(strings.TrimSpace(query))
+ if query == "" {
+ return dto.CustomizeSearchResponse{
+ Results: []dto.CustomizeCategory{},
+ Query: query,
+ Count: 0,
+ }
+ }
+
+ categories := s.GetCustomizeCategories()
+ results := []dto.CustomizeCategory{}
+
+ for _, category := range categories {
+ // Check if category matches
+ categoryMatch := strings.Contains(strings.ToLower(category.Title), query) ||
+ strings.Contains(strings.ToLower(category.Description), query) ||
+ containsKeyword(category.Keywords, query)
+
+ // Check individual customizations
+ matchingCustomizations := []dto.CustomizationMeta{}
+ for _, customization := range category.Customizations {
+ if matchesCustomization(customization, query) {
+ matchingCustomizations = append(matchingCustomizations, customization)
+ }
+ }
+
+ if categoryMatch || len(matchingCustomizations) > 0 {
+ relevanceScore := calculateCustomizeRelevance(category, matchingCustomizations, query)
+
+ resultCategory := category
+ if len(matchingCustomizations) > 0 {
+ resultCategory.MatchingCustomizations = matchingCustomizations
+ }
+ resultCategory.RelevanceScore = relevanceScore
+
+ results = append(results, resultCategory)
+ }
+ }
+
+ // Sort by relevance (highest first)
+ sort.Slice(results, func(i, j int) bool {
+ return results[i].RelevanceScore > results[j].RelevanceScore
+ })
+
+ return dto.CustomizeSearchResponse{
+ Results: results,
+ Query: query,
+ Count: len(results),
+ }
+}
+
+func matchesCustomization(customization dto.CustomizationMeta, query string) bool {
+ return strings.Contains(strings.ToLower(customization.Key), query) ||
+ strings.Contains(strings.ToLower(customization.Label), query) ||
+ strings.Contains(strings.ToLower(customization.Description), query) ||
+ containsKeyword(customization.Keywords, query)
+}
+
+func calculateCustomizeRelevance(category dto.CustomizeCategory, matchingCustomizations []dto.CustomizationMeta, query string) int {
+ score := 0
+
+ // Category-level scoring
+ if strings.ToLower(category.Title) == query {
+ score += 30
+ } else if strings.Contains(strings.ToLower(category.Title), query) {
+ score += 20
+ }
+
+ if strings.Contains(strings.ToLower(category.Description), query) {
+ score += 15
+ }
+
+ // Exact keyword match
+ for _, keyword := range category.Keywords {
+ if strings.ToLower(keyword) == query {
+ score += 25
+ break
+ } else if strings.Contains(strings.ToLower(keyword), query) {
+ score += 10
+ break
+ }
+ }
+
+ // Customization-level scoring
+ for _, customization := range matchingCustomizations {
+ if strings.ToLower(customization.Key) == query {
+ score += 30
+ } else if strings.Contains(strings.ToLower(customization.Key), query) {
+ score += 15
+ }
+
+ if strings.Contains(strings.ToLower(customization.Label), query) {
+ score += 12
+ }
+
+ if strings.Contains(strings.ToLower(customization.Description), query) {
+ score += 8
+ }
+
+ // Exact keyword match
+ for _, keyword := range customization.Keywords {
+ if strings.ToLower(keyword) == query {
+ score += 20
+ break
+ } else if strings.Contains(strings.ToLower(keyword), query) {
+ score += 5
+ break
+ }
+ }
+ }
+
+ return score
+}
+
+func containsKeyword(keywords []string, query string) bool {
+ for _, keyword := range keywords {
+ if strings.Contains(strings.ToLower(keyword), query) {
+ return true
+ }
+ }
+ return false
+}
diff --git a/backend/internal/services/settings_search_service.go b/backend/internal/services/settings_search_service.go
new file mode 100644
index 000000000..c2248acf2
--- /dev/null
+++ b/backend/internal/services/settings_search_service.go
@@ -0,0 +1,266 @@
+package services
+
+import (
+ "reflect"
+ "sort"
+ "strings"
+ "sync"
+
+ "github.com/ofkm/arcane-backend/internal/dto"
+ "github.com/ofkm/arcane-backend/internal/models"
+ "github.com/ofkm/arcane-backend/internal/utils"
+)
+
+type SettingsSearchService struct {
+ categories []dto.SettingsCategory
+ once sync.Once
+}
+
+func NewSettingsSearchService() *SettingsSearchService {
+ s := &SettingsSearchService{}
+ s.initCategories()
+ return s
+}
+
+func (s *SettingsSearchService) initCategories() {
+ s.once.Do(func() {
+ s.categories = s.buildCategoriesFromModel()
+ })
+}
+
+// GetSettingsCategories returns all available settings categories with their metadata
+func (s *SettingsSearchService) GetSettingsCategories() []dto.SettingsCategory {
+ return s.categories
+}
+
+func (s *SettingsSearchService) buildCategoriesFromModel() []dto.SettingsCategory {
+ // Extract category metadata from struct tags (catmeta)
+ catMetaMap := utils.ExtractCategoryMetadata(models.Settings{}, nil)
+
+ // map category id -> list of settings
+ categories := map[string][]dto.SettingMeta{}
+ categoryOrder := []string{} // Track order from first appearance in struct
+
+ rt := reflect.TypeOf(models.Settings{})
+ for i := 0; i < rt.NumField(); i++ {
+ field := rt.Field(i)
+ keyTag := field.Tag.Get("key")
+ key, _, _ := strings.Cut(keyTag, ",")
+ if key == "" {
+ continue
+ }
+
+ meta := utils.ParseMetaTag(field.Tag.Get("meta"))
+ label := meta["label"]
+ if label == "" {
+ label = key
+ }
+ typ := meta["type"]
+ if typ == "" {
+ typ = "text"
+ }
+ desc := meta["description"]
+ keywords := utils.ParseKeywords(meta["keywords"])
+ categoryID := meta["category"]
+ if categoryID == "" {
+ categoryID = "general"
+ }
+
+ // Skip internal category
+ if categoryID == "internal" {
+ continue
+ }
+
+ // Track category order from first appearance
+ if len(categories[categoryID]) == 0 && !utils.Contains(categoryOrder, categoryID) {
+ categoryOrder = append(categoryOrder, categoryID)
+ }
+
+ sm := dto.SettingMeta{
+ Key: key,
+ Label: label,
+ Type: typ,
+ Description: desc,
+ Keywords: keywords,
+ }
+
+ categories[categoryID] = append(categories[categoryID], sm)
+ }
+
+ // Build final category list in struct order
+ results := []dto.SettingsCategory{}
+ for _, catID := range categoryOrder {
+ catMeta := catMetaMap[catID]
+ if catMeta == nil {
+ continue
+ }
+
+ // Parse keywords from catmeta
+ keywords := utils.ParseKeywords(catMeta["keywords"])
+ if keywords == nil {
+ keywords = []string{}
+ }
+
+ results = append(results, dto.SettingsCategory{
+ ID: catMeta["id"],
+ Title: catMeta["title"],
+ Description: catMeta["description"],
+ Icon: catMeta["icon"],
+ URL: catMeta["url"],
+ Keywords: keywords,
+ Settings: categories[catID],
+ })
+ }
+
+ return results
+}
+
+// Search performs a relevance-scored search across settings categories and individual settings
+func (s *SettingsSearchService) Search(query string) dto.SettingsSearchResponse {
+ query = strings.ToLower(strings.TrimSpace(query))
+ if query == "" {
+ return dto.SettingsSearchResponse{
+ Results: []dto.SettingsCategory{},
+ Query: query,
+ Count: 0,
+ }
+ }
+
+ categories := s.GetSettingsCategories()
+ var results []dto.SettingsCategory
+
+ for _, category := range categories {
+ // Check if category matches
+ categoryMatch := s.categoryMatches(category, query)
+
+ // Check individual settings with enhanced matching
+ matchingSettings := s.findMatchingSettings(category.Settings, query)
+
+ if categoryMatch || len(matchingSettings) > 0 {
+ // Calculate relevance score based on match quality
+ relevanceScore := s.calculateRelevance(category, matchingSettings, query)
+
+ categoryResult := dto.SettingsCategory{
+ ID: category.ID,
+ Title: category.Title,
+ Description: category.Description,
+ Icon: category.Icon,
+ URL: category.URL,
+ Keywords: category.Keywords,
+ Settings: category.Settings,
+ RelevanceScore: relevanceScore,
+ }
+
+ if len(matchingSettings) > 0 {
+ categoryResult.MatchingSettings = matchingSettings
+ }
+
+ results = append(results, categoryResult)
+ }
+ }
+
+ // Sort by relevance (highest first)
+ s.sortByRelevance(results)
+
+ return dto.SettingsSearchResponse{
+ Results: results,
+ Query: query,
+ Count: len(results),
+ }
+}
+
+func (s *SettingsSearchService) categoryMatches(category dto.SettingsCategory, query string) bool {
+ if strings.Contains(strings.ToLower(category.Title), query) {
+ return true
+ }
+ if strings.Contains(strings.ToLower(category.Description), query) {
+ return true
+ }
+ for _, keyword := range category.Keywords {
+ if strings.Contains(strings.ToLower(keyword), query) {
+ return true
+ }
+ }
+ return false
+}
+
+func (s *SettingsSearchService) findMatchingSettings(settings []dto.SettingMeta, query string) []dto.SettingMeta {
+ var matching []dto.SettingMeta
+ for _, setting := range settings {
+ if s.settingMatches(setting, query) {
+ matching = append(matching, setting)
+ }
+ }
+ return matching
+}
+
+func (s *SettingsSearchService) settingMatches(setting dto.SettingMeta, query string) bool {
+ if strings.Contains(strings.ToLower(setting.Key), query) {
+ return true
+ }
+ if strings.Contains(strings.ToLower(setting.Label), query) {
+ return true
+ }
+ if strings.Contains(strings.ToLower(setting.Description), query) {
+ return true
+ }
+ for _, keyword := range setting.Keywords {
+ if strings.Contains(strings.ToLower(keyword), query) {
+ return true
+ }
+ }
+ return false
+}
+
+func (s *SettingsSearchService) calculateRelevance(category dto.SettingsCategory, matchingSettings []dto.SettingMeta, query string) int {
+ score := 0
+
+ // Category title/description match gets high score
+ if strings.Contains(strings.ToLower(category.Title), query) {
+ score += 20
+ }
+ if strings.Contains(strings.ToLower(category.Description), query) {
+ score += 15
+ }
+
+ // Exact keyword match
+ for _, keyword := range category.Keywords {
+ if strings.ToLower(keyword) == query {
+ score += 25
+ } else if strings.Contains(strings.ToLower(keyword), query) {
+ score += 10
+ }
+ }
+
+ // Add score for individual setting matches
+ for _, setting := range matchingSettings {
+ if strings.ToLower(setting.Key) == query {
+ score += 30
+ } else if strings.Contains(strings.ToLower(setting.Key), query) {
+ score += 15
+ }
+
+ if strings.Contains(strings.ToLower(setting.Label), query) {
+ score += 12
+ }
+ if strings.Contains(strings.ToLower(setting.Description), query) {
+ score += 8
+ }
+
+ for _, keyword := range setting.Keywords {
+ if strings.ToLower(keyword) == query {
+ score += 20
+ } else if strings.Contains(strings.ToLower(keyword), query) {
+ score += 5
+ }
+ }
+ }
+
+ return score
+}
+
+func (s *SettingsSearchService) sortByRelevance(results []dto.SettingsCategory) {
+ sort.Slice(results, func(i, j int) bool {
+ return results[i].RelevanceScore > results[j].RelevanceScore
+ })
+}
diff --git a/backend/internal/utils/reflection.go b/backend/internal/utils/reflection.go
new file mode 100644
index 000000000..ba6710af0
--- /dev/null
+++ b/backend/internal/utils/reflection.go
@@ -0,0 +1,76 @@
+package utils
+
+import (
+ "reflect"
+ "strings"
+)
+
+// ParseMetaTag parses a struct tag meta value formatted as `k=v;other=val;...`
+// Returns a map of key-value pairs extracted from the tag
+func ParseMetaTag(tag string) map[string]string {
+ res := map[string]string{}
+ if tag == "" {
+ return res
+ }
+ parts := strings.Split(tag, ";")
+ for _, p := range parts {
+ if p == "" {
+ continue
+ }
+ if kv := strings.SplitN(p, "=", 2); len(kv) == 2 {
+ res[strings.TrimSpace(kv[0])] = strings.TrimSpace(kv[1])
+ }
+ }
+ return res
+}
+
+// ParseKeywords parses a comma-separated keywords string into a slice
+// Returns an empty slice if the input is empty or contains only whitespace
+func ParseKeywords(keywordsStr string) []string {
+ keywords := []string{}
+ if k := strings.TrimSpace(keywordsStr); k != "" {
+ for _, kk := range strings.Split(k, ",") {
+ if t := strings.TrimSpace(kk); t != "" {
+ keywords = append(keywords, t)
+ }
+ }
+ }
+ return keywords
+}
+
+// ExtractCategoryMetadata extracts category metadata from struct fields with catmeta tags
+// Returns a map of category ID to category metadata in field order
+func ExtractCategoryMetadata(model interface{}, categoryIDsInOrder []string) map[string]map[string]string {
+ result := make(map[string]map[string]string)
+ seenCategories := make(map[string]bool)
+
+ rt := reflect.TypeOf(model)
+ for i := 0; i < rt.NumField(); i++ {
+ field := rt.Field(i)
+ catmetaTag := field.Tag.Get("catmeta")
+ if catmetaTag == "" {
+ continue
+ }
+
+ meta := ParseMetaTag(catmetaTag)
+ catID := meta["id"]
+ if catID == "" || seenCategories[catID] {
+ continue
+ }
+
+ seenCategories[catID] = true
+ result[catID] = meta
+ }
+
+ return result
+}
+
+// Contains checks if a string slice contains an item
+func Contains(slice []string, item string) bool {
+ for _, v := range slice {
+ if v == item {
+ return true
+ }
+ }
+ return false
+}
diff --git a/frontend/src/lib/services/customize-search.ts b/frontend/src/lib/services/customize-search.ts
new file mode 100644
index 000000000..f4df9d30a
--- /dev/null
+++ b/frontend/src/lib/services/customize-search.ts
@@ -0,0 +1,20 @@
+import axios from 'axios';
+import type { CustomizeSearchResponse, CustomizeCategory } from '$lib/types/customize-search.type';
+
+export class CustomizeSearchService {
+ private baseUrl = '/api/customize';
+
+ async search(query: string): Promise<CustomizeSearchResponse> {
+ const response = await axios.post<CustomizeSearchResponse>(`${this.baseUrl}/search`, {
+ query
+ });
+ return response.data;
+ }
+
+ async getCategories(): Promise<CustomizeCategory[]> {
+ const response = await axios.get<CustomizeCategory[]>(`${this.baseUrl}/categories`);
+ return response.data;
+ }
+}
+
+export const customizeSearchService = new CustomizeSearchService();
diff --git a/frontend/src/lib/services/settings-search.ts b/frontend/src/lib/services/settings-search.ts
new file mode 100644
index 000000000..37f83c63b
--- /dev/null
+++ b/frontend/src/lib/services/settings-search.ts
@@ -0,0 +1,20 @@
+import axios from 'axios';
+import type { SettingsSearchResponse, SettingsCategory } from '$lib/types/settings-search.type';
+
+export class SettingsSearchService {
+ private baseUrl = '/api/settings';
+
+ async search(query: string): Promise<SettingsSearchResponse> {
+ const response = await axios.post<SettingsSearchResponse>(`${this.baseUrl}/search`, {
+ query
+ });
+ return response.data;
+ }
+
+ async getCategories(): Promise<SettingsCategory[]> {
+ const response = await axios.get<SettingsCategory[]>(`${this.baseUrl}/categories`);
+ return response.data;
+ }
+}
+
+export const settingsSearchService = new SettingsSearchService();
diff --git a/frontend/src/lib/types/customize-search.type.ts b/frontend/src/lib/types/customize-search.type.ts
new file mode 100644
index 000000000..2f5734013
--- /dev/null
+++ b/frontend/src/lib/types/customize-search.type.ts
@@ -0,0 +1,25 @@
+export interface CustomizationMeta {
+ key: string;
+ label: string;
+ type: string;
+ keywords?: string[];
+ description?: string;
+}
+
+export interface CustomizeCategory {
+ id: string;
+ title: string;
+ description: string;
+ icon: string;
+ url: string;
+ keywords: string[];
+ customizations: CustomizationMeta[];
+ matchingCustomizations?: CustomizationMeta[];
+ relevanceScore?: number;
+}
+
+export interface CustomizeSearchResponse {
+ results: CustomizeCategory[];
+ query: string;
+ count: number;
+}
diff --git a/frontend/src/lib/types/settings-search.type.ts b/frontend/src/lib/types/settings-search.type.ts
new file mode 100644
index 000000000..ae7f2b4f3
--- /dev/null
+++ b/frontend/src/lib/types/settings-search.type.ts
@@ -0,0 +1,25 @@
+export interface SettingMeta {
+ key: string;
+ label: string;
+ type: string;
+ keywords?: string[];
+ description?: string;
+}
+
+export interface SettingsCategory {
+ id: string;
+ title: string;
+ description: string;
+ icon: string;
+ url: string;
+ keywords: string[];
+ settings: SettingMeta[];
+ matchingSettings?: SettingMeta[];
+ relevanceScore?: number;
+}
+
+export interface SettingsSearchResponse {
+ results: SettingsCategory[];
+ query: string;
+ count: number;
+}
diff --git a/frontend/src/routes/customize/+page.svelte b/frontend/src/routes/customize/+page.svelte
index 44915a33a..443fbdff3 100644
--- a/frontend/src/routes/customize/+page.svelte
+++ b/frontend/src/routes/customize/+page.svelte
@@ -1,243 +1,79 @@
<script lang="ts">
import { goto } from '$app/navigation';
+ import { onMount } from 'svelte';
import SearchIcon from '@lucide/svelte/icons/search';
import PaletteIcon from '@lucide/svelte/icons/palette';
import ChevronRightIcon from '@lucide/svelte/icons/chevron-right';
+ import FileTextIcon from '@lucide/svelte/icons/file-text';
+ import LayersIcon from '@lucide/svelte/icons/layers';
+ import PackageIcon from '@lucide/svelte/icons/package';
+ import CodeIcon from '@lucide/svelte/icons/code';
import { Button } from '$lib/components/ui/button';
import { Card } from '$lib/components/ui/card';
import { m } from '$lib/paraglide/messages';
import { UiConfigDisabledTag } from '$lib/components/badges/index.js';
- import { navigationItems } from '$lib/config/navigation-config';
- import type { NavigationItem } from '$lib/config/navigation-config';
-
- interface CustomizationMeta {
- key: string;
- label: string;
- type: string;
- keywords?: string[];
- description?: string;
- }
-
- interface CustomizationCategory {
- id: string;
- title: string;
- description: string;
- icon: any;
- url: string;
- keywords: string[];
- customizations: CustomizationMeta[];
- matchingCustomizations?: CustomizationMeta[];
- relevanceScore?: number;
- }
+ import { customizeSearchService } from '$lib/services/customize-search';
+ import type { CustomizeCategory } from '$lib/types/customize-search.type';
+ import { debounced } from '$lib/utils/utils';
let { data } = $props();
let searchQuery = $state('');
let showSearchResults = $state(false);
- let searchResults = $state<CustomizationCategory[]>([]);
+ let searchResults = $state<CustomizeCategory[]>([]);
+ let isSearching = $state(false);
+ let customizeCategories = $state<CustomizeCategory[]>([]);
+ let currentSearchRequest = $state(0);
- // Extract customization items from navigation config
- const customizationNavItems = navigationItems.customizationItems[0]?.items || [];
+ const iconMap: Record<string, any> = {
+ 'file-text': FileTextIcon,
+ layers: LayersIcon,
+ package: PackageIcon,
+ code: CodeIcon
+ };
- // Build customization categories with metadata
- const customizationCategories: CustomizationCategory[] = customizationNavItems.map((item: NavigationItem) => {
- const categoryId = item.url.split('/').pop() || '';
-
- // Define customization metadata for each category
- const customizationsByCategory: Record<string, CustomizationMeta[]> = {
- defaults: [
- {
- key: 'defaultProjectTemplate',
- label: m.customize_default_project_template(),
- type: 'select',
- description: m.customize_defaults_description(),
- keywords: ['template', 'default', 'project', 'scaffold', 'boilerplate', 'starter']
- },
- {
- key: 'defaultContainerSettings',
- label: m.customize_default_container_settings(),
- type: 'object',
- description: m.customize_defaults_description(),
- keywords: ['container', 'default', 'settings', 'docker', 'configuration', 'runtime']
- },
- {
- key: 'defaultNetworkMode',
- label: m.customize_default_network_mode(),
- type: 'select',
- description: m.customize_category_defaults_description(),
- keywords: ['network', 'default', 'mode', 'bridge', 'host', 'none', 'container']
- }
- ],
- templates: [
- {
- key: 'customTemplates',
- label: m.templates_title(),
- type: 'array',
- description: m.customize_category_templates_description(),
- keywords: ['templates', 'custom', 'project', 'compose', 'docker-compose', 'yaml', 'stack']
- },
- {
- key: 'templateCategories',
- label: m.customize_template_categories(),
- type: 'array',
- description: m.customize_category_templates_description(),
- keywords: ['categories', 'organization', 'grouping', 'tags', 'classification']
- },
- {
- key: 'templateValidation',
- label: m.customize_template_validation(),
- type: 'boolean',
- description: m.customize_validation_error(),
- keywords: ['validation', 'check', 'verify', 'lint', 'syntax', 'schema']
- }
- ],
- registries: [
- {
- key: 'containerRegistries',
- label: m.registries_title(),
- type: 'array',
- description: m.customize_category_registries_description(),
- keywords: ['registry', 'docker', 'images', 'hub', 'private', 'authentication', 'credentials']
- },
- {
- key: 'registryCredentials',
- label: m.customize_registry_credentials(),
- type: 'secure',
- description: m.registries_credentials_description(),
- keywords: ['credentials', 'auth', 'username', 'password', 'token', 'login', 'security']
- },
- {
- key: 'registryMirrors',
- label: m.customize_registry_mirrors(),
- type: 'array',
- description: m.customize_category_registries_description(),
- keywords: ['mirrors', 'proxy', 'cache', 'performance', 'cdn', 'regional']
- }
- ],
- variables: [
- {
- key: 'globalVariables',
- label: m.variables_title(),
- type: 'object',
- description: m.variables_subtitle(),
- keywords: ['variables', 'environment', 'env', 'global', 'config', 'settings', 'parameters']
- },
- {
- key: 'secretVariables',
- label: m.customize_secret_variables(),
- type: 'secure',
- description: m.customize_category_variables_description(),
- keywords: ['secrets', 'sensitive', 'secure', 'encrypted', 'password', 'api', 'key']
- },
- {
- key: 'variableTemplates',
- label: m.customize_variable_templates(),
- type: 'array',
- description: m.customize_category_variables_description(),
- keywords: ['templates', 'reusable', 'preset', 'configuration', 'standard', 'common']
- }
- ]
- };
-
- return {
- id: categoryId,
- title: item.title,
- description: getDescriptionForCategory(categoryId),
- icon: item.icon,
- url: item.url,
- keywords: getKeywordsForCategory(categoryId),
- customizations: customizationsByCategory[categoryId] || []
- };
+ onMount(async () => {
+ try {
+ customizeCategories = await customizeSearchService.getCategories();
+ } catch (error) {
+ console.error('Failed to load categories:', error);
+ }
});
- function getDescriptionForCategory(categoryId: string): string {
- const descriptions: Record<string, string> = {
- defaults: m.customize_category_defaults_description(),
- templates: m.customize_category_templates_description(),
- registries: m.customize_category_registries_description(),
- variables: m.customize_category_variables_description()
- };
- return descriptions[categoryId] || m.customize_fallback_description();
- }
+ async function performSearch(query: string, immediate = false) {
+ const trimmedQuery = query.trim();
- function getKeywordsForCategory(categoryId: string): string[] {
- const keywordMap: Record<string, string[]> = {
- defaults: ['defaults', 'templates', 'presets', 'configuration', 'initial'],
- templates: ['templates', 'stacks', 'compose', 'docker-compose', 'yaml', 'custom'],
- registries: ['registries', 'docker', 'images', 'authentication', 'credentials', 'private'],
- variables: ['variables', 'environment', 'config', 'settings', 'secrets', 'parameters']
- };
- return keywordMap[categoryId] || [];
- }
-
- // Search functionality
- $effect(() => {
- if (searchQuery.trim()) {
- showSearchResults = true;
- performSearch();
- } else {
- showSearchResults = false;
+ if (!trimmedQuery) {
searchResults = [];
+ showSearchResults = false;
+ isSearching = false;
+ currentSearchRequest++;
+ return;
}
- });
-
- function performSearch() {
- const query = searchQuery.toLowerCase().trim();
- const results: CustomizationCategory[] = [];
-
- customizationCategories.forEach((category) => {
- // Check if category matches
- const categoryMatch =
- category.title.toLowerCase().includes(query) ||
- category.description.toLowerCase().includes(query) ||
- category.keywords.some((keyword) => keyword.toLowerCase().includes(query));
- // Check individual customizations with enhanced matching
- const matchingCustomizations = category.customizations.filter((customization) => {
- const keyMatch = customization.key.toLowerCase().includes(query);
- const labelMatch = customization.label.toLowerCase().includes(query);
- const descriptionMatch = customization.description?.toLowerCase().includes(query) || false;
- const keywordsMatch = customization.keywords?.some((keyword) => keyword.toLowerCase().includes(query)) || false;
+ currentSearchRequest++;
+ const requestId = currentSearchRequest;
+ isSearching = true;
+ showSearchResults = true;
- return keyMatch || labelMatch || descriptionMatch || keywordsMatch;
- });
-
- if (categoryMatch || matchingCustomizations.length > 0) {
- // Calculate relevance score based on match quality
- let relevanceScore = 0;
-
- if (categoryMatch) {
- // Category title/description match gets high score
- if (category.title.toLowerCase().includes(query)) relevanceScore += 20;
- if (category.description.toLowerCase().includes(query)) relevanceScore += 15;
- if (category.keywords.some((keyword) => keyword.toLowerCase() === query)) relevanceScore += 25;
- if (category.keywords.some((keyword) => keyword.toLowerCase().includes(query))) relevanceScore += 10;
- }
-
- // Add score for individual customization matches
- matchingCustomizations.forEach((customization) => {
- if (customization.key.toLowerCase() === query) relevanceScore += 30;
- else if (customization.key.toLowerCase().includes(query)) relevanceScore += 15;
-
- if (customization.label.toLowerCase().includes(query)) relevanceScore += 12;
- if (customization.description?.toLowerCase().includes(query)) relevanceScore += 8;
-
- if (customization.keywords?.some((keyword) => keyword.toLowerCase() === query)) relevanceScore += 20;
- else if (customization.keywords?.some((keyword) => keyword.toLowerCase().includes(query))) relevanceScore += 5;
- });
-
- const categoryResult: CustomizationCategory = {
- ...category,
- matchingCustomizations: matchingCustomizations.length > 0 ? matchingCustomizations : category.customizations,
- relevanceScore
- };
- results.push(categoryResult);
+ try {
+ const response = await customizeSearchService.search(trimmedQuery);
+ if (requestId === currentSearchRequest) {
+ searchResults = response.results || [];
+ isSearching = false;
}
- });
-
- // Sort by relevance (highest first)
- searchResults = results.sort((a, b) => (b.relevanceScore || 0) - (a.relevanceScore || 0));
+ } catch (error) {
+ console.error('Search failed:', error);
+ if (requestId === currentSearchRequest) {
+ searchResults = [];
+ isSearching = false;
+ }
+ }
}
+ const debouncedSearch = debounced((query: string) => {
+ void performSearch(query, false);
+ }, 300);
+
function navigateToCategory(categoryUrl: string) {
goto(categoryUrl);
}
@@ -245,6 +81,13 @@
function clearSearch() {
searchQuery = '';
showSearchResults = false;
+ isSearching = false;
+ searchResults = [];
+ currentSearchRequest++;
+ }
+
+ function getIconComponent(iconName: string) {
+ return iconMap[iconName] || PaletteIcon;
}
</script>
@@ -276,11 +119,20 @@
</div>
<div class="relative mt-4 w-full sm:mt-6 sm:max-w-md">
- <SearchIcon class="text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2" />
+ <SearchIcon class="text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2" />
<input
type="text"
placeholder={m.customize_search_placeholder()}
- bind:value={searchQuery}
+ value={searchQuery}
+ oninput={(e) => {
+ searchQuery = e.currentTarget.value;
+ debouncedSearch(e.currentTarget.value);
+ }}
+ onkeydown={(e) => {
+ if (e.key === 'Enter') {
+ performSearch((e.currentTarget as HTMLInputElement).value, true);
+ }
+ }}
class="bg-background/50 border-input ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 pl-10 text-sm backdrop-blur-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
{#if showSearchResults}
@@ -295,8 +147,8 @@
{#if !showSearchResults}
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-6 xl:grid-cols-3">
- {#each customizationCategories as category}
- {@const Icon = category.icon}
+ {#each customizeCategories as category}
+ {@const Icon = getIconComponent(category.icon)}
<Card class="hover:border-primary/20 group cursor-pointer transition-all duration-200 hover:shadow-md">
<button onclick={() => navigateToCategory(category.url)} class="w-full p-4 text-left sm:p-6">
<div class="flex items-start justify-between gap-3">
@@ -328,7 +180,14 @@
</h2>
</div>
- {#if searchResults.length === 0}
+ {#if isSearching}
+ <div class="py-8 text-center sm:py-12">
+ <div
+ class="border-primary mx-auto mb-3 size-8 animate-spin rounded-full border-4 border-t-transparent sm:mb-4 sm:size-12"
+ ></div>
+ <p class="text-muted-foreground text-sm sm:text-base">Searching...</p>
+ </div>
+ {:else if searchResults.length === 0}
<div class="py-8 text-center sm:py-12">
<SearchIcon class="text-muted-foreground mx-auto mb-3 size-8 sm:mb-4 sm:size-12" />
<h3 class="mb-2 text-base font-medium sm:text-lg">{m.customize_no_options()}</h3>
@@ -337,7 +196,7 @@
{:else}
<div class="space-y-4 sm:space-y-6">
{#each searchResults as result}
- {@const Icon = result.icon}
+ {@const Icon = getIconComponent(result.icon)}
<div class="bg-background/40 rounded-lg border shadow-sm">
<div class="border-b p-4 sm:p-6">
<div class="flex items-center justify-between">
diff --git a/frontend/src/routes/settings/+page.svelte b/frontend/src/routes/settings/+page.svelte
index 69d9c9198..aacfede89 100644
--- a/frontend/src/routes/settings/+page.svelte
+++ b/frontend/src/routes/settings/+page.svelte
@@ -1,5 +1,6 @@
<script lang="ts">
import { goto } from '$app/navigation';
+ import { onMount } from 'svelte';
import SearchIcon from '@lucide/svelte/icons/search';
import SettingsIcon from '@lucide/svelte/icons/settings';
import DatabaseIcon from '@lucide/svelte/icons/database';
@@ -11,343 +12,69 @@
import { Card } from '$lib/components/ui/card';
import { m } from '$lib/paraglide/messages';
import { UiConfigDisabledTag } from '$lib/components/badges/index.js';
-
- interface SettingMeta {
- key: string;
- label: string;
- type: string;
- keywords?: string[];
- description?: string;
- }
-
- interface SettingsCategory {
- id: string;
- title: string;
- description: string;
- icon: any;
- url: string;
- keywords: string[];
- settings: SettingMeta[];
- matchingSettings?: SettingMeta[];
- relevanceScore?: number;
- }
+ import { settingsSearchService } from '$lib/services/settings-search';
+ import type { SettingsCategory } from '$lib/types/settings-search.type';
+ import { debounced } from '$lib/utils/utils';
let { data } = $props();
let searchQuery = $state('');
let showSearchResults = $state(false);
let searchResults = $state<SettingsCategory[]>([]);
+ let isSearching = $state(false);
+ let settingsCategories = $state<SettingsCategory[]>([]);
+ let currentSearchRequest = $state(0);
- // Settings categories with metadata
- const settingsCategories: SettingsCategory[] = [
- {
- id: 'general',
- title: m.general_title(),
- description: m.general_description(),
- icon: SettingsIcon,
- url: '/settings/general',
- keywords: ['general', 'core', 'basic', 'main'],
- settings: [
- {
- key: 'projectsDirectory',
- label: m.general_projects_directory_label(),
- type: 'text',
- description: 'Configure where project files are stored',
- keywords: ['projects', 'directory', 'path', 'folder', 'location', 'storage', 'files', 'compose', 'docker-compose']
- },
- {
- key: 'baseServerUrl',
- label: m.general_base_url_label(),
- type: 'text',
- description: 'Set the base URL for the application',
- keywords: ['base', 'url', 'server', 'domain', 'host', 'endpoint', 'address', 'link']
- },
- {
- key: 'enableGravatar',
- label: m.general_enable_gravatar_label(),
- type: 'boolean',
- description: 'Enable Gravatar profile pictures for users',
- keywords: ['gravatar', 'avatar', 'profile', 'picture', 'image', 'user', 'photo']
- }
- ]
- },
- {
- id: 'docker',
- title: m.docker_title(),
- description: 'Configure Docker settings, polling, and auto-updates',
- icon: DatabaseIcon,
- url: '/settings/docker',
- keywords: ['docker', 'container', 'image'],
- settings: [
- {
- key: 'pollingEnabled',
- label: m.docker_enable_polling_label(),
- type: 'boolean',
- description: 'Enable automatic checking for image updates',
- keywords: ['polling', 'check', 'monitor', 'watch', 'scan', 'detection', 'automatic']
- },
- {
- key: 'pollingInterval',
- label: m.docker_polling_interval_label(),
- type: 'number',
- description: 'How often to check for image updates',
- keywords: ['interval', 'frequency', 'schedule', 'time', 'minutes', 'period', 'delay']
- },
- {
- key: 'autoUpdate',
- label: m.docker_auto_update_label(),
- type: 'boolean',
- description: 'Automatically update containers when new images are available',
- keywords: ['auto', 'update', 'automatic', 'upgrade', 'refresh', 'restart', 'deploy']
- },
- {
- key: 'autoUpdateInterval',
- label: m.docker_auto_update_interval_label(),
- type: 'number',
- description: 'Interval between automatic updates',
- keywords: ['auto', 'update', 'interval', 'frequency', 'schedule', 'automatic', 'timing']
- },
- {
- key: 'dockerPruneMode',
- label: m.docker_prune_action_label(),
- type: 'select',
- description: 'Configure how unused Docker images are cleaned up',
- keywords: ['prune', 'cleanup', 'clean', 'remove', 'delete', 'unused', 'dangling', 'space', 'disk']
- }
- ]
- },
- {
- id: 'security',
- title: m.security_title(),
- description: 'Manage authentication and security settings',
- icon: ShieldIcon,
- url: '/settings/security',
- keywords: ['security', 'safety', 'protection'],
- settings: [
- {
- key: 'authLocalEnabled',
- label: m.security_local_auth_label(),
- type: 'boolean',
- description: 'Enable local username/password authentication',
- keywords: ['local', 'auth', 'authentication', 'username', 'password', 'login', 'credentials']
- },
- {
- key: 'authOidcEnabled',
- label: m.security_oidc_auth_label(),
- type: 'boolean',
- description: 'Enable OpenID Connect (OIDC) authentication',
- keywords: ['oidc', 'openid', 'connect', 'sso', 'oauth', 'external', 'provider', 'federation']
- },
- {
- key: 'authSessionTimeout',
- label: m.security_session_timeout_label(),
- type: 'number',
- description: 'How long user sessions remain active',
- keywords: ['session', 'timeout', 'expire', 'duration', 'lifetime', 'minutes', 'logout']
- },
- {
- key: 'authPasswordPolicy',
- label: m.security_password_policy_label(),
- type: 'select',
- description: 'Set password strength requirements',
- keywords: ['password', 'policy', 'strength', 'complexity', 'requirements', 'security', 'rules']
- }
- ]
- },
- {
- id: 'navigation',
- title: m.navigation_title(),
- description: m.navigation_description(),
- icon: NavigationIcon,
- url: '/settings/navigation',
- keywords: [
- 'navigation',
- 'nav',
- 'menu',
- 'bar',
- 'floating',
- 'docked',
- 'behavior',
- 'mobile',
- 'desktop',
- 'ui',
- 'interface',
- 'layout',
- 'appearance',
- 'customize'
- ],
- settings: [
- {
- key: 'sidebarHoverExpansion',
- label: m.navigation_sidebar_hover_expansion_label(),
- type: 'boolean',
- description: m.navigation_sidebar_hover_expansion_description(),
- keywords: [
- 'sidebar',
- 'hover',
- 'expansion',
- 'expand',
- 'desktop',
- 'mouse',
- 'over',
- 'collapsed',
- 'collapsible',
- 'icon',
- 'labels',
- 'text',
- 'preview',
- 'peek',
- 'tooltip',
- 'overlay',
- 'temporary',
- 'quick',
- 'access',
- 'navigation',
- 'menu',
- 'items',
- 'submenu',
- 'nested'
- ]
- },
- {
- key: 'mobileNavigationMode',
- label: m.navigation_mode_label(),
- type: 'select',
- description: m.navigation_mode_description(),
- keywords: ['mode', 'style', 'type', 'floating', 'docked', 'position', 'layout', 'design', 'appearance', 'bottom']
- },
- {
- key: 'mobileNavigationShowLabels',
- label: m.navigation_show_labels_label(),
- type: 'boolean',
- description: m.navigation_show_labels_description(),
- keywords: ['labels', 'text', 'icons', 'display', 'show', 'hide', 'names', 'captions', 'titles', 'visible', 'toggle']
- },
- {
- key: 'mobileNavigationScrollToHide',
- label: m.navigation_scroll_to_hide_label(),
- type: 'boolean',
- description: m.navigation_scroll_to_hide_description(),
- keywords: [
- 'scroll',
- 'hide',
- 'auto-hide',
- 'behavior',
- 'down',
- 'up',
- 'automatic',
- 'disappear',
- 'vanish',
- 'minimize',
- 'collapse'
- ]
- },
- {
- key: 'glassEffectEnabled',
- label: m.navigation_glass_effect_label(),
- type: 'boolean',
- description: 'Enable modern glassmorphism design with blur, gradients, and ambient effects',
- keywords: [
- 'glass',
- 'glassmorphism',
- 'blur',
- 'backdrop',
- 'frosted',
- 'effect',
- 'gradient',
- 'ambient',
- 'design',
- 'ui',
- 'appearance',
- 'modern',
- 'visual',
- 'style',
- 'theme',
- 'transparency',
- 'translucent'
- ]
- }
- ]
- },
- {
- id: 'users',
- title: m.users_title(),
- description: m.users_subtitle(),
- icon: UserIcon,
- url: '/settings/users',
- keywords: ['users', 'accounts', 'admin', 'roles', 'management', 'people'],
- settings: []
- }
- ];
+ const iconMap: Record<string, any> = {
+ settings: SettingsIcon,
+ database: DatabaseIcon,
+ shield: ShieldIcon,
+ navigation: NavigationIcon,
+ user: UserIcon
+ };
- // Search functionality
- $effect(() => {
- if (searchQuery.trim()) {
- showSearchResults = true;
- performSearch();
- } else {
- showSearchResults = false;
- searchResults = [];
+ onMount(async () => {
+ try {
+ settingsCategories = await settingsSearchService.getCategories();
+ } catch (error) {
+ console.error('Failed to load categories:', error);
}
});
- function performSearch() {
- const query = searchQuery.toLowerCase().trim();
- const results: SettingsCategory[] = [];
-
- settingsCategories.forEach((category) => {
- // Check if category matches
- const categoryMatch =
- category.title.toLowerCase().includes(query) ||
- category.description.toLowerCase().includes(query) ||
- category.keywords.some((keyword) => keyword.toLowerCase().includes(query));
-
- // Check individual settings with enhanced matching
- const matchingSettings = category.settings.filter((setting) => {
- const keyMatch = setting.key.toLowerCase().includes(query);
- const labelMatch = setting.label.toLowerCase().includes(query);
- const descriptionMatch = setting.description?.toLowerCase().includes(query) || false;
- const keywordsMatch = setting.keywords?.some((keyword) => keyword.toLowerCase().includes(query)) || false;
-
- return keyMatch || labelMatch || descriptionMatch || keywordsMatch;
- });
-
- if (categoryMatch || matchingSettings.length > 0) {
- // Calculate relevance score based on match quality
- let relevanceScore = 0;
-
- if (categoryMatch) {
- // Category title/description match gets high score
- if (category.title.toLowerCase().includes(query)) relevanceScore += 20;
- if (category.description.toLowerCase().includes(query)) relevanceScore += 15;
- if (category.keywords.some((keyword) => keyword.toLowerCase() === query)) relevanceScore += 25;
- if (category.keywords.some((keyword) => keyword.toLowerCase().includes(query))) relevanceScore += 10;
- }
+ async function performSearch(query: string, immediate = false) {
+ const trimmedQuery = query.trim();
- // Add score for individual setting matches
- matchingSettings.forEach((setting) => {
- if (setting.key.toLowerCase() === query) relevanceScore += 30;
- else if (setting.key.toLowerCase().includes(query)) relevanceScore += 15;
-
- if (setting.label.toLowerCase().includes(query)) relevanceScore += 12;
- if (setting.description?.toLowerCase().includes(query)) relevanceScore += 8;
+ if (!trimmedQuery) {
+ searchResults = [];
+ showSearchResults = false;
+ isSearching = false;
+ currentSearchRequest++;
+ return;
+ }
- if (setting.keywords?.some((keyword) => keyword.toLowerCase() === query)) relevanceScore += 20;
- else if (setting.keywords?.some((keyword) => keyword.toLowerCase().includes(query))) relevanceScore += 5;
- });
+ currentSearchRequest++;
+ const requestId = currentSearchRequest;
+ isSearching = true;
+ showSearchResults = true;
- const categoryResult: SettingsCategory = {
- ...category,
- matchingSettings: matchingSettings.length > 0 ? matchingSettings : category.settings,
- relevanceScore
- };
- results.push(categoryResult);
+ try {
+ const response = await settingsSearchService.search(trimmedQuery);
+ if (requestId === currentSearchRequest) {
+ searchResults = response.results || [];
+ isSearching = false;
}
- });
-
- // Sort by relevance (highest first)
- searchResults = results.sort((a, b) => (b.relevanceScore || 0) - (a.relevanceScore || 0));
+ } catch (error) {
+ console.error('Search failed:', error);
+ if (requestId === currentSearchRequest) {
+ searchResults = [];
+ isSearching = false;
+ }
+ }
}
+ const debouncedSearch = debounced((query: string) => {
+ void performSearch(query, false);
+ }, 300);
+
function navigateToCategory(categoryUrl: string) {
goto(categoryUrl);
}
@@ -355,6 +82,13 @@
function clearSearch() {
searchQuery = '';
showSearchResults = false;
+ isSearching = false;
+ searchResults = [];
+ currentSearchRequest++;
+ }
+
+ function getIconComponent(iconName: string) {
+ return iconMap[iconName] || SettingsIcon;
}
</script>
@@ -390,7 +124,16 @@
<input
type="text"
placeholder="Search settings..."
- bind:value={searchQuery}
+ value={searchQuery}
+ oninput={(e) => {
+ searchQuery = e.currentTarget.value;
+ debouncedSearch(e.currentTarget.value);
+ }}
+ onkeydown={(e) => {
+ if (e.key === 'Enter') {
+ performSearch((e.currentTarget as HTMLInputElement).value, true);
+ }
+ }}
class="bg-background/50 border-input ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 pl-10 text-sm backdrop-blur-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
{#if showSearchResults}
@@ -406,7 +149,7 @@
{#if !showSearchResults}
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-6 xl:grid-cols-3">
{#each settingsCategories as category}
- {@const Icon = category.icon}
+ {@const Icon = getIconComponent(category.icon)}
<Card class="hover:border-primary/20 group cursor-pointer transition-all duration-200 hover:shadow-md">
<button onclick={() => navigateToCategory(category.url)} class="w-full p-4 text-left sm:p-6">
<div class="flex items-start justify-between gap-3">
@@ -438,7 +181,14 @@
</h2>
</div>
- {#if searchResults.length === 0}
+ {#if isSearching}
+ <div class="py-8 text-center sm:py-12">
+ <div
+ class="border-primary mx-auto mb-3 size-8 animate-spin rounded-full border-4 border-t-transparent sm:mb-4 sm:size-12"
+ ></div>
+ <p class="text-muted-foreground text-sm sm:text-base">Searching...</p>
+ </div>
+ {:else if searchResults.length === 0}
<div class="py-8 text-center sm:py-12">
<SearchIcon class="text-muted-foreground mx-auto mb-3 size-8 sm:mb-4 sm:size-12" />
<h3 class="mb-2 text-base font-medium sm:text-lg">No settings found</h3>
@@ -447,7 +197,7 @@
{:else}
<div class="space-y-4 sm:space-y-6">
{#each searchResults as result}
- {@const Icon = result.icon}
+ {@const Icon = getIconComponent(result.icon)}
<div class="bg-background/40 rounded-lg border shadow-sm">
<div class="border-b p-4 sm:p-6">
<div class="flex items-center justify-between">