Skip to content

Commit 8746992

Browse files
committed
Updates routes to use SvelteKit's resolve
Migrates hardcoded routes to use SvelteKit's `resolve` function for improved route management and flexibility. This change ensures that routes are correctly resolved based on the application's configuration and base path, preventing potential issues with broken links or incorrect navigation, especially after the introduction of route groups. Additionally, the commit disables the `svelte/no-navigation-without-resolve` eslint rule, as the updated code now consistently uses the `resolve` function.
1 parent 283b359 commit 8746992

File tree

33 files changed

+112
-63
lines changed

33 files changed

+112
-63
lines changed

src/Exceptionless.Web/ClientApp/eslint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export default ts.config(
3737
{
3838
ignores: ['build/', '.svelte-kit/', 'dist/', 'src/lib/generated/api.ts', 'src/lib/features/shared/components/ui/']
3939
},
40+
{
41+
rules: {
42+
'svelte/no-navigation-without-resolve': 'off'
43+
}
44+
},
4045
{
4146
rules: {
4247
'perfectionist/sort-enums': [

src/Exceptionless.Web/ClientApp/src/lib/features/auth/index.svelte.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { goto } from '$app/navigation';
2+
import { resolve } from '$app/paths';
23
import { page } from '$app/state';
34
import { env } from '$env/dynamic/public';
45
import { useFetchClient } from '@exceptionless/fetchclient';
@@ -106,7 +107,7 @@ export async function googleLogin(redirectUrl?: string) {
106107
export async function gotoLogin() {
107108
const url = page.url;
108109
const isAuthPath = url.pathname.startsWith('/next/login') || url.pathname.startsWith('/next/logout');
109-
const redirect = url.pathname === '/next/' || isAuthPath ? '/next/login' : `/next/login?redirect=${url.pathname}`;
110+
const redirect = url.pathname === resolve('/') || isAuthPath ? resolve('/(auth)/login') : `${resolve('/(auth)/login')}?redirect=${url.pathname}`;
110111
await goto(redirect, { replaceState: true });
111112
}
112113

@@ -181,7 +182,7 @@ async function oauthLogin(options: OAuthLoginOptions) {
181182

182183
if (response.ok && response.data?.token) {
183184
accessToken.current = response.data.token;
184-
await goto(options.redirectUrl || '/');
185+
await goto(options.redirectUrl || resolve('/'));
185186
}
186187
}
187188

src/Exceptionless.Web/ClientApp/src/lib/features/organizations/components/table/organization-actions-cell.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { goto } from '$app/navigation';
3+
import { resolve } from '$app/paths';
34
import { Button } from '$comp/ui/button';
45
import * as DropdownMenu from '$comp/ui/dropdown-menu';
56
import { deleteOrganization, deleteOrganizationUser } from '$features/organizations/api.svelte';
@@ -82,15 +83,15 @@
8283
{/snippet}
8384
</DropdownMenu.Trigger>
8485
<DropdownMenu.Content align="end">
85-
<DropdownMenu.Item onclick={() => goto(`/next/organization/${org.id}/manage`)}>
86+
<DropdownMenu.Item onclick={() => goto(resolve(`/(app)/organization/[organizationId]/manage`, { organizationId: org.id }))}>
8687
<Edit />
8788
Edit
8889
</DropdownMenu.Item>
89-
<DropdownMenu.Item onclick={() => goto(`/next/organization/${org.id}/billing`)}>
90+
<DropdownMenu.Item onclick={() => goto(resolve(`/(app)/organization/[organizationId]/billing`, { organizationId: org.id }))}>
9091
<ChangePlan />
9192
Change Plan
9293
</DropdownMenu.Item>
93-
<DropdownMenu.Item onclick={() => goto(`/next/organization/${org.id}/billing`)}>
94+
<DropdownMenu.Item onclick={() => goto(resolve(`/(app)/organization/[organizationId]/billing`, { organizationId: org.id }))}>
9495
<ViewInvoices />
9596
View Invoices
9697
</DropdownMenu.Item>

src/Exceptionless.Web/ClientApp/src/lib/features/projects/components/table/project-actions-cell.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { goto } from '$app/navigation';
3+
import { resolve } from '$app/paths';
34
import { Button } from '$comp/ui/button';
45
import * as DropdownMenu from '$comp/ui/dropdown-menu';
56
import { deleteProject } from '$features/projects/api.svelte';
@@ -45,15 +46,15 @@
4546
{/snippet}
4647
</DropdownMenu.Trigger>
4748
<DropdownMenu.Content align="end">
48-
<DropdownMenu.Item onclick={() => goto(`/next/issues`)}>
49+
<DropdownMenu.Item onclick={() => goto(resolve('/(app)/issues'))}>
4950
<Issues />
5051
Issues
5152
</DropdownMenu.Item>
52-
<DropdownMenu.Item onclick={() => goto(`/next/project/${project.id}/manage`)}>
53+
<DropdownMenu.Item onclick={() => goto(resolve('/(app)/project/[projectId]/manage', { projectId: project.id }))}>
5354
<Edit />
5455
Edit
5556
</DropdownMenu.Item>
56-
<DropdownMenu.Item onclick={() => goto(`/next/project/${project.id}/configure`)}>
57+
<DropdownMenu.Item onclick={() => goto(resolve('/(app)/project/[projectId]/configure', { projectId: project.id }))}>
5758
<Configure />
5859
Download & Configure Client
5960
</DropdownMenu.Item>
@@ -62,7 +63,7 @@
6263
Delete
6364
</DropdownMenu.Item>
6465
<DropdownMenu.Separator />
65-
<DropdownMenu.Item onclick={() => goto(`/organization/${project.organization_id}/manage`)}>
66+
<DropdownMenu.Item onclick={() => goto(resolve('/(app)/organization/[organizationId]/manage', { organizationId: project.organization_id }))}>
6667
<Organization />
6768
View Organization
6869
</DropdownMenu.Item>

src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stack-options-dropdown-menu.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { goto } from '$app/navigation';
3+
import { resolve } from '$app/paths';
34
import Button from '$comp/ui/button/button.svelte';
45
import * as DropdownMenu from '$comp/ui/dropdown-menu';
56
import Reference from '@lucide/svelte/icons/link-2';
@@ -86,7 +87,7 @@
8687
}
8788
8889
async function navigateToProjectIntegrations() {
89-
await goto(`/project/${stack.project_id}/manage`);
90+
await goto(resolve('/(app)/project/[projectId]/manage', { projectId: stack.project_id }));
9091
}
9192
9293
async function updateCritical() {

src/Exceptionless.Web/ClientApp/src/routes/(app)/(components)/layouts/navbar.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { resolve } from '$app/paths';
23
import DarkModeButton from '$comp/dark-mode-button.svelte';
34
import Logo from '$comp/logo.svelte';
45
import { Button } from '$comp/ui/button';
@@ -27,7 +28,7 @@
2728
<div class="flex items-center justify-start">
2829
<Sidebar.Trigger variant="outline" class="size-9" />
2930

30-
<a class="mr-14 ml-2 flex md:min-w-[250px] lg:ml-3 dark:text-white" href="./">
31+
<a class="mr-14 ml-2 flex md:min-w-[250px] lg:ml-3 dark:text-white" href={resolve('/(app)')}>
3132
{#if isMediumScreenQuery.current}
3233
<Logo class="absolute top-[9px] mr-3 h-[45px]" />
3334
{:else}

src/Exceptionless.Web/ClientApp/src/routes/(app)/+layout.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { Snippet } from 'svelte';
33
44
import { goto } from '$app/navigation';
5+
import { resolve } from '$app/paths';
56
import { page } from '$app/state';
67
import { useSidebar } from '$comp/ui/sidebar';
78
import { env } from '$env/dynamic/public';
@@ -168,7 +169,7 @@
168169
169170
if (!organizationsQuery.data.data || organizationsQuery.data.data.length === 0) {
170171
organization.current = undefined;
171-
goto('/next/organization/add');
172+
goto(resolve(`/(app)/organization/add`));
172173
return;
173174
}
174175

src/Exceptionless.Web/ClientApp/src/routes/(app)/account/routes.svelte.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { resolve } from '$app/paths';
12
import Notifications from '@lucide/svelte/icons/bell';
23
import Password from '@lucide/svelte/icons/key-round';
34
import Verify from '@lucide/svelte/icons/shield-check';
@@ -11,39 +12,39 @@ export function routes(): NavigationItem[] {
1112
return [
1213
{
1314
group: 'My Account',
14-
href: '/next/account/manage',
15+
href: resolve('/(app)/account/manage'),
1516
icon: Account,
1617
title: 'Account'
1718
},
1819
{
1920
group: 'My Account',
20-
href: '/next/account/appearance',
21+
href: resolve('/(app)/account/appearance'),
2122
icon: Appearance,
2223
title: 'Appearance'
2324
},
2425
{
2526
group: 'My Account',
26-
href: '/next/account/notifications',
27+
href: resolve('/(app)/account/notifications'),
2728
icon: Notifications,
2829
title: 'Notifications'
2930
},
3031
{
3132
group: 'My Account',
32-
href: '/next/account/security',
33+
href: resolve('/(app)/account/security'),
3334
icon: Password,
3435
show: () => false,
3536
title: 'Password and authentication'
3637
},
3738
{
3839
group: 'My Account',
39-
href: '/next/account/sessions',
40+
href: resolve('/(app)/account/sessions'),
4041
icon: Sessions,
4142
show: () => false,
4243
title: 'Sessions'
4344
},
4445
{
4546
group: 'My Account',
46-
href: '/next/account/verify',
47+
href: resolve('/(app)/account/verify'),
4748
icon: Verify,
4849
show: () => false,
4950
title: 'Verify'

src/Exceptionless.Web/ClientApp/src/routes/(app)/account/verify/+page.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { goto } from '$app/navigation';
3+
import { resolve } from '$app/paths';
34
import { page } from '$app/state';
45
import { useFetchClient } from '@exceptionless/fetchclient';
56
import { toast } from 'svelte-sonner';
@@ -19,7 +20,7 @@
1920
}
2021
}
2122
22-
await goto('/next/account/manage');
23+
await goto(resolve('/(app)/account/manage'));
2324
}
2425
2526
verifyAccount();

src/Exceptionless.Web/ClientApp/src/routes/(app)/event/[eventId]/+page.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { ProblemDetails } from '@exceptionless/fetchclient';
33
44
import { goto } from '$app/navigation';
5+
import { resolve } from '$app/paths';
56
import { page } from '$app/state';
67
import * as FacetedFilter from '$comp/faceted-filter';
78
import { H3 } from '$comp/typography';
@@ -16,7 +17,7 @@
1617
watch(
1718
() => organization.current,
1819
() => {
19-
goto('/next/');
20+
goto(resolve('/(app)'));
2021
},
2122
{ lazy: true }
2223
);
@@ -31,7 +32,7 @@
3132
}
3233
3334
toast.error(`The event "${page.params.eventId}" could not be found.`);
34-
await goto('/next/');
35+
await goto(resolve('/(app)'));
3536
}
3637
</script>
3738

0 commit comments

Comments
 (0)