mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
only show GitHub button / dialog during onboarding
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
|||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/components/ui/dialog'
|
} from '@/components/ui/dialog'
|
||||||
import { useState } from 'react'
|
import { useCallback, useState } from 'react'
|
||||||
import { AuthMethodsList, OAuth2AuthConfig } from 'pocketbase'
|
import { AuthMethodsList, OAuth2AuthConfig } from 'pocketbase'
|
||||||
import { Link } from '../router'
|
import { Link } from '../router'
|
||||||
|
|
||||||
@@ -67,7 +67,8 @@ export function UserAuthForm({
|
|||||||
const [isOauthLoading, setIsOauthLoading] = useState<boolean>(false)
|
const [isOauthLoading, setIsOauthLoading] = useState<boolean>(false)
|
||||||
const [errors, setErrors] = useState<Record<string, string | undefined>>({})
|
const [errors, setErrors] = useState<Record<string, string | undefined>>({})
|
||||||
|
|
||||||
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
const handleSubmit = useCallback(
|
||||||
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
try {
|
try {
|
||||||
@@ -117,7 +118,9 @@ export function UserAuthForm({
|
|||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
[isFirstRun]
|
||||||
|
)
|
||||||
|
|
||||||
if (!authMethods) {
|
if (!authMethods) {
|
||||||
return null
|
return null
|
||||||
@@ -225,6 +228,8 @@ export function UserAuthForm({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{(isFirstRun || authMethods.authProviders.length > 0) && (
|
||||||
|
// only show 'continue with' during onboarding or if we have auth providers
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<div className="absolute inset-0 flex items-center">
|
<div className="absolute inset-0 flex items-center">
|
||||||
<span className="w-full border-t" />
|
<span className="w-full border-t" />
|
||||||
@@ -233,6 +238,7 @@ export function UserAuthForm({
|
|||||||
<span className="bg-background px-2 text-muted-foreground">Or continue with</span>
|
<span className="bg-background px-2 text-muted-foreground">Or continue with</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -297,7 +303,8 @@ export function UserAuthForm({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!authMethods.authProviders.length && (
|
{!authMethods.authProviders.length && isFirstRun && (
|
||||||
|
// only show GitHub button / dialog during onboarding
|
||||||
<Dialog>
|
<Dialog>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<button type="button" className={cn(buttonVariants({ variant: 'outline' }))}>
|
<button type="button" className={cn(buttonVariants({ variant: 'outline' }))}>
|
||||||
|
Reference in New Issue
Block a user