Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/lib/components/TagEditPopover.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { tick } from 'svelte';
import * as Popover from '$lib/components/ui/popover';
import { Input } from '$lib/components/ui/input';
import { Check, Tag as TagIcon } from 'lucide-svelte';
Expand All @@ -19,13 +20,30 @@
}
let { open = $bindable(false), catalog, selected, onCreate, onApply, allowCreate = false }: Props = $props();

// The heavy Popover.Root (bits-ui floating-ui context + portal) is only mounted once
// the user actually opens this row's editor. Before that each row renders a plain
// button, so toggling "inline tag editing" across a big grid mounts N cheap buttons
// instead of N popovers - the difference between instant and multi-second. Once
// mounted the Root stays (only this row's, not all N), so re-opens are normal.
let activated = $state(open);
// Mount the Root first, THEN open on the next microtask: bits-ui positions the content
// against a trigger that is already in the DOM, so opening after mount is reliable.
async function activate() {
activated = true;
await tick();
open = true;
}
// A parent that drives `open` (rare) still forces the Root to mount.
$effect(() => { if (open) activated = true; });

let query = $state('');
let newColor = $state<TagColor>('blue');
let newIcon = $state<string | null>(null);
let iconSearch = $state('');
let creating = $state(false);

const allIconNames = Object.keys(iconMap);
// Gated on activated so an un-opened row (the common case on a big grid) does no work.
const allIconNames = $derived(activated ? Object.keys(iconMap) : []);
const iconResults = $derived(
iconSearch.trim()
? allIconNames.filter((n) => n.toLowerCase().includes(iconSearch.trim().toLowerCase()))
Expand Down Expand Up @@ -66,6 +84,13 @@
}
</script>

