From 849c69706166e026a04311fa2743f5af7484c22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 13 Jan 2022 19:33:48 +0100 Subject: [PATCH] [ui] uplink now works outside of /browse --- webui/src/components/display/UpEntry.svelte | 4 +-- webui/src/components/display/UpLink.svelte | 32 +++++++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/webui/src/components/display/UpEntry.svelte b/webui/src/components/display/UpEntry.svelte index 7412cf0..8def319 100644 --- a/webui/src/components/display/UpEntry.svelte +++ b/webui/src/components/display/UpEntry.svelte @@ -7,14 +7,14 @@
- +
{entry.attribute}
{#if entry.value.t === "Address"} - + {:else} {entry.value.c} {/if} diff --git a/webui/src/components/display/UpLink.svelte b/webui/src/components/display/UpLink.svelte index 3543441..bba7b2d 100644 --- a/webui/src/components/display/UpLink.svelte +++ b/webui/src/components/display/UpLink.svelte @@ -2,7 +2,7 @@ import { getContext } from "svelte"; import { useNavigate, useLocation, useParams } from "svelte-navigator"; - import type { Writable } from "svelte/store"; + import { readable, Writable } from "svelte/store"; import type { Address, VALUE_TYPE } from "upend/types"; const params = useParams(); const location = useLocation(); @@ -14,21 +14,29 @@ value?: { t: VALUE_TYPE; c: string }; }; - const { index } = getContext("browse") as { index: Writable }; + const context = getContext("browse") as + | { index: Writable } + | undefined; + + const index = Boolean(context) ? context.index : readable(0); function onClick() { - if ($location.pathname.startsWith("/browse") && to.entity) { - let addresses = $params.addresses.split(","); + if (to.entity) { + if ($location.pathname.startsWith("/browse")) { + let addresses = $params.addresses.split(","); - const routerTo = - "/browse/" + - addresses - .slice(0, $index + 1) - .concat([to.entity]) - .join(","); + const routerTo = + "/browse/" + + addresses + .slice(0, $index + 1) + .concat([to.entity]) + .join(","); - navigate(routerTo); - return true; + navigate(routerTo); + return true; + } else { + navigate(`/browse/${to.entity}`); + } } }