Skip to content

Modern Docker Management, Designed for Everyone

fix: show correct environments types in filter (#2578)

Kyle Mendell906555224c47
diff --git a/backend/internal/huma/handlers/environments.go b/backend/internal/huma/handlers/environments.go
index 3f4a127e5..091d6852a 100644
--- a/backend/internal/huma/handlers/environments.go
+++ b/backend/internal/huma/handlers/environments.go
@@ -57,6 +57,7 @@ type ListEnvironmentsInput struct {
Order string `query:"order" default:"asc" doc:"Sort direction (asc or desc)"`
Start int `query:"start" default:"0" doc:"Start index for pagination"`
Limit int `query:"limit" default:"20" doc:"Items per page"`
+ Type string `query:"type" doc:"Filter by environment type (comma-separated: http,edge,websocket,grpc,polling)"`
}
type ListEnvironmentsOutput struct {
@@ -422,6 +423,10 @@ func (h *EnvironmentHandler) ListEnvironments(ctx context.Context, input *ListEn
Start: input.Start,
Limit: input.Limit,
},
+ Filters: map[string]string{},
+ }
+ if input.Type != "" {
+ params.Filters["type"] = input.Type
}
envs, paginationResp, err := h.environmentService.ListEnvironmentsPaginated(ctx, params)
diff --git a/backend/internal/huma/handlers/templates.go b/backend/internal/huma/handlers/templates.go
index ae943e292..8d9239265 100644
--- a/backend/internal/huma/handlers/templates.go
+++ b/backend/internal/huma/handlers/templates.go
@@ -38,6 +38,7 @@ type ListTemplatesInput struct {
Order string `query:"order" default:"asc" doc:"Sort direction"`
Start int `query:"start" default:"0" doc:"Start index"`
Limit int `query:"limit" default:"20" doc:"Items per page"`
+ Type string `query:"type" doc:"Filter by template type (comma-separated: false,true)"`
}
type ListTemplatesOutput struct {
@@ -399,6 +400,9 @@ func (h *TemplateHandler) ListTemplates(ctx context.Context, input *ListTemplate
if params.Limit == 0 {
params.Limit = 20
}
+ if input.Type != "" {
+ params.Filters["type"] = input.Type
+ }
templates, paginationResp, err := h.templateService.GetAllTemplatesPaginated(ctx, params)
if err != nil {
diff --git a/backend/internal/services/environment_service.go b/backend/internal/services/environment_service.go
index fa439fd2a..aafc39567 100644
--- a/backend/internal/services/environment_service.go
+++ b/backend/internal/services/environment_service.go
@@ -455,6 +455,10 @@ func (s *EnvironmentService) GetEnvironmentByID(ctx context.Context, id string)
}
func (s *EnvironmentService) ListEnvironmentsPaginated(ctx context.Context, params pagination.QueryParams) ([]environment.Environment, pagination.Response, error) {
+ if strings.TrimSpace(params.Filters["type"]) != "" {
+ return s.listEnvironmentsPaginatedWithRuntimeFiltersInternal(ctx, params)
+ }
+
var envs []models.Environment
q := s.db.WithContext(ctx).Model(&models.Environment{}).Where("hidden = ?", false)
@@ -482,6 +486,124 @@ func (s *EnvironmentService) ListEnvironmentsPaginated(ctx context.Context, para
return out, paginationResp, nil
}
+func (s *EnvironmentService) listEnvironmentsPaginatedWithRuntimeFiltersInternal(ctx context.Context, params pagination.QueryParams) ([]environment.Environment, pagination.Response, error) {
+ var envs []models.Environment
+ if err := s.db.WithContext(ctx).
+ Model(&models.Environment{}).
+ Where("hidden = ?", false).
+ Find(&envs).Error; err != nil {
+ return nil, pagination.Response{}, fmt.Errorf("failed to list environments: %w", err)
+ }
+
+ items, mapErr := mapper.MapSlice[models.Environment, environment.Environment](envs)
+ if mapErr != nil {
+ return nil, pagination.Response{}, fmt.Errorf("failed to map environments: %w", mapErr)
+ }
+
+ for i := range items {
+ ApplyEnvironmentRuntimeState(&items[i])
+ }
+
+ config := pagination.Config[environment.Environment]{
+ SearchAccessors: []pagination.SearchAccessor[environment.Environment]{
+ func(env environment.Environment) (string, error) { return env.Name, nil },
+ func(env environment.Environment) (string, error) { return env.ApiUrl, nil },
+ },
+ SortBindings: []pagination.SortBinding[environment.Environment]{
+ {
+ Key: "id",
+ Fn: func(a, b environment.Environment) int {
+ return strings.Compare(strings.ToLower(a.ID), strings.ToLower(b.ID))
+ },
+ },
+ {
+ Key: "name",
+ Fn: func(a, b environment.Environment) int {
+ return strings.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name))
+ },
+ },
+ {
+ Key: "status",
+ Fn: func(a, b environment.Environment) int {
+ return strings.Compare(strings.ToLower(a.Status), strings.ToLower(b.Status))
+ },
+ },
+ {
+ Key: "enabled",
+ Fn: func(a, b environment.Environment) int {
+ if a.Enabled == b.Enabled {
+ return 0
+ }
+ if a.Enabled {
+ return 1
+ }
+ return -1
+ },
+ },
+ {
+ Key: "apiUrl",
+ Fn: func(a, b environment.Environment) int {
+ return strings.Compare(strings.ToLower(a.ApiUrl), strings.ToLower(b.ApiUrl))
+ },
+ },
+ },
+ FilterAccessors: []pagination.FilterAccessor[environment.Environment]{
+ {
+ Key: "status",
+ Fn: func(item environment.Environment, filterValue string) bool {
+ return strings.EqualFold(item.Status, strings.TrimSpace(filterValue))
+ },
+ },
+ {
+ Key: "enabled",
+ Fn: func(item environment.Environment, filterValue string) bool {
+ switch strings.ToLower(strings.TrimSpace(filterValue)) {
+ case "true", "1":
+ return item.Enabled
+ case "false", "0":
+ return !item.Enabled
+ default:
+ return true
+ }
+ },
+ },
+ {
+ Key: "type",
+ Fn: environmentTypeMatchesInternal,
+ },
+ },
+ }
+
+ result := pagination.SearchOrderAndPaginate(items, params, config)
+ paginationResp := pagination.BuildResponseFromFilterResult(result, params)
+
+ return result.Items, paginationResp, nil
+}
+
+func environmentTypeMatchesInternal(env environment.Environment, filterValue string) bool {
+ return environmentTypeKeyInternal(env) == strings.ToLower(strings.TrimSpace(filterValue))
+}
+
+func environmentTypeKeyInternal(env environment.Environment) string {
+ if !env.IsEdge {
+ return "http"
+ }
+ if env.LastPollAt != nil {
+ return "polling"
+ }
+ if env.Connected == nil || !*env.Connected || env.EdgeTransport == nil || strings.TrimSpace(*env.EdgeTransport) == "" {
+ return "edge"
+ }
+ switch strings.ToLower(strings.TrimSpace(*env.EdgeTransport)) {
+ case edge.EdgeTransportWebSocket:
+ return "websocket"
+ case edge.EdgeTransportGRPC:
+ return "grpc"
+ default:
+ return "edge"
+ }
+}
+
func (s *EnvironmentService) ListVisibleEnvironments(ctx context.Context) ([]environment.Environment, error) {
var envs []models.Environment
if err := s.db.WithContext(ctx).
diff --git a/backend/internal/services/environment_service_test.go b/backend/internal/services/environment_service_test.go
index e21b3a56b..a2e0b4139 100644
--- a/backend/internal/services/environment_service_test.go
+++ b/backend/internal/services/environment_service_test.go
@@ -24,7 +24,9 @@ import (
"github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge"
"github.com/getarcaneapp/arcane/backend/pkg/pagination"
"github.com/getarcaneapp/arcane/types/containerregistry"
+ "github.com/getarcaneapp/arcane/types/environment"
"github.com/getarcaneapp/arcane/types/gitops"
+ "github.com/gorilla/websocket"
)
func setupEnvironmentServiceTestDB(t *testing.T) *database.DB {
@@ -700,6 +702,128 @@ func TestEnvironmentService_ListMethods_ExcludeHiddenEnvironments(t *testing.T)
require.Equal(t, "env-visible", remoteEnvironments[0].ID)
}
+func TestEnvironmentService_ListEnvironmentsPaginated_FiltersByRuntimeType(t *testing.T) {
+ ctx := context.Background()
+ db := setupEnvironmentServiceTestDB(t)
+ svc := NewEnvironmentService(db, nil, nil, nil, nil, nil)
+
+ now := time.Now()
+ envs := []models.Environment{
+ {
+ BaseModel: models.BaseModel{ID: "0", CreatedAt: now, UpdatedAt: &now},
+ Name: "Local",
+ ApiUrl: "http://localhost:3552",
+ Status: string(models.EnvironmentStatusOnline),
+ Enabled: true,
+ },
+ {
+ BaseModel: models.BaseModel{ID: "env-edge", CreatedAt: now, UpdatedAt: &now},
+ Name: "Edge",
+ ApiUrl: "edge://agent",
+ Status: string(models.EnvironmentStatusOffline),
+ Enabled: true,
+ IsEdge: true,
+ },
+ {
+ BaseModel: models.BaseModel{ID: "env-grpc", CreatedAt: now, UpdatedAt: &now},
+ Name: "gRPC",
+ ApiUrl: "edge://grpc",
+ Status: string(models.EnvironmentStatusOffline),
+ Enabled: true,
+ IsEdge: true,
+ },
+ {
+ BaseModel: models.BaseModel{ID: "env-websocket", CreatedAt: now, UpdatedAt: &now},
+ Name: "WebSocket",
+ ApiUrl: "edge://websocket",
+ Status: string(models.EnvironmentStatusOffline),
+ Enabled: true,
+ IsEdge: true,
+ },
+ {
+ BaseModel: models.BaseModel{ID: "env-polling", CreatedAt: now, UpdatedAt: &now},
+ Name: "Polling",
+ ApiUrl: "edge://polling",
+ Status: string(models.EnvironmentStatusOffline),
+ Enabled: true,
+ IsEdge: true,
+ },
+ }
+ require.NoError(t, db.WithContext(ctx).Create(&envs).Error)
+
+ edge.GetRegistry().Unregister("env-grpc")
+ edge.GetRegistry().Unregister("env-websocket")
+ edge.GetRegistry().Unregister("env-polling")
+ t.Cleanup(func() {
+ edge.GetRegistry().Unregister("env-grpc")
+ edge.GetRegistry().Unregister("env-websocket")
+ edge.GetRegistry().Unregister("env-polling")
+ })
+
+ grpcTunnel := edge.NewAgentTunnelWithConn("env-grpc", edge.NewGRPCManagerTunnelConn(nil))
+ edge.GetRegistry().Register("env-grpc", grpcTunnel)
+
+ websocketTunnel, closeWebSocketTunnel := newTestWebSocketTunnelInternal(t, "env-websocket")
+ defer closeWebSocketTunnel()
+ edge.GetRegistry().Register("env-websocket", websocketTunnel)
+
+ edge.GetPollRuntimeRegistry().Update("env-polling", edge.DefaultTunnelPollInterval, time.Now())
+
+ tests := []struct {
+ name string
+ typeFilter string
+ wantIDs []string
+ }{
+ {name: "http", typeFilter: "http", wantIDs: []string{"0"}},
+ {name: "edge", typeFilter: "edge", wantIDs: []string{"env-edge"}},
+ {name: "grpc", typeFilter: "grpc", wantIDs: []string{"env-grpc"}},
+ {name: "websocket", typeFilter: "websocket", wantIDs: []string{"env-websocket"}},
+ {name: "polling", typeFilter: "polling", wantIDs: []string{"env-polling"}},
+ {name: "multiple", typeFilter: "http,polling", wantIDs: []string{"0", "env-polling"}},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ listedEnvironments, _, err := svc.ListEnvironmentsPaginated(ctx, pagination.QueryParams{
+ PaginationParams: pagination.PaginationParams{Start: 0, Limit: 20},
+ Filters: map[string]string{"type": tt.typeFilter},
+ })
+ require.NoError(t, err)
+ require.ElementsMatch(t, tt.wantIDs, environmentIDsInternal(listedEnvironments))
+ })
+ }
+}
+
+func environmentIDsInternal(environments []environment.Environment) []string {
+ ids := make([]string, 0, len(environments))
+ for _, env := range environments {
+ ids = append(ids, env.ID)
+ }
+ return ids
+}
+
+func newTestWebSocketTunnelInternal(t *testing.T, envID string) (*edge.AgentTunnel, func()) {
+ t.Helper()
+
+ connCh := make(chan *websocket.Conn, 1)
+ upgrader := websocket.Upgrader{}
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ conn, err := upgrader.Upgrade(w, r, nil)
+ require.NoError(t, err)
+ connCh <- conn
+ }))
+
+ wsURL := "ws" + strings.TrimPrefix(server.URL, "http")
+ clientConn, _, err := websocket.DefaultDialer.Dial(wsURL, nil)
+ require.NoError(t, err)
+
+ serverConn := <-connCh
+ return edge.NewAgentTunnelWithConn(envID, edge.NewTunnelConn(serverConn)), func() {
+ _ = clientConn.Close()
+ server.Close()
+ }
+}
+
func TestEnvironmentService_GenerateEdgeDeploymentSnippets_WithAutoGeneratedMTLS(t *testing.T) {
crypto.InitEncryption(&crypto.Config{
EncryptionKey: "test-encryption-key-for-testing-32bytes-min",
diff --git a/backend/internal/services/template_service_test.go b/backend/internal/services/template_service_test.go
index 47ab4f7e7..c2db93083 100644
--- a/backend/internal/services/template_service_test.go
+++ b/backend/internal/services/template_service_test.go
@@ -20,7 +20,9 @@ import (
"github.com/getarcaneapp/arcane/backend/internal/common"
"github.com/getarcaneapp/arcane/backend/internal/database"
"github.com/getarcaneapp/arcane/backend/internal/models"
+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"
httputils "github.com/getarcaneapp/arcane/backend/pkg/utils/httpx"
+ tmpl "github.com/getarcaneapp/arcane/types/template"
)
func setupTemplateServiceTestDB(t *testing.T) *database.DB {
@@ -290,6 +292,81 @@ services:
require.Equal(t, "https://cdn.example/download.png", *stored.Metadata.IconURL)
}
+func TestGetAllTemplatesPaginated_FiltersByType(t *testing.T) {
+ tempDir := t.TempDir()
+ setTestWorkingDir(t, tempDir)
+
+ now := time.Now()
+ db := setupTemplateServiceTestDB(t)
+ localTemplates := []models.ComposeTemplate{
+ {
+ BaseModel: models.BaseModel{ID: "local-one", CreatedAt: now, UpdatedAt: &now},
+ Name: "Local One",
+ Description: "Local template",
+ Content: "services: {}",
+ IsCustom: true,
+ IsRemote: false,
+ },
+ {
+ BaseModel: models.BaseModel{ID: "local-two", CreatedAt: now, UpdatedAt: &now},
+ Name: "Local Two",
+ Description: "Local template",
+ Content: "services: {}",
+ IsCustom: true,
+ IsRemote: false,
+ },
+ }
+ require.NoError(t, db.WithContext(context.Background()).Create(&localTemplates).Error)
+
+ service := &TemplateService{
+ db: db,
+ httpClient: http.DefaultClient,
+ registryFetchMeta: make(map[string]*registryFetchMeta),
+ remoteCache: remoteCache{
+ templates: []models.ComposeTemplate{
+ {
+ BaseModel: models.BaseModel{ID: "remote-one", CreatedAt: now, UpdatedAt: &now},
+ Name: "Remote One",
+ Description: "Remote template",
+ Content: "services: {}",
+ IsRemote: true,
+ RegistryID: stringPtr("registry-one"),
+ },
+ },
+ lastFetch: now,
+ },
+ }
+
+ tests := []struct {
+ name string
+ typeFilter string
+ wantIDs []string
+ }{
+ {name: "local", typeFilter: "false", wantIDs: []string{"local-one", "local-two"}},
+ {name: "remote", typeFilter: "true", wantIDs: []string{"remote-one"}},
+ {name: "both", typeFilter: "false,true", wantIDs: []string{"local-one", "local-two", "remote-one"}},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ templates, _, err := service.GetAllTemplatesPaginated(context.Background(), pagination.QueryParams{
+ PaginationParams: pagination.PaginationParams{Start: 0, Limit: 20},
+ Filters: map[string]string{"type": tt.typeFilter},
+ })
+ require.NoError(t, err)
+ require.ElementsMatch(t, tt.wantIDs, templateIDsInternal(templates))
+ })
+ }
+}
+
+func templateIDsInternal(templates []tmpl.Template) []string {
+ ids := make([]string, 0, len(templates))
+ for _, template := range templates {
+ ids = append(ids, template.ID)
+ }
+ return ids
+}
+
func TestFetchRaw_BlocksUnsafeRemoteURL(t *testing.T) {
service := &TemplateService{
httpClient: http.DefaultClient,
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index bcb6c526f..60a12d0a2 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1246,6 +1246,10 @@
"environments_basic_info_description": "Basic environment information and settings",
"environments_enable_disable_description": "Enable or disable this environment",
"environments_local_badge": "Local",
+ "environments_edge_http_label": "HTTP",
+ "environments_edge_label": "Edge",
+ "environments_edge_websocket_label": "WebSocket",
+ "environments_edge_grpc_label": "gRPC",
"environments_docker_settings_title": "Docker Settings",
"environments_config_description": "Configuration for this environment",
"environments_api_url_help": "The base URL for the environment's API",
diff --git a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
index e2efdf286..730ff351a 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
+++ b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
@@ -7,7 +7,6 @@
usageFilters,
severityFilters,
vulnerabilitySeverityFilters,
- templateTypeFilters,
projectStatusFilters
} from './data.js';
import { debounced } from '$lib/utils/utils.js';
@@ -16,7 +15,7 @@
import type { Snippet } from 'svelte';
import { cn } from '$lib/utils';
import { ResetIcon, SearchIcon, FilterIcon } from '$lib/icons';
- import type { BulkAction } from './arcane-table.types.svelte';
+ import type { BulkAction, FilterOption } from './arcane-table.types.svelte';
import * as Popover from '$lib/components/ui/popover/index.js';
let {
@@ -64,6 +63,9 @@
table.getAllColumns().some((col) => col.id === 'serviceCount') ? table.getColumn('serviceCount') : undefined
);
const typeColumn = $derived(table.getAllColumns().some((col) => col.id === 'type') ? table.getColumn('type') : undefined);
+ const typeColumnFilterOptions = $derived(
+ (typeColumn?.columnDef.meta as { filterOptions?: FilterOption[] } | undefined)?.filterOptions ?? []
+ );
const debouncedSetGlobal = debounced((v: string) => table.setGlobalFilter(v), 300);
const imageNameFilterOptionsFormatted = $derived(imageNameFilterOptions.map((name) => ({ label: name, value: name })));
@@ -73,7 +75,7 @@
// Check if any filter columns exist
const hasFilterColumns = $derived(
!withoutFilters &&
- (!!(typeColumn && !severityColumn && !vulnSeverityColumn) ||
+ (!!(typeColumn && typeColumnFilterOptions.length > 0 && !severityColumn && !vulnSeverityColumn) ||
!!usageColumn ||
!!updatesColumn ||
!!severityColumn ||
@@ -102,8 +104,8 @@
{#if hasFilterColumns}
<div class="hidden items-center gap-1.5 md:flex">
- {#if typeColumn && !severityColumn && !vulnSeverityColumn}
- <DataTableFacetedFilter column={typeColumn} title={m.common_type()} options={templateTypeFilters} />
+ {#if typeColumn && typeColumnFilterOptions.length > 0 && !severityColumn && !vulnSeverityColumn}
+ <DataTableFacetedFilter column={typeColumn} title={m.common_type()} options={typeColumnFilterOptions} />
{/if}
{#if usageColumn}
<DataTableFacetedFilter column={usageColumn} title={m.common_usage()} options={usageFilters} />
@@ -146,8 +148,8 @@
</Popover.Trigger>
<Popover.Content align="end" class="w-56 p-2">
<div class="flex flex-col gap-1.5">
- {#if typeColumn && !severityColumn && !vulnSeverityColumn}
- <DataTableFacetedFilter column={typeColumn} title={m.common_type()} options={templateTypeFilters} />
+ {#if typeColumn && typeColumnFilterOptions.length > 0 && !severityColumn && !vulnSeverityColumn}
+ <DataTableFacetedFilter column={typeColumn} title={m.common_type()} options={typeColumnFilterOptions} />
{/if}
{#if usageColumn}
<DataTableFacetedFilter column={usageColumn} title={m.common_usage()} options={usageFilters} />
diff --git a/frontend/src/lib/components/arcane-table/arcane-table.svelte b/frontend/src/lib/components/arcane-table/arcane-table.svelte
index 607bddb15..039f936dd 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table.svelte
+++ b/frontend/src/lib/components/arcane-table/arcane-table.svelte
@@ -320,6 +320,7 @@
...(accessorFn ? { accessorFn } : {}),
meta: {
title: spec.title,
+ filterOptions: spec.filterOptions,
width: spec.width,
align: spec.align,
truncate: spec.truncate
diff --git a/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts b/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
index 96faa8f58..fa5606fa6 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
+++ b/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
@@ -1,5 +1,13 @@
import type { Row, Column, FilterFn, ColumnFiltersState, VisibilityState } from '@tanstack/table-core';
import type { Snippet } from 'svelte';
+import type { Component } from 'svelte';
+
+export interface FilterOption {
+ value: string | boolean;
+ label: string;
+ icon?: Component;
+ dotClass?: string;
+}
export type FieldSpec = {
id: string;
@@ -26,6 +34,7 @@ export type ColumnSpec<T> = {
header?: Snippet<[{ column: Column<T>; title: string; class?: string }]>;
class?: string;
filterFn?: FilterFn<T>;
+ filterOptions?: FilterOption[];
width?: ColumnWidth;
align?: ColumnAlign;
truncate?: boolean;
diff --git a/frontend/src/lib/components/arcane-table/data.ts b/frontend/src/lib/components/arcane-table/data.ts
index 28df504ba..dc1629f89 100644
--- a/frontend/src/lib/components/arcane-table/data.ts
+++ b/frontend/src/lib/components/arcane-table/data.ts
@@ -11,15 +11,9 @@ import {
StartIcon,
StopIcon
} from '$lib/icons';
+import type { FilterOption } from './arcane-table.types.svelte';
-export interface FilterOption {
- value: string | boolean;
- label: string;
- icon?: any;
- dotClass?: string;
-}
-
-export const usageFilters = [
+export const usageFilters: FilterOption[] = [
{
value: true,
label: m.common_in_use(),
@@ -32,7 +26,7 @@ export const usageFilters = [
}
];
-export const imageUpdateFilters = [
+export const imageUpdateFilters: FilterOption[] = [
{
value: 'has_update',
label: m.images_has_updates(),
@@ -55,7 +49,7 @@ export const imageUpdateFilters = [
}
];
-export const severityFilters = [
+export const severityFilters: FilterOption[] = [
{
value: 'info',
label: m.events_info(),
@@ -78,7 +72,7 @@ export const severityFilters = [
}
];
-export const vulnerabilitySeverityFilters = [
+export const vulnerabilitySeverityFilters: FilterOption[] = [
{
value: 'CRITICAL',
label: m.vuln_severity_critical(),
@@ -106,7 +100,7 @@ export const vulnerabilitySeverityFilters = [
}
];
-export const templateTypeFilters = [
+export const templateTypeFilters: FilterOption[] = [
{
value: 'false',
label: m.templates_local(),
@@ -119,7 +113,7 @@ export const templateTypeFilters = [
}
];
-export const projectStatusFilters = [
+export const projectStatusFilters: FilterOption[] = [
{
value: 'running',
label: m.common_running(),
diff --git a/frontend/src/routes/(app)/customize/templates/template-table.svelte b/frontend/src/routes/(app)/customize/templates/template-table.svelte
index ff041101b..21d6c4a93 100644
--- a/frontend/src/routes/(app)/customize/templates/template-table.svelte
+++ b/frontend/src/routes/(app)/customize/templates/template-table.svelte
@@ -14,6 +14,7 @@
import type { Template } from '$lib/types/template.type';
import type { ColumnSpec, MobileFieldVisibility } from '$lib/components/arcane-table';
import { m } from '$lib/paraglide/messages';
+ import { templateTypeFilters } from '$lib/components/arcane-table/data';
import { templateService } from '$lib/services/template-service';
import { truncateString } from '$lib/utils/string.utils';
import { PersistedState } from 'runed';
@@ -103,6 +104,7 @@
accessorFn: (row) => row.isRemote,
title: m.common_type(),
sortable: true,
+ filterOptions: templateTypeFilters,
cell: TypeCell
},
{
@@ -199,7 +201,7 @@
{#snippet TagsCell({ item }: { item: Template })}
{#if item.metadata?.tags && item.metadata.tags.length > 0}
<div class="flex flex-wrap gap-1">
- {#each item.metadata.tags.slice(0, 2) as tag}
+ {#each item.metadata.tags.slice(0, 2) as tag (tag)}
<Badge variant="outline" class="text-xs">{tag}</Badge>
{/each}
{#if item.metadata.tags.length > 2}
@@ -250,7 +252,7 @@
{m.common_tags()}
</div>
<div class="mt-1 flex flex-wrap gap-1">
- {#each item.metadata.tags.slice(0, 3) as tag}
+ {#each item.metadata.tags.slice(0, 3) as tag (tag)}
<Badge variant="outline" class="text-xs">{tag}</Badge>
{/each}
{#if item.metadata.tags.length > 3}
diff --git a/frontend/src/routes/(app)/environments/environment-table.svelte b/frontend/src/routes/(app)/environments/environment-table.svelte
index 807517959..2bdba1d1b 100644
--- a/frontend/src/routes/(app)/environments/environment-table.svelte
+++ b/frontend/src/routes/(app)/environments/environment-table.svelte
@@ -12,6 +12,7 @@
import { extractApiErrorMessage } from '$lib/utils/api.util';
import type { Paginated, SearchPaginationSortRequest } from '$lib/types/pagination.type';
import type { ColumnSpec, MobileFieldVisibility, BulkAction } from '$lib/components/arcane-table';
+ import type { FilterOption } from '$lib/components/arcane-table/arcane-table.types.svelte';
import { UniversalMobileCard } from '$lib/components/arcane-table';
import type { Environment } from '$lib/types/environment.type';
import { m } from '$lib/paraglide/messages';
@@ -49,6 +50,22 @@
});
const isAdmin = $derived(!!currentUser?.roles?.includes('admin'));
+ const environmentTypeFilters: FilterOption[] = [
+ { value: 'http', label: m.environments_edge_http_label(), icon: EnvironmentsIcon },
+ { value: 'edge', label: m.environments_edge_label(), icon: EnvironmentsIcon },
+ { value: 'websocket', label: m.environments_edge_websocket_label(), icon: EnvironmentsIcon },
+ { value: 'grpc', label: m.environments_edge_grpc_label(), icon: EnvironmentsIcon },
+ { value: 'polling', label: m.environments_edge_polling_label(), icon: EnvironmentsIcon }
+ ];
+
+ function getEnvironmentTypeLabel(item: Environment): string {
+ if (!item.isEdge) return m.environments_edge_http_label();
+ if (item.lastPollAt) return m.environments_edge_polling_label();
+ if (!item.connected || !item.edgeTransport) return m.environments_edge_label();
+ if (item.edgeTransport === 'websocket') return m.environments_edge_websocket_label();
+ return m.environments_edge_grpc_label();
+ }
+
async function handleDeleteSelected(ids: string[]) {
if (!ids?.length) return;
@@ -218,6 +235,7 @@
id: 'type',
title: m.common_type(),
accessorFn: (row) => row,
+ filterOptions: environmentTypeFilters,
cell: TypeCell
},
{
@@ -298,15 +316,7 @@
{#snippet TypeCell({ value }: { value: unknown })}
{@const env = value as Environment}
- {@const typeLabel = !env.isEdge
- ? 'HTTP'
- : env.lastPollAt
- ? m.environments_edge_polling_label()
- : !env.connected || !env.edgeTransport
- ? 'Edge'
- : env.edgeTransport === 'websocket'
- ? 'WebSocket'
- : 'gRPC'}
+ {@const typeLabel = getEnvironmentTypeLabel(env)}
{@const typeVariant = !env.isEdge
? 'gray'
: env.lastPollAt
@@ -353,16 +363,7 @@
},
{
label: m.common_type(),
- getValue: (item: Environment) =>
- !item.isEdge
- ? 'HTTP'
- : item.lastPollAt
- ? m.environments_edge_polling_label()
- : !item.connected || !item.edgeTransport
- ? 'Edge'
- : item.edgeTransport === 'websocket'
- ? 'WebSocket'
- : 'gRPC',
+ getValue: (item: Environment) => getEnvironmentTypeLabel(item),
icon: StatsIcon,
iconVariant: 'gray' as const,
show: mobileFieldVisibility.type ?? true