Skip to content

The only tool you need to know what is happening and how to fix it.

#49

dduxcf21dedb7503
diff --git a/frontend/src/lib/components/ui/view-all-table-row/view-all-table-row.svelte b/frontend/src/lib/components/ui/view-all-table-row/view-all-table-row.svelte
index d438ca13..b2dc8e21 100644
--- a/frontend/src/lib/components/ui/view-all-table-row/view-all-table-row.svelte
+++ b/frontend/src/lib/components/ui/view-all-table-row/view-all-table-row.svelte
@@ -1,20 +1,22 @@
<script lang="ts">
import * as Table from '$lib/components/ui/table';
import { ArrowRight } from 'lucide-svelte';
- import { createRowClickHandler } from '$lib/utils/navigation';
+ import { createRowClickHandlerWithNavigate } from '$lib/utils/navigation';
let {
colspan,
href,
- label
+ label,
+ onBeforeNavigate
}: {
colspan: number;
href: string;
label: string;
+ onBeforeNavigate?: () => void;
} = $props();
</script>
-<Table.Row class="cursor-pointer bg-muted/50 hover:bg-muted" onclick={createRowClickHandler(href)}>
+<Table.Row class="cursor-pointer bg-muted/50 hover:bg-muted" onclick={createRowClickHandlerWithNavigate(href, onBeforeNavigate)}>
<Table.Cell {colspan} class="py-2 text-center text-sm text-muted-foreground">
{label} <ArrowRight class="inline h-3.5 w-3.5" />
</Table.Cell>
diff --git a/frontend/src/lib/utils/navigation.ts b/frontend/src/lib/utils/navigation.ts
index 49d87842..6e9c2a23 100644
--- a/frontend/src/lib/utils/navigation.ts
+++ b/frontend/src/lib/utils/navigation.ts
@@ -21,8 +21,10 @@ export function addStickyParamsToHref(href: string, ...stickyParams: string[]) {
// in the future it would be really cool if we could bind the type here to get type safety and force the use of resolve :/
// this also won't work with absolute paths - meh so be it
-export function createRowClickHandler(href: string, ...stickyParams: string[]) {
+export function createRowClickHandlerWithNavigate(href: string, onBeforeNavigate: (() => void) | undefined, ...stickyParams: string[]) {
return (event: MouseEvent) => {
+ onBeforeNavigate?.();
+
const finalHref = addStickyParamsToHref(href, ...stickyParams);
if (event.ctrlKey || event.metaKey) {
@@ -32,4 +34,8 @@ export function createRowClickHandler(href: string, ...stickyParams: string[]) {
goto(finalHref);
}
};
+}
+
+export function createRowClickHandler(href: string, ...stickyParams: string[]) {
+ return createRowClickHandlerWithNavigate(href, undefined, ...stickyParams);
}
\ No newline at end of file
diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte
index 7650c0c7..80f9973a 100644
--- a/frontend/src/routes/+page.svelte
+++ b/frontend/src/routes/+page.svelte
@@ -14,6 +14,7 @@
import { api } from '$lib/api';
import { ErrorDisplay } from '$lib/components/ui/error-display';
import { projectsState } from '$lib/state/projects.svelte';
+ import { setSortState } from '$lib/utils/sort-storage';
const timezone = $derived(getTimezone());
@@ -82,6 +83,9 @@
return null;
}
+ function resetEndpointsSortToImpact() {
+ setSortState('endpoints', { field: 'impact', direction: 'desc' });
+ }
</script>
<div class="space-y-4">
@@ -192,7 +196,7 @@
</Table.Cell>
</Table.Row>
{/each}
- <ViewAllTableRow colspan={5} href="/endpoints" label="View all endpoints" />
+ <ViewAllTableRow colspan={5} href="/endpoints" label="View all endpoints" onBeforeNavigate={resetEndpointsSortToImpact} />
</Table.Body>
{:else}
<Table.Body>