{#if !activated}
<!-- Cheap placeholder: no Popover.Root until the user opens this row's editor. -->
<button type="button" title="Edit tags" onclick={activate}
class="inline-flex h-4 w-4 items-center justify-center rounded text-muted-foreground/60 hover:text-foreground">
<TagIcon class="h-3 w-3" />
</button>
{:else}
<Popover.Root bind:open>
<Popover.Trigger>
{#snippet child({ props })}
Expand Down Expand Up @@ -139,3 +164,4 @@
</div>
</Popover.Content>
</Popover.Root>
{/if}
81 changes: 55 additions & 26 deletions src/lib/components/TagFilter.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import * as Popover from '$lib/components/ui/popover';
import { Button } from '$lib/components/ui/button';
import { Tag as TagIcon, Check, ChevronDown, Rows3, Paintbrush } from 'lucide-svelte';
import { Tag as TagIcon, Check, ChevronDown, ChevronRight, Rows3, Paintbrush, Pencil, Settings2 } from 'lucide-svelte';
import { TogglePill } from '$lib/components/ui/toggle-pill';
import TagLucideIcon from '$lib/components/TagLucideIcon.svelte';
import { tagHex } from '$lib/utils/tags-core';
Expand All @@ -15,9 +15,14 @@
groupBy?: boolean; // 'group rows by tag' toggle (bindable); omit to hide it
showTags?: boolean; // 'show tag chips on rows' toggle (bindable); omit to hide it
showBands?: boolean; // 'coloured group bands' toggle (bindable); shown only while groupBy is on
inlineEditing?: boolean; // 'show a tag button on each row' toggle (bindable); omit to hide it
settingsExpanded?: boolean; // collapsed state of the settings section (bindable)
width?: string;
}
let { tags, selected = $bindable([]), mode = $bindable('all'), groupBy = $bindable(undefined), showTags = $bindable(undefined), showBands = $bindable(undefined), width = 'w-44' }: Props = $props();
let { tags, selected = $bindable([]), mode = $bindable('all'), groupBy = $bindable(undefined), showTags = $bindable(undefined), showBands = $bindable(undefined), inlineEditing = $bindable(undefined), settingsExpanded = $bindable(true), width = 'w-44' }: Props = $props();

// Whether any of the settings toggles are present, so the section only renders when it has content.
const hasSettings = $derived(groupBy !== undefined || showTags !== undefined || inlineEditing !== undefined);

let open = $state(false);

Expand All @@ -35,37 +40,61 @@
<Button {...props} variant="outline" size="sm" class="{width} justify-between font-normal">
<span class="flex items-center gap-1.5 truncate">
<TagIcon class="h-3.5 w-3.5 text-muted-foreground" />
<span class="truncate">{label}</span>
<span class="truncate {selected.length === 0 ? 'text-muted-foreground' : ''}">{label}</span>
</span>
<ChevronDown class="h-3.5 w-3.5 text-muted-foreground shrink-0" />
</Button>
{/snippet}
</Popover.Trigger>
<Popover.Content class="w-60 p-1" align="start">
{#if groupBy !== undefined}
<div class="flex items-center gap-2 px-2 py-1.5">
<Rows3 class="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<span class="text-xs flex-1">Group by tag</span>
<TogglePill bind:checked={groupBy} />
</div>
{#if showBands !== undefined && groupBy}
<!-- Only meaningful while grouping is on. Same padding as the other rows so
the icon column lines up on the left and the toggle on the right. -->
<div class="flex items-center gap-2 px-2 py-1.5">
<Paintbrush class="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<span class="text-xs flex-1 whitespace-nowrap">Color group bands</span>
<TogglePill bind:checked={showBands} />
</div>
{#if hasSettings}
<!-- Collapsible settings section, open by default. The header toggles it; the
state is persisted by the parent page (localStorage). -->
<button
type="button"
class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-muted-foreground hover:bg-muted"
onclick={() => (settingsExpanded = !settingsExpanded)}
>
<Settings2 class="h-3.5 w-3.5 shrink-0" />
<span class="text-xs flex-1 text-left">Settings</span>
{#if settingsExpanded}
<ChevronDown class="h-3.5 w-3.5 shrink-0" />
{:else}
<ChevronRight class="h-3.5 w-3.5 shrink-0" />
{/if}
</button>
{#if settingsExpanded}
{#if groupBy !== undefined}
<div class="flex items-center gap-2 px-2 py-1.5">
<Rows3 class="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<span class="text-xs flex-1">Group by tag</span>
<TogglePill bind:checked={groupBy} />
</div>
{#if showBands !== undefined && groupBy}
<!-- Only meaningful while grouping is on. Same padding as the other rows so
the icon column lines up on the left and the toggle on the right. -->
<div class="flex items-center gap-2 px-2 py-1.5">
<Paintbrush class="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<span class="text-xs flex-1 whitespace-nowrap">Color group bands</span>
<TogglePill bind:checked={showBands} />
</div>
{/if}
{/if}
{#if showTags !== undefined}
<div class="flex items-center gap-2 px-2 py-1.5">
<TagIcon class="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<span class="text-xs flex-1">Show tags</span>
<TogglePill bind:checked={showTags} />
</div>
{/if}
{#if inlineEditing !== undefined}
<div class="flex items-center gap-2 px-2 py-1.5">
<Pencil class="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<span class="text-xs flex-1 whitespace-nowrap">Inline tag editing</span>
<TogglePill bind:checked={inlineEditing} />
</div>
{/if}
{/if}
{/if}
{#if showTags !== undefined}
<div class="flex items-center gap-2 px-2 py-1.5">
<TagIcon class="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<span class="text-xs flex-1">Show tags</span>
<TogglePill bind:checked={showTags} />
</div>
{/if}
{#if groupBy !== undefined || showTags !== undefined}
<div class="my-1 h-px bg-border"></div>
{/if}
{#if tags.length === 0}
Expand Down
4 changes: 0 additions & 4 deletions src/lib/openapi.generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -24265,9 +24265,6 @@
"editorIndentGuides": {
"type": "boolean"
},
"inlineTagEditing": {
"type": "boolean"
},
"coloredActionButtons": {
"type": "boolean"
},
Expand Down Expand Up @@ -24438,7 +24435,6 @@
"example": {
"animateIcons": true,
"editorIndentGuides": true,
"inlineTagEditing": true,
"coloredActionButtons": true,
"lightTheme": "string",
"darkTheme": "string",
Expand Down
11 changes: 0 additions & 11 deletions src/lib/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface AppSettings {
confirmDestructive: boolean;
showStoppedContainers: boolean;
highlightUpdates: boolean;
inlineTagEditing: boolean;
showGitCommitHash: boolean;
timeFormat: TimeFormat;
dateFormat: DateFormat;
Expand Down Expand Up @@ -72,7 +71,6 @@ const DEFAULT_SETTINGS: AppSettings = {
confirmDestructive: true,
showStoppedContainers: true,
highlightUpdates: true,
inlineTagEditing: false,
showGitCommitHash: false,
timeFormat: '24h',
dateFormat: 'DD.MM.YYYY',
Expand Down Expand Up @@ -166,7 +164,6 @@ function createSettingsStore() {
confirmDestructive: settings.confirmDestructive ?? DEFAULT_SETTINGS.confirmDestructive,
showStoppedContainers: settings.showStoppedContainers ?? DEFAULT_SETTINGS.showStoppedContainers,
highlightUpdates: settings.highlightUpdates ?? DEFAULT_SETTINGS.highlightUpdates,
inlineTagEditing: settings.inlineTagEditing ?? DEFAULT_SETTINGS.inlineTagEditing,
showGitCommitHash: settings.showGitCommitHash ?? DEFAULT_SETTINGS.showGitCommitHash,
timeFormat: settings.timeFormat ?? DEFAULT_SETTINGS.timeFormat,
dateFormat: settings.dateFormat ?? DEFAULT_SETTINGS.dateFormat,
Expand Down Expand Up @@ -230,7 +227,6 @@ function createSettingsStore() {
confirmDestructive: updatedSettings.confirmDestructive ?? DEFAULT_SETTINGS.confirmDestructive,
showStoppedContainers: updatedSettings.showStoppedContainers ?? DEFAULT_SETTINGS.showStoppedContainers,
highlightUpdates: updatedSettings.highlightUpdates ?? DEFAULT_SETTINGS.highlightUpdates,
inlineTagEditing: updatedSettings.inlineTagEditing ?? DEFAULT_SETTINGS.inlineTagEditing,
showGitCommitHash: updatedSettings.showGitCommitHash ?? DEFAULT_SETTINGS.showGitCommitHash,
timeFormat: updatedSettings.timeFormat ?? DEFAULT_SETTINGS.timeFormat,
dateFormat: updatedSettings.dateFormat ?? DEFAULT_SETTINGS.dateFormat,
Expand Down Expand Up @@ -325,13 +321,6 @@ function createSettingsStore() {
return newSettings;
});
},
setInlineTagEditing: (value: boolean) => {
update((current) => {
const newSettings = { ...current, inlineTagEditing: value };
saveSettings({ inlineTagEditing: value });
return newSettings;
});
},
setUseSelfhstIcons: (value: boolean) => {
update((current) => {
const newSettings = { ...current, useSelfhstIcons: value };
Expand Down
15 changes: 2 additions & 13 deletions src/routes/api/settings/general/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export interface GeneralSettings {
confirmDestructive: boolean;
showStoppedContainers: boolean;
highlightUpdates: boolean;
inlineTagEditing: boolean;
coloredActionButtons: boolean;
actionIconSize: ActionIconSize;
timeFormat: TimeFormat;
Expand Down Expand Up @@ -144,7 +143,6 @@ const DEFAULT_SETTINGS: Omit<GeneralSettings, 'scheduleRetentionDays' | 'eventRe
confirmDestructive: true,
showStoppedContainers: true,
highlightUpdates: true,
inlineTagEditing: false,
coloredActionButtons: false,
actionIconSize: 'normal' as const,
timeFormat: '24h',
Expand Down Expand Up @@ -253,7 +251,6 @@ export const GET: RequestHandler = async ({ cookies }) => {
confirmDestructive,
showStoppedContainers,
highlightUpdates,
inlineTagEditing,
coloredActionButtons,
actionIconSize,
timeFormat,
Expand Down Expand Up @@ -310,7 +307,6 @@ export const GET: RequestHandler = async ({ cookies }) => {
getSetting('confirm_destructive'),
getSetting('show_stopped_containers'),
getSetting('highlight_updates'),
getSetting('inline_tag_editing'),
getSetting('colored_action_buttons'),
getSetting('action_icon_size'),
getSetting('time_format'),
Expand Down Expand Up @@ -369,7 +365,6 @@ export const GET: RequestHandler = async ({ cookies }) => {
confirmDestructive: confirmDestructive ?? DEFAULT_SETTINGS.confirmDestructive,
showStoppedContainers: showStoppedContainers ?? DEFAULT_SETTINGS.showStoppedContainers,
highlightUpdates: highlightUpdates ?? DEFAULT_SETTINGS.highlightUpdates,
inlineTagEditing: inlineTagEditing ?? DEFAULT_SETTINGS.inlineTagEditing,
coloredActionButtons: coloredActionButtons ?? DEFAULT_SETTINGS.coloredActionButtons,
actionIconSize: (VALID_ACTION_ICON_SIZES.includes(actionIconSize as ActionIconSize) ? actionIconSize : DEFAULT_SETTINGS.actionIconSize) as ActionIconSize,
timeFormat: timeFormat ?? DEFAULT_SETTINGS.timeFormat,
Expand Down Expand Up @@ -437,7 +432,7 @@ export const GET: RequestHandler = async ({ cookies }) => {
* @openapi
* summary: Update global general settings (all fields optional; only supplied keys are written)
* description: A large flat settings bag - theme/fonts, scanner defaults, cleanup schedules, event/metrics collection, editor options (e.g. editorIndentGuides), and more.
* body: {animateIcons:boolean, editorIndentGuides:boolean, inlineTagEditing:boolean, coloredActionButtons:boolean, lightTheme:string, darkTheme:string, defaultTimezone:string, logBufferSizeKb:integer, externalStackPaths:string, actionIconSize:string, compactPorts:boolean, confirmDestructive:boolean, dateFormat:string, defaultBackupImage:string, defaultComposeTemplate:string, defaultGrypeArgs:string, defaultGrypeImage:string, defaultScannerDns:array<string>, defaultScannerNetworkMode:string, defaultTrivyArgs:string, defaultTrivyImage:string, deployLogReconcileCron:string, deployLogReconcileEnabled:boolean, downloadFormat:string, editorFont:string, editorTheme:string, eventCleanupCron:string, eventCleanupEnabled:boolean, eventCollectionMode:string, eventPollInterval:integer, eventRetentionDays:integer, font:string, fontSize:string, formatLogTimestamps:boolean, gridFontSize:string, highlightUpdates:boolean, honorProxyLabels:boolean, labelFilterMode:string, logMaxLines:integer, metricsCollectionInterval:integer, primaryStackLocation:string, protectScannerImages:boolean, scannerCleanupCron:string, scannerCleanupEnabled:boolean, scheduleCleanupCron:string, scheduleCleanupEnabled:boolean, scheduleRetentionDays:integer, showExposedPorts:boolean, showGitCommitHash:boolean, showImageChangelogLinks:boolean, showStoppedContainers:boolean, showWhatsNew:boolean, terminalFont:string, timeFormat:string, useSelfhstIcons:boolean, stackLogOperations:array<string>}
* body: {animateIcons:boolean, editorIndentGuides:boolean, coloredActionButtons:boolean, lightTheme:string, darkTheme:string, defaultTimezone:string, logBufferSizeKb:integer, externalStackPaths:string, actionIconSize:string, compactPorts:boolean, confirmDestructive:boolean, dateFormat:string, defaultBackupImage:string, defaultComposeTemplate:string, defaultGrypeArgs:string, defaultGrypeImage:string, defaultScannerDns:array<string>, defaultScannerNetworkMode:string, defaultTrivyArgs:string, defaultTrivyImage:string, deployLogReconcileCron:string, deployLogReconcileEnabled:boolean, downloadFormat:string, editorFont:string, editorTheme:string, eventCleanupCron:string, eventCleanupEnabled:boolean, eventCollectionMode:string, eventPollInterval:integer, eventRetentionDays:integer, font:string, fontSize:string, formatLogTimestamps:boolean, gridFontSize:string, highlightUpdates:boolean, honorProxyLabels:boolean, labelFilterMode:string, logMaxLines:integer, metricsCollectionInterval:integer, primaryStackLocation:string, protectScannerImages:boolean, scannerCleanupCron:string, scannerCleanupEnabled:boolean, scheduleCleanupCron:string, scheduleCleanupEnabled:boolean, scheduleRetentionDays:integer, showExposedPorts:boolean, showGitCommitHash:boolean, showImageChangelogLinks:boolean, showStoppedContainers:boolean, showWhatsNew:boolean, terminalFont:string, timeFormat:string, useSelfhstIcons:boolean, stackLogOperations:array<string>}
* resp-403: Permission denied (needs settings:edit)
* resp-500: Failed to save settings
*/
Expand All @@ -449,7 +444,7 @@ export const POST: RequestHandler = async ({ request, cookies }) => {

try {
const body = await request.json();
const { confirmDestructive, showStoppedContainers, highlightUpdates, inlineTagEditing, coloredActionButtons, actionIconSize, timeFormat, dateFormat, downloadFormat, defaultGrypeArgs, defaultTrivyArgs, scheduleRetentionDays, eventRetentionDays, scheduleCleanupCron, eventCleanupCron, scheduleCleanupEnabled, eventCleanupEnabled, scannerCleanupCron, scannerCleanupEnabled, deployLogReconcileCron, deployLogReconcileEnabled, logBufferSizeKb, logMaxLines, defaultTimezone, eventCollectionMode, eventPollInterval, metricsCollectionInterval, lightTheme, darkTheme, font, fontSize, gridFontSize, terminalFont, editorFont, editorTheme, compactPorts, showExposedPorts, showGitCommitHash, formatLogTimestamps, externalStackPaths, primaryStackLocation, defaultGrypeImage, defaultTrivyImage, defaultComposeTemplate, labelFilterMode, defaultBackupImage, honorProxyLabels, showImageChangelogLinks, useSelfhstIcons, animateIcons, editorIndentGuides, protectScannerImages, showWhatsNew, defaultScannerNetworkMode, defaultScannerDns, stackLogOperations } = body;
const { confirmDestructive, showStoppedContainers, highlightUpdates, coloredActionButtons, actionIconSize, timeFormat, dateFormat, downloadFormat, defaultGrypeArgs, defaultTrivyArgs, scheduleRetentionDays, eventRetentionDays, scheduleCleanupCron, eventCleanupCron, scheduleCleanupEnabled, eventCleanupEnabled, scannerCleanupCron, scannerCleanupEnabled, deployLogReconcileCron, deployLogReconcileEnabled, logBufferSizeKb, logMaxLines, defaultTimezone, eventCollectionMode, eventPollInterval, metricsCollectionInterval, lightTheme, darkTheme, font, fontSize, gridFontSize, terminalFont, editorFont, editorTheme, compactPorts, showExposedPorts, showGitCommitHash, formatLogTimestamps, externalStackPaths, primaryStackLocation, defaultGrypeImage, defaultTrivyImage, defaultComposeTemplate, labelFilterMode, defaultBackupImage, honorProxyLabels, showImageChangelogLinks, useSelfhstIcons, animateIcons, editorIndentGuides, protectScannerImages, showWhatsNew, defaultScannerNetworkMode, defaultScannerDns, stackLogOperations } = body;

if (confirmDestructive !== undefined) {
await setSetting('confirm_destructive', confirmDestructive);
Expand All @@ -460,9 +455,6 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
if (highlightUpdates !== undefined) {
await setSetting('highlight_updates', highlightUpdates);
}
if (inlineTagEditing !== undefined) {
await setSetting('inline_tag_editing', inlineTagEditing);
}
if (coloredActionButtons !== undefined) {
await setSetting('colored_action_buttons', coloredActionButtons);
}
Expand Down Expand Up @@ -660,7 +652,6 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
confirmDestructiveVal,
showStoppedContainersVal,
highlightUpdatesVal,
inlineTagEditingVal,
coloredActionButtonsVal,
actionIconSizeVal,
timeFormatVal,
Expand Down Expand Up @@ -717,7 +708,6 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
getSetting('confirm_destructive'),
getSetting('show_stopped_containers'),
getSetting('highlight_updates'),
getSetting('inline_tag_editing'),
getSetting('colored_action_buttons'),
getSetting('action_icon_size'),
getSetting('time_format'),
Expand Down Expand Up @@ -776,7 +766,6 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
confirmDestructive: confirmDestructiveVal ?? DEFAULT_SETTINGS.confirmDestructive,
showStoppedContainers: showStoppedContainersVal ?? DEFAULT_SETTINGS.showStoppedContainers,
highlightUpdates: highlightUpdatesVal ?? DEFAULT_SETTINGS.highlightUpdates,
inlineTagEditing: inlineTagEditingVal ?? DEFAULT_SETTINGS.inlineTagEditing,
coloredActionButtons: coloredActionButtonsVal ?? DEFAULT_SETTINGS.coloredActionButtons,
actionIconSize: (VALID_ACTION_ICON_SIZES.includes(actionIconSizeVal as ActionIconSize) ? actionIconSizeVal : DEFAULT_SETTINGS.actionIconSize) as ActionIconSize,
timeFormat: timeFormatVal ?? DEFAULT_SETTINGS.timeFormat,
Expand Down
Loading
Loading