Skip to content

Commit 17185ca

Browse files
committed
refactor(web): update layout for new authentication state and redirects
Update the app layout: - Provide the LoginService for downstream components. - Integrate RedirectIfNotFinalized component at the top-level. - Only show Navigation if not on commit/login/signup page.
1 parent 54c96b8 commit 17185ca

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

apps/web/src/routes/(app)/+layout.svelte

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import '$lib/styles/global.css';
33
import { page } from '$app/state';
44
import { ButlerAIClient, BUTLER_AI_CLIENT } from '$lib/ai/service';
5+
import RedirectIfNotFinalized from '$lib/auth/RedirectIfNotFinalized.svelte';
56
import { AUTH_SERVICE } from '$lib/auth/authService.svelte';
67
import Footer from '$lib/components/Footer.svelte';
78
import Navigation from '$lib/components/Navigation.svelte';
@@ -20,6 +21,7 @@
2021
} from '@gitbutler/shared/chat/chatChannelsService';
2122
import { inject, provide } from '@gitbutler/shared/context';
2223
import { FeedService, FEED_SERVICE } from '@gitbutler/shared/feeds/service';
24+
import LoginService, { LOGIN_SERVICE } from '@gitbutler/shared/login/loginService';
2325
import { HttpClient, HTTP_CLIENT } from '@gitbutler/shared/network/httpClient';
2426
import {
2527
OrganizationService,
@@ -71,6 +73,9 @@
7173
const httpClient = new HttpClient(window.fetch, env.PUBLIC_APP_HOST, authService.tokenReadable);
7274
provide(HTTP_CLIENT, httpClient);
7375
76+
const loginService = new LoginService(httpClient);
77+
provide(LOGIN_SERVICE, loginService);
78+
7479
const aiService = new ButlerAIClient(httpClient);
7580
provide(BUTLER_AI_CLIENT, aiService);
7681
@@ -142,10 +147,15 @@
142147
provide(RULES_SERVICE, rulesService);
143148
144149
const isCommitPage = $derived(page.url.pathname.includes('/commit/'));
150+
const isLoginPage = $derived(page.url.pathname.includes('/login'));
151+
const isSignupPage = $derived(page.url.pathname.includes('/signup'));
152+
const hasNavigation = $derived(!isCommitPage && !isLoginPage && !isSignupPage);
145153
</script>
146154

155+
<RedirectIfNotFinalized />
156+
147157
<div class="app">
148-
{#if !isCommitPage}
158+
{#if hasNavigation}
149159
<Navigation />
150160
{/if}
151161

0 commit comments

Comments
 (0)