From dd88b1d901f19736d723076c886ddeb7db9b6432 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 29 Mar 2024 11:48:12 -0700 Subject: [PATCH] Fixed styling on update notice. Added private mode. --- next.config.js | 2 ++ src/app/(main)/UpdateNotice.module.css | 7 +++++-- src/app/(main)/UpdateNotice.tsx | 5 +++-- src/components/common/Favicon.tsx | 4 ++++ src/components/input/ProfileButton.tsx | 2 +- src/pages/api/scripts/telemetry.ts | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/next.config.js b/next.config.js index dce49100..f8850c60 100644 --- a/next.config.js +++ b/next.config.js @@ -14,6 +14,7 @@ const frameAncestors = process.env.ALLOWED_FRAME_URLS || ''; const disableLogin = process.env.DISABLE_LOGIN || ''; const disableUI = process.env.DISABLE_UI || ''; const hostURL = process.env.HOST_URL || ''; +const privateMode = process.env.PRIVATE_MODE || ''; const contentSecurityPolicy = [ `default-src 'self'`, @@ -120,6 +121,7 @@ const config = { disableLogin, disableUI, hostURL, + privateMode, }, basePath, output: 'standalone', diff --git a/src/app/(main)/UpdateNotice.module.css b/src/app/(main)/UpdateNotice.module.css index 261a3169..fec0962c 100644 --- a/src/app/(main)/UpdateNotice.module.css +++ b/src/app/(main)/UpdateNotice.module.css @@ -1,14 +1,17 @@ .notice { position: absolute; + display: flex; + justify-content: space-between; + width: 100%; max-width: 800px; gap: 20px; - margin: 80px auto; + margin: 60px auto; align-self: center; background: var(--base50); padding: 20px; border: 1px solid var(--base300); border-radius: var(--border-radius); - z-index: var(--z-index-popup); + z-index: 9999; box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1); } diff --git a/src/app/(main)/UpdateNotice.tsx b/src/app/(main)/UpdateNotice.tsx index 54ad05c9..553e1138 100644 --- a/src/app/(main)/UpdateNotice.tsx +++ b/src/app/(main)/UpdateNotice.tsx @@ -4,9 +4,9 @@ import { Button } from 'react-basics'; import { setItem } from 'next-basics'; import useStore, { checkVersion } from 'store/version'; import { REPO_URL, VERSION_CHECK } from 'lib/constants'; -import styles from './UpdateNotice.module.css'; import { useMessages } from 'components/hooks'; import { usePathname } from 'next/navigation'; +import styles from './UpdateNotice.module.css'; export function UpdateNotice({ user, config }) { const { formatMessage, labels, messages } = useMessages(); @@ -16,8 +16,9 @@ export function UpdateNotice({ user, config }) { const allowUpdate = user?.isAdmin && !config?.updatesDisabled && - !config?.cloudMode && !pathname.includes('/share/') && + !process.env.cloudMode && + !process.env.privateMode && !dismissed; const updateCheck = useCallback(() => { diff --git a/src/components/common/Favicon.tsx b/src/components/common/Favicon.tsx index 2bf43c77..2793c0d0 100644 --- a/src/components/common/Favicon.tsx +++ b/src/components/common/Favicon.tsx @@ -6,6 +6,10 @@ function getHostName(url: string) { } export function Favicon({ domain, ...props }) { + if (process.env.privateMode) { + return null; + } + const hostName = domain ? getHostName(domain) : null; return hostName ? ( diff --git a/src/components/input/ProfileButton.tsx b/src/components/input/ProfileButton.tsx index ff3ee63e..b1875165 100644 --- a/src/components/input/ProfileButton.tsx +++ b/src/components/input/ProfileButton.tsx @@ -11,7 +11,7 @@ export function ProfileButton() { const { user } = useLogin(); const router = useRouter(); const { dir } = useLocale(); - const cloudMode = Boolean(process.env.cloudMode); + const cloudMode = !!process.env.cloudMode; const handleSelect = (key: Key, close: () => void) => { if (key === 'profile') { diff --git a/src/pages/api/scripts/telemetry.ts b/src/pages/api/scripts/telemetry.ts index bc0fd503..a8a8872e 100644 --- a/src/pages/api/scripts/telemetry.ts +++ b/src/pages/api/scripts/telemetry.ts @@ -6,7 +6,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) { if (process.env.NODE_ENV === 'production') { res.setHeader('content-type', 'text/javascript'); - if (process.env.DISABLE_TELEMETRY) { + if (process.env.DISABLE_TELEMETRY || process.env.PRIVATE_MODE) { return res.send('/* telemetry disabled */'); }