mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 01:36:29 -05:00
enhancement: use isLoggedIn hook
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
8e10fb6804
commit
3dfad0cea5
5 changed files with 19 additions and 10 deletions
|
@ -1,3 +1,9 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
'use client'
|
||||
|
||||
/*
|
||||
|
@ -14,16 +20,16 @@ import { Trans } from 'react-i18next'
|
|||
import { CustomBranding } from '../../../components/common/custom-branding/custom-branding'
|
||||
import { IntroCustomContent } from '../../../components/intro-page/intro-custom-content'
|
||||
import React from 'react'
|
||||
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
||||
import { RedirectToParamOrHistory } from '../../../components/login-page/redirect-to-param-or-history'
|
||||
import { Col, Container, Row } from 'react-bootstrap'
|
||||
import { LocalLoginCard } from '../../../components/login-page/local-login/local-login-card'
|
||||
import { LdapLoginCards } from '../../../components/login-page/ldap/ldap-login-cards'
|
||||
import { OneClickLoginCard } from '../../../components/login-page/one-click/one-click-login-card'
|
||||
import { GuestCard } from '../../../components/login-page/guest/guest-card'
|
||||
import { useIsLoggedIn } from '../../../hooks/common/use-is-logged-in'
|
||||
|
||||
const LoginPage: NextPage = () => {
|
||||
const userLoggedIn = useApplicationState((state) => !!state.user)
|
||||
const userLoggedIn = useIsLoggedIn()
|
||||
|
||||
if (userLoggedIn) {
|
||||
return <RedirectToParamOrHistory />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -15,6 +15,7 @@ import React from 'react'
|
|||
import { Dropdown } from 'react-bootstrap'
|
||||
import { Cloud as IconCloud, Laptop as IconLaptop, ThreeDots as IconThreeDots } from 'react-bootstrap-icons'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { useIsLoggedIn } from '../../../hooks/common/use-is-logged-in'
|
||||
|
||||
export interface EntryMenuProps {
|
||||
id: string
|
||||
|
@ -44,7 +45,7 @@ export const EntryMenu: React.FC<EntryMenuProps> = ({
|
|||
className
|
||||
}) => {
|
||||
useTranslation()
|
||||
const userExists = useApplicationState((state) => !!state.user)
|
||||
const userExists = useIsLoggedIn()
|
||||
|
||||
return (
|
||||
<Dropdown className={`d-inline-flex ${className || ''}`} {...cypressId('history-entry-menu')}>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -24,6 +24,7 @@ import { useSyncToolbarStateToUrlEffect } from './toolbar-context/use-sync-toolb
|
|||
import React, { useCallback } from 'react'
|
||||
import { Button, Col } from 'react-bootstrap'
|
||||
import { CloudUpload as IconCloudUpload } from 'react-bootstrap-icons'
|
||||
import { useIsLoggedIn } from '../../../hooks/common/use-is-logged-in'
|
||||
|
||||
export enum ViewStateEnum {
|
||||
CARD,
|
||||
|
@ -35,7 +36,7 @@ export enum ViewStateEnum {
|
|||
*/
|
||||
export const HistoryToolbar: React.FC = () => {
|
||||
const historyEntries = useApplicationState((state) => state.history)
|
||||
const userExists = useApplicationState((state) => !!state.user)
|
||||
const userExists = useIsLoggedIn()
|
||||
const { showErrorNotification } = useUiNotifications()
|
||||
const safeRefreshHistoryState = useSafeRefreshHistoryStateCallback()
|
||||
useSyncToolbarStateToUrlEffect()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -16,12 +16,13 @@ import { useSafeRefreshHistoryStateCallback } from './hooks/use-safe-refresh-his
|
|||
import React, { useCallback, useRef, useState } from 'react'
|
||||
import { Button } from 'react-bootstrap'
|
||||
import { Upload as IconUpload } from 'react-bootstrap-icons'
|
||||
import { useIsLoggedIn } from '../../../hooks/common/use-is-logged-in'
|
||||
|
||||
/**
|
||||
* Button that lets the user select a history JSON file and uploads imports that into the history.
|
||||
*/
|
||||
export const ImportHistoryButton: React.FC = () => {
|
||||
const userExists = useApplicationState((state) => !!state.user)
|
||||
const userExists = useIsLoggedIn()
|
||||
const historyState = useApplicationState((state) => state.history)
|
||||
const uploadInput = useRef<HTMLInputElement>(null)
|
||||
const [fileName, setFilename] = useState('')
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { useApplicationState } from '../../../../hooks/common/use-application-state'
|
||||
import { SignInButton } from '../../../landing-layout/navigation/sign-in-button'
|
||||
import { UserDropdown } from '../../../landing-layout/navigation/user-dropdown'
|
||||
import React from 'react'
|
||||
import { useIsLoggedIn } from '../../../../hooks/common/use-is-logged-in'
|
||||
|
||||
/**
|
||||
* Renders either the user dropdown or the sign-in button depending on the user state.
|
||||
*/
|
||||
export const UserElement: React.FC = () => {
|
||||
const userExists = useApplicationState((state) => !!state.user)
|
||||
const userExists = useIsLoggedIn()
|
||||
return userExists ? <UserDropdown /> : <SignInButton size={'sm'} className={'h-100'} />
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue