From 7f43a1e599c340415deec3aacf9e4e560f08acd6 Mon Sep 17 00:00:00 2001 From: Florent Benoit Date: Fri, 20 Dec 2024 17:07:01 +0100 Subject: [PATCH] chore: move PodsList to svelte5 runes mode part of https://github.com/podman-desktop/podman-desktop/issues/10240 Signed-off-by: Florent Benoit --- packages/renderer/src/lib/pod/PodsList.svelte | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/packages/renderer/src/lib/pod/PodsList.svelte b/packages/renderer/src/lib/pod/PodsList.svelte index 225325b54..f80b45aa0 100644 --- a/packages/renderer/src/lib/pod/PodsList.svelte +++ b/packages/renderer/src/lib/pod/PodsList.svelte @@ -31,23 +31,32 @@ import PodColumnStatus from './PodColumnStatus.svelte'; import PodEmptyScreen from './PodEmptyScreen.svelte'; import type { PodInfoUI } from './PodInfoUI'; -export let searchTerm = ''; -$: searchPattern.set(searchTerm); +interface Props { + searchTerm?: string; +} + +let { searchTerm = $bindable('') }: Props = $props(); + +$effect(() => { + searchPattern.set(searchTerm); +}); -let pods: PodInfoUI[] = []; -let enginesList: EngineInfoUI[]; +let pods: PodInfoUI[] = $state([]); +let enginesList: EngineInfoUI[] = $state([]); -$: providerConnections = $providerInfos - .map(provider => provider.containerConnections) - .flat() - .filter(providerContainerConnection => providerContainerConnection.status === 'started'); +const providerConnections = $derived( + $providerInfos + .flatMap(provider => provider.containerConnections) + .filter(providerContainerConnection => providerContainerConnection.status === 'started'), +); -$: providerPodmanConnections = $providerInfos - .map(provider => provider.containerConnections) - .flat() - // keep only podman providers as it is not supported by docker - .filter(providerContainerConnection => providerContainerConnection.type === 'podman') - .filter(providerContainerConnection => providerContainerConnection.status === 'started'); +const providerPodmanConnections = $derived( + $providerInfos + .flatMap(provider => provider.containerConnections) + // keep only podman providers as it is not supported by docker + .filter(providerContainerConnection => providerContainerConnection.type === 'podman') + .filter(providerContainerConnection => providerContainerConnection.status === 'started'), +); const podUtils = new PodUtils(); @@ -79,7 +88,7 @@ onMount(() => { }); // delete the items selected in the list -let bulkDeleteInProgress = false; +let bulkDeleteInProgress = $state(false); async function deleteSelectedPods() { const selectedPods = pods.filter(pod => pod.selected); if (selectedPods.length === 0) { @@ -107,7 +116,7 @@ async function deleteSelectedPods() { bulkDeleteInProgress = false; } -let selectedItemsNumber: number; +let selectedItemsNumber: number = $state(0); let table: Table; let statusColumn = new TableColumn('Status', {