mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 18:25:21 -04:00
feat: fetch frontend config in server side rendering
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
312d1adf6f
commit
24f1b2a361
41 changed files with 270 additions and 220 deletions
|
@ -1,15 +1,15 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
||||
import links from '../../../links.json'
|
||||
import { useFrontendConfig } from '../../common/frontend-config-context/use-frontend-config'
|
||||
import { ExternalLink } from '../../common/links/external-link'
|
||||
import { TranslatedExternalLink } from '../../common/links/translated-external-link'
|
||||
import { TranslatedInternalLink } from '../../common/links/translated-internal-link'
|
||||
import { VersionInfoLink } from './version-info/version-info-link'
|
||||
import React, { Fragment } from 'react'
|
||||
import React, { Fragment, useMemo } from 'react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
|
||||
/**
|
||||
|
@ -18,8 +18,11 @@ import { Trans, useTranslation } from 'react-i18next'
|
|||
export const PoweredByLinks: React.FC = () => {
|
||||
useTranslation()
|
||||
|
||||
const specialUrls: [string, string][] = useApplicationState((state) =>
|
||||
Object.entries(state.config.specialUrls).map(([i18nkey, url]) => [i18nkey, String(url)])
|
||||
const rawSpecialUrls = useFrontendConfig().specialUrls
|
||||
|
||||
const specialUrls = useMemo(
|
||||
() => Object.entries(rawSpecialUrls).map(([i18nkey, url]) => [i18nkey, String(url)]),
|
||||
[rawSpecialUrls]
|
||||
)
|
||||
|
||||
return (
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { BackendVersion } from '../../../../api/config/types'
|
||||
import { useApplicationState } from '../../../../hooks/common/use-application-state'
|
||||
import links from '../../../../links.json'
|
||||
import { cypressId } from '../../../../utils/cypress-attribute'
|
||||
import { CopyableField } from '../../../common/copyable/copyable-field/copyable-field'
|
||||
import { useFrontendConfig } from '../../../common/frontend-config-context/use-frontend-config'
|
||||
import { TranslatedExternalLink } from '../../../common/links/translated-external-link'
|
||||
import type { CommonModalProps } from '../../../common/modals/common-modal'
|
||||
import { CommonModal } from '../../../common/modals/common-modal'
|
||||
|
@ -22,7 +22,7 @@ import { Modal } from 'react-bootstrap'
|
|||
* @param show If the modal should be shown.
|
||||
*/
|
||||
export const VersionInfoModal: React.FC<CommonModalProps> = ({ onHide, show }) => {
|
||||
const serverVersion: BackendVersion = useApplicationState((state) => state.config.version)
|
||||
const serverVersion: BackendVersion = useFrontendConfig().version
|
||||
const backendVersion = useMemo(() => {
|
||||
const version = `${serverVersion.major}.${serverVersion.minor}.${serverVersion.patch}`
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
||||
import { cypressId } from '../../../utils/cypress-attribute'
|
||||
import { useFrontendConfig } from '../../common/frontend-config-context/use-frontend-config'
|
||||
import { ShowIf } from '../../common/show-if/show-if'
|
||||
import { filterOneClickProviders } from '../../login-page/auth/utils'
|
||||
import { getOneClickProviderMetadata } from '../../login-page/auth/utils/get-one-click-provider-metadata'
|
||||
|
@ -25,7 +25,7 @@ export type SignInButtonProps = Omit<ButtonProps, 'href'>
|
|||
*/
|
||||
export const SignInButton: React.FC<SignInButtonProps> = ({ variant, ...props }) => {
|
||||
const { t } = useTranslation()
|
||||
const authProviders = useApplicationState((state) => state.config.authProviders)
|
||||
const authProviders = useFrontendConfig().authProviders
|
||||
|
||||
const loginLink = useMemo(() => {
|
||||
const oneClickProviders = authProviders.filter(filterOneClickProviders)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue