fix(docker): connect Grouped/List toggle to table view state

The Grouped/List toggle buttons in DockerFilter were updating the
external groupingMode state, but DockerUnifiedTable had its own
internal sortKey state for determining whether to show grouped vs
flat view. These two states were completely disconnected.

Added groupingMode prop to DockerUnifiedTable and a createEffect to
sync the external state with the internal sort state.

Fixes #1100
This commit is contained in:
rcourtman
2026-01-12 19:08:13 +00:00
parent bf9d829e09
commit 4402b3ce2e
2 changed files with 13 additions and 0 deletions
@@ -623,6 +623,7 @@ export const DockerHosts: Component<DockerHostsProps> = (props) => {
dockerHostMetadata={dockerHostMetadata()}
onCustomUrlUpdate={handleCustomUrlUpdate}
batchUpdateState={batchUpdateState}
groupingMode={groupingMode() === 'flat' ? 'flat' : 'grouped'}
/>
}
>
@@ -76,6 +76,7 @@ interface DockerUnifiedTableProps {
dockerHostMetadata?: Record<string, DockerHostMetadata>;
onCustomUrlUpdate?: (resourceId: string, url: string) => void;
batchUpdateState?: Record<string, 'updating' | 'queued' | 'error'>;
groupingMode?: 'grouped' | 'flat';
}
type SortKey =
@@ -2481,6 +2482,17 @@ const DockerUnifiedTable: Component<DockerUnifiedTableProps> = (props) => {
const isGroupedView = createMemo(() => sortKey() === 'host');
// Sync external groupingMode prop with internal sort state
createEffect(() => {
const mode = props.groupingMode;
if (mode === 'grouped' && sortKey() !== 'host') {
setSortKey('host');
} else if (mode === 'flat' && sortKey() === 'host') {
// Switch to resource sort for flat view
setSortKey('resource');
}
});
const handleSort = (key: SortKey) => {
if (sortKey() === key) {
setSortDirection(sortDirection() === 'asc' ? 'desc' : 'asc');