mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-04-21 09:37:22 +00:00
fix(renderer/PodActions): update to Svelte 5 (#14582)
* fix(renderer/PodActions): update to Svelte 5 Signed-off-by: Simon Rey <51708585+simonrey1@users.noreply.github.com> * refactor(renderer/PodActions): remove intermediate state Signed-off-by: Simon Rey <51708585+simonrey1@users.noreply.github.com> --------- Signed-off-by: Simon Rey <51708585+simonrey1@users.noreply.github.com>
This commit is contained in:
parent
a86a28c7b4
commit
67da47356b
1 changed files with 21 additions and 18 deletions
|
|
@ -22,22 +22,30 @@ import FlatMenu from '../ui/FlatMenu.svelte';
|
|||
import ListItemButtonIcon from '../ui/ListItemButtonIcon.svelte';
|
||||
import type { PodInfoUI } from './PodInfoUI';
|
||||
|
||||
export let pod: PodInfoUI;
|
||||
export let dropdownMenu = false;
|
||||
export let detailed = false;
|
||||
|
||||
const dispatch = createEventDispatcher<{ update: PodInfoUI }>();
|
||||
export let onUpdate: (update: PodInfoUI) => void = update => {
|
||||
dispatch('update', update);
|
||||
};
|
||||
interface Props {
|
||||
pod: PodInfoUI;
|
||||
dropdownMenu?: boolean;
|
||||
detailed?: boolean;
|
||||
onUpdate?: (update: PodInfoUI) => void;
|
||||
}
|
||||
|
||||
let contributions: Menu[] = [];
|
||||
let {
|
||||
pod = $bindable(),
|
||||
dropdownMenu = false,
|
||||
detailed = false,
|
||||
onUpdate = (update): void => {
|
||||
dispatch('update', update);
|
||||
},
|
||||
}: Props = $props();
|
||||
|
||||
let contributions = $state<Menu[]>([]);
|
||||
onMount(async () => {
|
||||
contributions = await window.getContributedMenus(MenuContext.DASHBOARD_POD);
|
||||
});
|
||||
|
||||
let urls: Array<string> = [];
|
||||
$: openingUrls = urls;
|
||||
let urls: Array<string> = $state([]);
|
||||
const openingUrls = $derived(urls);
|
||||
|
||||
const portRegexp = RegExp(/:(\d+)/);
|
||||
|
||||
|
|
@ -132,12 +140,7 @@ function deployToKubernetes(): void {
|
|||
}
|
||||
// If dropdownMenu = true, we'll change style to the imported dropdownMenu style
|
||||
// otherwise, leave blank.
|
||||
let actionsStyle: typeof DropdownMenu | typeof FlatMenu;
|
||||
if (dropdownMenu) {
|
||||
actionsStyle = DropdownMenu;
|
||||
} else {
|
||||
actionsStyle = FlatMenu;
|
||||
}
|
||||
const MenuComponent = $derived(dropdownMenu ? DropdownMenu : FlatMenu);
|
||||
</script>
|
||||
|
||||
<ListItemButtonIcon
|
||||
|
|
@ -162,7 +165,7 @@ if (dropdownMenu) {
|
|||
inProgress={pod.actionInProgress && pod.status === 'DELETING'} />
|
||||
|
||||
<!-- If dropdownMenu is true, use it, otherwise just show the regular buttons -->
|
||||
<svelte:component this={actionsStyle}>
|
||||
<MenuComponent>
|
||||
{#if !detailed}
|
||||
<ListItemButtonIcon
|
||||
title="Generate Kube"
|
||||
|
|
@ -221,4 +224,4 @@ if (dropdownMenu) {
|
|||
contributions={contributions}
|
||||
detailed={detailed}
|
||||
onError={handleError} />
|
||||
</svelte:component>
|
||||
</MenuComponent>
|
||||
|
|
|
|||
Loading…
Reference in a new issue