Skip to content

Commit cec849d

Browse files
committed
Reworked routes so they are dynamic and resolvable by href.
1 parent 0a33604 commit cec849d

File tree

20 files changed

+275
-217
lines changed

20 files changed

+275
-217
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import * as Sidebar from '$comp/ui/sidebar';
66
import { useSidebar } from '$comp/ui/sidebar';
77
8-
import type { NavigationItem } from '../../../routes';
8+
import type { NavigationItem } from '../../../routes.svelte';
99
1010
type Props = ComponentProps<typeof Sidebar.Root> & {
1111
footer?: Snippet;

src/Exceptionless.Web/ClientApp/src/routes/(app)/(components)/navigation-command.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { A } from '$comp/typography';
33
import * as Command from '$comp/ui/command';
44
5-
import type { NavigationItem } from '../../routes';
5+
import type { NavigationItem } from '../../routes.svelte';
66
77
let { open = $bindable(), routes }: { open: boolean; routes: NavigationItem[] } = $props();
88

src/Exceptionless.Web/ClientApp/src/routes/(app)/(components)/sidebar-nav.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
import * as Navigation from '$lib/features/shared/components/navigation';
55
6-
import type { NavigationItem } from '../../routes';
6+
import type { NavigationItem } from '../../routes.svelte';
77
88
interface Props extends HTMLAttributes<HTMLElement> {
99
routes: NavigationItem[];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { useQueryClient } from '@tanstack/svelte-query';
1919
import { fade } from 'svelte/transition';
2020
21-
import { type NavigationItemContext, routes } from '../routes';
21+
import { type NavigationItemContext, routes } from '../routes.svelte';
2222
import Footer from './(components)/layouts/footer.svelte';
2323
import Navbar from './(components)/layouts/navbar.svelte';
2424
import SidebarOrganizationSwitcher from './(components)/layouts/sidebar-organization-switcher.svelte';
@@ -173,7 +173,7 @@
173173
174174
const filteredRoutes = $derived.by(() => {
175175
const context: NavigationItemContext = { authenticated: isAuthenticated, user: userResponse.data };
176-
return routes.filter((route) => (route.show ? route.show(context) : true));
176+
return routes().filter((route) => (route.show ? route.show(context) : true));
177177
});
178178
</script>
179179

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
import * as SplitLayout from '$features/shared/components/layouts/split-layout';
66
import { getMeQuery } from '$features/users/api.svelte';
77
8-
import type { NavigationItemContext } from '../../routes';
8+
import type { NavigationItemContext } from '../../routes.svelte';
99
1010
import SidebarNav from '../(components)/sidebar-nav.svelte';
11-
import { routes } from './routes';
11+
import { routes } from './routes.svelte';
1212
1313
let { children } = $props();
1414
1515
const userResponse = getMeQuery();
1616
let isAuthenticated = $derived(accessToken.current !== null);
1717
const filteredRoutes = $derived.by(() => {
1818
const context: NavigationItemContext = { authenticated: isAuthenticated, user: userResponse.data };
19-
return routes.filter((route) => (route.show ? route.show(context) : true));
19+
return routes().filter((route) => (route.show ? route.show(context) : true));
2020
});
2121
</script>
2222

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import Notifications from 'lucide-svelte/icons/bell';
2+
import Password from 'lucide-svelte/icons/key-round';
3+
import Verify from 'lucide-svelte/icons/shield-check';
4+
import Appearance from 'lucide-svelte/icons/sun-moon';
5+
import Account from 'lucide-svelte/icons/user';
6+
import Sessions from 'lucide-svelte/icons/users';
7+
8+
import type { NavigationItem } from '../../routes.svelte';
9+
10+
export function routes(): NavigationItem[] {
11+
return [
12+
{
13+
group: 'My Account',
14+
href: '/next/account/manage',
15+
icon: Account,
16+
title: 'Account'
17+
},
18+
{
19+
group: 'My Account',
20+
href: '/next/account/appearance',
21+
icon: Appearance,
22+
title: 'Appearance'
23+
},
24+
{
25+
group: 'My Account',
26+
href: '/next/account/notifications',
27+
icon: Notifications,
28+
show: () => false,
29+
title: 'Notifications'
30+
},
31+
{
32+
group: 'My Account',
33+
href: '/next/account/security',
34+
icon: Password,
35+
show: () => false,
36+
title: 'Password and authentication'
37+
},
38+
{
39+
group: 'My Account',
40+
href: '/next/account/sessions',
41+
icon: Sessions,
42+
show: () => false,
43+
title: 'Sessions'
44+
},
45+
{
46+
group: 'My Account',
47+
href: '/next/account/verify',
48+
icon: Verify,
49+
show: () => false,
50+
title: 'Verify'
51+
}
52+
];
53+
}

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

Lines changed: 0 additions & 51 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// TODO: Show a message to the user that they need to upgrade their subscription.
3535
}
3636
37-
toast.error(`The event "${page.params.id}" could not be found.`);
37+
toast.error(`The event "${page.params.eventId}" could not be found.`);
3838
await goto('/next/');
3939
}
4040
</script>
@@ -45,7 +45,7 @@
4545
<Card.Title class="text-2xl" level={2}>Event Details</Card.Title></Card.Header
4646
>
4747
<Card.Content class="pt-4">
48-
<EventsOverview {filterChanged} id={page.params.id || ''} {handleError}></EventsOverview>
48+
<EventsOverview {filterChanged} id={page.params.eventId || ''} {handleError}></EventsOverview>
4949
</Card.Content>
5050
</Card.Root>
5151
</div>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { page } from '$app/state';
2+
import Events from 'lucide-svelte/icons/calendar-days';
3+
4+
import type { NavigationItem } from '../../routes.svelte';
5+
6+
export function routes(): NavigationItem[] {
7+
if (!page.params.eventId) {
8+
return [];
9+
}
10+
11+
return [
12+
{
13+
group: 'Event',
14+
href: `/next/event/${page.params.eventId}`,
15+
icon: Events,
16+
show: () => false,
17+
title: 'Event Details'
18+
}
19+
];
20+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { page } from '$app/state';
2+
import ClientConfig from 'lucide-svelte/icons/braces';
3+
import Configure from 'lucide-svelte/icons/cloud-download';
4+
import ApiKey from 'lucide-svelte/icons/key';
5+
import Integration from 'lucide-svelte/icons/plug-2';
6+
import Settings from 'lucide-svelte/icons/settings';
7+
import Webhook from 'lucide-svelte/icons/webhook';
8+
9+
import type { NavigationItem } from '../../../routes.svelte';
10+
11+
export function routes(): NavigationItem[] {
12+
if (!page.params.projectId) {
13+
return [];
14+
}
15+
16+
return [
17+
{
18+
group: 'Project Settings',
19+
href: `/next/project/${page.params.projectId}/manage`,
20+
icon: Settings,
21+
title: 'General'
22+
},
23+
{
24+
group: 'Project Settings',
25+
href: `/next/project/${page.params.projectId}/api-keys`,
26+
icon: ApiKey,
27+
title: 'API Keys'
28+
},
29+
{
30+
group: 'Project Settings',
31+
href: `/next/project/${page.params.projectId}/settings`,
32+
icon: Settings,
33+
title: 'Settings'
34+
},
35+
{
36+
group: 'Project Settings',
37+
href: `/next/project/${page.params.projectId}/config`,
38+
icon: ClientConfig,
39+
title: 'Client Configuration'
40+
},
41+
{
42+
group: 'Project Settings',
43+
href: `/next/project/${page.params.projectId}/configure`,
44+
icon: Configure,
45+
title: 'Download & Configure Client'
46+
},
47+
{
48+
group: 'Project Settings',
49+
href: `/next/project/${page.params.projectId}/webhooks`,
50+
icon: Webhook,
51+
title: 'Webhooks'
52+
},
53+
{
54+
group: 'Project Settings',
55+
href: `/next/project/${page.params.projectId}/integrations`,
56+
icon: Integration,
57+
title: 'Integrations'
58+
}
59+
];
60+
}

0 commit comments

Comments
 (0)