From 6b615e4cf1941451834b531a126a0640231e0bd8 Mon Sep 17 00:00:00 2001 From: Luca Stocchi <49404737+lstocchi@users.noreply.github.com> Date: Thu, 23 May 2024 17:52:16 +0200 Subject: [PATCH] fix: remove tinro from Tab and ui (#7288) * fix: remove tinro from Tab and ui Signed-off-by: lstocchi * fix: use selected prop in tab component Signed-off-by: lstocchi * fix: fix wrong tab url Signed-off-by: lstocchi --------- Signed-off-by: lstocchi --- .../src/lib/compose/ComposeDetails.svelte | 16 ++++++++++---- .../src/lib/container/ContainerDetails.svelte | 22 ++++++++++++++----- .../lib/deployments/DeploymentDetails.svelte | 14 +++++++++--- .../src/lib/image/ImageDetails.svelte | 19 ++++++++++++---- .../renderer/src/lib/image/RunImage.svelte | 21 ++++++++++++++---- .../ingresses-routes/IngressDetails.svelte | 14 +++++++++--- .../lib/ingresses-routes/RouteDetails.svelte | 14 +++++++++--- .../renderer/src/lib/pod/PodDetails.svelte | 20 ++++++++++++----- ...erencesContainerConnectionRendering.svelte | 9 ++++++-- ...rencesKubernetesConnectionRendering.svelte | 9 ++++++-- .../src/lib/service/ServiceDetails.svelte | 14 +++++++++--- .../TroubleshootingPage.svelte | 16 ++++++++++---- .../renderer/src/lib/ui/FormPageSpec.svelte | 8 ++++--- packages/renderer/src/lib/ui/Util.ts | 9 ++++++++ .../src/lib/volume/VolumeDetails.svelte | 12 ++++++++-- packages/ui/package.json | 3 +-- packages/ui/src/lib/tab/Tab.spec.ts | 17 ++++++++++---- packages/ui/src/lib/tab/Tab.svelte | 19 +++++++--------- 18 files changed, 191 insertions(+), 65 deletions(-) diff --git a/packages/renderer/src/lib/compose/ComposeDetails.svelte b/packages/renderer/src/lib/compose/ComposeDetails.svelte index 216cd0b324158..c35f5fee3055f 100644 --- a/packages/renderer/src/lib/compose/ComposeDetails.svelte +++ b/packages/renderer/src/lib/compose/ComposeDetails.svelte @@ -2,6 +2,7 @@ import { Tab } from '@podman-desktop/ui-svelte'; import { onDestroy, onMount } from 'svelte'; import type { Unsubscriber } from 'svelte/store'; +import { router } from 'tinro'; import { containersInfos } from '/@/stores/containers'; @@ -11,6 +12,7 @@ import type { ContainerInfoUI } from '../container/ContainerInfoUI'; import ComposeIcon from '../images/PodIcon.svelte'; import StatusIcon from '../images/StatusIcon.svelte'; import DetailsPage from '../ui/DetailsPage.svelte'; +import { getTabUrl, isTabSelected } from '../ui/Util'; import ComposeActions from './ComposeActions.svelte'; import ComposeDetailsInspect from './ComposeDetailsInspect.svelte'; import ComposeDetailsKube from './ComposeDetailsKube.svelte'; @@ -96,10 +98,16 @@ onDestroy(() => { - - - - + + + + diff --git a/packages/renderer/src/lib/container/ContainerDetails.svelte b/packages/renderer/src/lib/container/ContainerDetails.svelte index 4689a0a4e521a..deb0cd7be68e2 100644 --- a/packages/renderer/src/lib/container/ContainerDetails.svelte +++ b/packages/renderer/src/lib/container/ContainerDetails.svelte @@ -11,6 +11,7 @@ import { containersInfos } from '../../stores/containers'; import StatusIcon from '../images/StatusIcon.svelte'; import DetailsPage from '../ui/DetailsPage.svelte'; import StateChange from '../ui/StateChange.svelte'; +import { getTabUrl, isTabSelected } from '../ui/Util'; import { ContainerUtils } from './container-utils'; import ContainerActions from './ContainerActions.svelte'; import ContainerDetailsInspect from './ContainerDetailsInspect.svelte'; @@ -90,16 +91,25 @@ onMount(() => { - - - + + + {#if container.engineType === 'podman' && container.groupInfo.type === ContainerGroupInfoTypeUI.STANDALONE} - + {/if} - + {#if displayTty} - + {/if} diff --git a/packages/renderer/src/lib/deployments/DeploymentDetails.svelte b/packages/renderer/src/lib/deployments/DeploymentDetails.svelte index 65735ddb3a737..518c6efae28ab 100644 --- a/packages/renderer/src/lib/deployments/DeploymentDetails.svelte +++ b/packages/renderer/src/lib/deployments/DeploymentDetails.svelte @@ -2,6 +2,7 @@ import type { V1Deployment } from '@kubernetes/client-node'; import { Tab } from '@podman-desktop/ui-svelte'; import { onMount } from 'svelte'; +import { router } from 'tinro'; import { stringify } from 'yaml'; import { kubernetesCurrentContextDeployments } from '/@/stores/kubernetes-contexts-state'; @@ -12,6 +13,7 @@ import DeploymentIcon from '../images/DeploymentIcon.svelte'; import StatusIcon from '../images/StatusIcon.svelte'; import KubeEditYAML from '../kube/KubeEditYAML.svelte'; import DetailsPage from '../ui/DetailsPage.svelte'; +import { getTabUrl, isTabSelected } from '../ui/Util'; import { DeploymentUtils } from './deployment-utils'; import DeploymentActions from './DeploymentActions.svelte'; import DeploymentDetailsSummary from './DeploymentDetailsSummary.svelte'; @@ -63,9 +65,15 @@ async function loadDetails() { - - - + + + diff --git a/packages/renderer/src/lib/image/ImageDetails.svelte b/packages/renderer/src/lib/image/ImageDetails.svelte index c390798de08c5..1343d548ac91e 100644 --- a/packages/renderer/src/lib/image/ImageDetails.svelte +++ b/packages/renderer/src/lib/image/ImageDetails.svelte @@ -3,6 +3,7 @@ import type { ImageInfo } from '@podman-desktop/api'; import { Tab } from '@podman-desktop/ui-svelte'; import { onDestroy, onMount } from 'svelte'; import type { Unsubscriber } from 'svelte/motion'; +import { router } from 'tinro'; import { containersInfos } from '/@/stores/containers'; import { context } from '/@/stores/context'; @@ -16,6 +17,7 @@ import type { ContextUI } from '../context/context'; import StatusIcon from '../images/StatusIcon.svelte'; import Badge from '../ui/Badge.svelte'; import DetailsPage from '../ui/DetailsPage.svelte'; +import { getTabUrl, isTabSelected } from '../ui/Util'; import { IMAGE_DETAILS_VIEW_BADGES, IMAGE_DETAILS_VIEW_ICONS, @@ -142,11 +144,20 @@ onDestroy(() => { groupContributions="{true}" on:update="{() => (image = image)}" /> - - - + + + {#if showCheckTab} - + {/if} diff --git a/packages/renderer/src/lib/image/RunImage.svelte b/packages/renderer/src/lib/image/RunImage.svelte index ad09e2b6829bc..8510ac0f6b482 100644 --- a/packages/renderer/src/lib/image/RunImage.svelte +++ b/packages/renderer/src/lib/image/RunImage.svelte @@ -17,6 +17,7 @@ import type { ContainerInfoUI } from '../container/ContainerInfoUI'; import { splitSpacesHandlingDoubleQuotes } from '../string/string'; import FormPage from '../ui/FormPage.svelte'; import NumberInput from '../ui/NumberInput.svelte'; +import { getTabUrl, isTabSelected } from '../ui/Util'; import type { ImageInfoUI } from './ImageInfoUI'; interface PortInfo { @@ -629,10 +630,22 @@ async function assertAllPortAreValid(): Promise {
- - - - + + + +
diff --git a/packages/renderer/src/lib/ingresses-routes/IngressDetails.svelte b/packages/renderer/src/lib/ingresses-routes/IngressDetails.svelte index b710bb98c04cd..9319e3fa7b28e 100644 --- a/packages/renderer/src/lib/ingresses-routes/IngressDetails.svelte +++ b/packages/renderer/src/lib/ingresses-routes/IngressDetails.svelte @@ -2,6 +2,7 @@ import type { V1Ingress } from '@kubernetes/client-node'; import { Tab } from '@podman-desktop/ui-svelte'; import { onMount } from 'svelte'; +import { router } from 'tinro'; import { stringify } from 'yaml'; import { kubernetesCurrentContextIngresses } from '/@/stores/kubernetes-contexts-state'; @@ -13,6 +14,7 @@ import StatusIcon from '../images/StatusIcon.svelte'; import KubeEditYAML from '../kube/KubeEditYAML.svelte'; import DetailsPage from '../ui/DetailsPage.svelte'; import StateChange from '../ui/StateChange.svelte'; +import { getTabUrl, isTabSelected } from '../ui/Util'; import { IngressRouteUtils } from './ingress-route-utils'; import IngressRouteActions from './IngressRouteActions.svelte'; import ServiceDetailsSummary from './IngressRouteDetailsSummary.svelte'; @@ -65,9 +67,15 @@ async function loadIngressDetails() {
- - - + + + diff --git a/packages/renderer/src/lib/ingresses-routes/RouteDetails.svelte b/packages/renderer/src/lib/ingresses-routes/RouteDetails.svelte index f3a3e00b5070c..76d0778126c1f 100644 --- a/packages/renderer/src/lib/ingresses-routes/RouteDetails.svelte +++ b/packages/renderer/src/lib/ingresses-routes/RouteDetails.svelte @@ -1,6 +1,7 @@ @@ -10,9 +12,9 @@ import FormPage from './FormPage.svelte'; - - - + + +
diff --git a/packages/renderer/src/lib/ui/Util.ts b/packages/renderer/src/lib/ui/Util.ts index fddac50be6d00..9bbe98a394a69 100644 --- a/packages/renderer/src/lib/ui/Util.ts +++ b/packages/renderer/src/lib/ui/Util.ts @@ -19,3 +19,12 @@ export function capitalize(text: string): string { return text.charAt(0).toUpperCase() + text.slice(1); } + +export function getTabUrl(routerPath: string, tabUrl: string): string { + const baseURL = routerPath.substring(0, routerPath.lastIndexOf('/')); + return `${baseURL}/${tabUrl}`; +} + +export function isTabSelected(routerPath: string, tabUrl: string): boolean { + return routerPath === getTabUrl(routerPath, tabUrl); +} diff --git a/packages/renderer/src/lib/volume/VolumeDetails.svelte b/packages/renderer/src/lib/volume/VolumeDetails.svelte index 65322950a9d7f..2a1009015f27c 100644 --- a/packages/renderer/src/lib/volume/VolumeDetails.svelte +++ b/packages/renderer/src/lib/volume/VolumeDetails.svelte @@ -1,12 +1,14 @@
+ class:border-[var(--pd-tab-highlight)]="{selected}" + class:border-transparent="{!selected}" + class:hover:border-[var(--pd-tab-hover)]="{!selected}"> + class:text-[var(--pd-tab-text-highlight)]="{selected}" + aria-controls="open-tabs-list-{title.toLowerCase()}-panel" + id="open-tabs-list-{title.toLowerCase()}-link"> {title}