From a282a41c39bdde9cd1eb7947e3891e21fbea863a Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Thu, 21 Mar 2024 18:41:22 +0100 Subject: [PATCH] Use `getContextByClass` for `AuthService` --- gitbutler-ui/src/lib/components/CredentialCheck.svelte | 6 ++++-- gitbutler-ui/src/lib/components/KeysForm.svelte | 5 ++--- gitbutler-ui/src/lib/components/ProjectSetup.svelte | 6 ++---- gitbutler-ui/src/routes/+layout.svelte | 6 ++++-- gitbutler-ui/src/routes/[projectId]/settings/+page.svelte | 5 +++-- gitbutler-ui/src/routes/[projectId]/setup/+page.svelte | 4 ++-- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/gitbutler-ui/src/lib/components/CredentialCheck.svelte b/gitbutler-ui/src/lib/components/CredentialCheck.svelte index 2e8e46f86..604c85900 100644 --- a/gitbutler-ui/src/lib/components/CredentialCheck.svelte +++ b/gitbutler-ui/src/lib/components/CredentialCheck.svelte @@ -3,14 +3,16 @@ import Icon from './Icon.svelte'; import InfoMessage from './InfoMessage.svelte'; import Link from './Link.svelte'; + import { AuthService } from '$lib/backend/auth'; + import { getContextByClass } from '$lib/utils/context'; import { slide } from 'svelte/transition'; - import type { AuthService } from '$lib/backend/auth'; - export let authService: AuthService; export let projectId: string; export let remoteName: string | null | undefined; export let branchName: string | null | undefined; + const authService = getContextByClass(AuthService); + type Check = { name: string; promise: Promise }; $: checks = [] as Check[]; diff --git a/gitbutler-ui/src/lib/components/KeysForm.svelte b/gitbutler-ui/src/lib/components/KeysForm.svelte index aa3a38ab6..b5e78b3f5 100644 --- a/gitbutler-ui/src/lib/components/KeysForm.svelte +++ b/gitbutler-ui/src/lib/components/KeysForm.svelte @@ -4,6 +4,7 @@ import RadioButton from './RadioButton.svelte'; import SectionCard from './SectionCard.svelte'; import TextBox from './TextBox.svelte'; + import { AuthService } from '$lib/backend/auth'; import { ProjectService, type Key, type KeyType, type Project } from '$lib/backend/projects'; import Button from '$lib/components/Button.svelte'; import Link from '$lib/components/Link.svelte'; @@ -13,11 +14,10 @@ import { openExternalUrl } from '$lib/utils/url'; import { BaseBranch } from '$lib/vbranches/types'; import { onMount } from 'svelte'; - import type { AuthService } from '$lib/backend/auth'; - export let authService: AuthService; export let project: Project; + const authService = getContextByClass(AuthService); const baseBranch = getContextStoreByClass(BaseBranch); const projectService = getContextByClass(ProjectService); @@ -207,7 +207,6 @@ diff --git a/gitbutler-ui/src/lib/components/ProjectSetup.svelte b/gitbutler-ui/src/lib/components/ProjectSetup.svelte index 96e93e725..0ade77d97 100644 --- a/gitbutler-ui/src/lib/components/ProjectSetup.svelte +++ b/gitbutler-ui/src/lib/components/ProjectSetup.svelte @@ -7,15 +7,13 @@ import { UserService } from '$lib/stores/user'; import { getContextByClass } from '$lib/utils/context'; import { BranchController } from '$lib/vbranches/branchController'; - import type { AuthService } from '$lib/backend/auth'; import type { Project } from '$lib/backend/projects'; import { goto } from '$app/navigation'; - export let authService: AuthService; - const branchController = getContextByClass(BranchController); export let project: Project; export let remoteBranches: { name: string }[]; + const branchController = getContextByClass(BranchController); const userService = getContextByClass(UserService); const user = userService.user; @@ -37,7 +35,7 @@ {#if selectedBranch} {@const [remoteName, branchName] = selectedBranch.split(/\/(.*)/s)} - +
- + diff --git a/gitbutler-ui/src/routes/[projectId]/setup/+page.svelte b/gitbutler-ui/src/routes/[projectId]/setup/+page.svelte index ec473ed79..f2457e64e 100644 --- a/gitbutler-ui/src/routes/[projectId]/setup/+page.svelte +++ b/gitbutler-ui/src/routes/[projectId]/setup/+page.svelte @@ -7,7 +7,7 @@ export let data: PageData; - $: ({ authService, projectId, project$ } = data); + $: ({ projectId, project$ } = data); {#await getRemoteBranches(projectId)} @@ -21,7 +21,7 @@ use virtual branches, please push your code to a remote branch to use as a base" /> {:else} - + {/if} {:catch}