mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Merge branch 'dev' into jajaja
# Conflicts: # next.config.ts # src/app/(main)/settings/preferences/LanguageSetting.tsx # src/components/hooks/useConfig.ts
This commit is contained in:
commit
b552868e0a
14 changed files with 55 additions and 44 deletions
|
|
@ -25,10 +25,6 @@ export function App({ children }) {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (config.uiDisabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Grid height="100vh" width="100%" columns="auto 1fr" backgroundColor="2">
|
||||
<Column>
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ export function UpdateNotice({ user, config }) {
|
|||
const { latest, checked, hasUpdate, releaseUrl } = useVersion();
|
||||
const pathname = usePathname();
|
||||
const [dismissed, setDismissed] = useState(checked);
|
||||
|
||||
const allowUpdate =
|
||||
process.env.NODE_ENV === 'production' &&
|
||||
user?.isAdmin &&
|
||||
!config?.updatesDisabled &&
|
||||
!config?.privateMode &&
|
||||
!pathname.includes('/share/') &&
|
||||
!process.env.cloudMode &&
|
||||
!process.env.privateMode &&
|
||||
!dismissed;
|
||||
|
||||
const updateCheck = useCallback(() => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,19 @@
|
|||
'use server';
|
||||
|
||||
export async function getConfig() {
|
||||
export type Config = {
|
||||
faviconUrl: string | undefined;
|
||||
privateMode: boolean;
|
||||
telemetryDisabled: boolean;
|
||||
trackerScriptName: string | undefined;
|
||||
updatesDisabled: boolean;
|
||||
};
|
||||
|
||||
export async function getConfig(): Promise<Config> {
|
||||
return {
|
||||
faviconUrl: process.env.FAVICON_URL,
|
||||
privateMode: !!process.env.PRIVATE_MODE,
|
||||
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
||||
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
|
||||
uiDisabled: !!process.env.DISABLE_UI,
|
||||
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
||||
loginDisabled: !!process.env.DISABLE_LOGIN,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,25 +2,25 @@ import { CURRENT_VERSION, TELEMETRY_PIXEL } from '@/lib/constants';
|
|||
|
||||
export async function GET() {
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
process.env.DISABLE_TELEMETRY &&
|
||||
process.env.NODE_ENV !== 'production' ||
|
||||
process.env.DISABLE_TELEMETRY ||
|
||||
process.env.PRIVATE_MODE
|
||||
) {
|
||||
const script = `
|
||||
(()=>{const i=document.createElement('img');
|
||||
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${CURRENT_VERSION}');
|
||||
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
|
||||
document.body.appendChild(i);})();
|
||||
`;
|
||||
|
||||
return new Response(script.replace(/\s\s+/g, ''), {
|
||||
return new Response('/* telemetry disabled */', {
|
||||
headers: {
|
||||
'content-type': 'text/javascript',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return new Response('/* telemetry disabled */', {
|
||||
const script = `
|
||||
(()=>{const i=document.createElement('img');
|
||||
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${CURRENT_VERSION}');
|
||||
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
|
||||
document.body.appendChild(i);})();
|
||||
`;
|
||||
|
||||
return new Response(script.replace(/\s\s+/g, ''), {
|
||||
headers: {
|
||||
'content-type': 'text/javascript',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@ import '@/styles/global.css';
|
|||
import '@/styles/variables.css';
|
||||
|
||||
export default function ({ children }) {
|
||||
if (process.env.DISABLE_UI) {
|
||||
return (
|
||||
<html>
|
||||
<body></body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@ import { Column } from '@umami/react-zen';
|
|||
import { LoginForm } from './LoginForm';
|
||||
|
||||
export function LoginPage() {
|
||||
if (process.env.disableLogin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Column justifyContent="center" alignItems="center" height="100vh" backgroundColor="2">
|
||||
<LoginForm />
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ import { Metadata } from 'next';
|
|||
import { LoginPage } from './LoginPage';
|
||||
|
||||
export default async function () {
|
||||
if (process.env.DISABLE_LOGIN) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <LoginPage />;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import { setUser } from '@/store/app';
|
|||
import { removeClientAuthToken } from '@/lib/client';
|
||||
|
||||
export function LogoutPage() {
|
||||
const disabled = !!(process.env.disableLogin || process.env.cloudMode);
|
||||
const router = useRouter();
|
||||
const { post } = useApi();
|
||||
const disabled = process.env.cloudMode;
|
||||
|
||||
useEffect(() => {
|
||||
async function logout() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ import { LogoutPage } from './LogoutPage';
|
|||
import { Metadata } from 'next';
|
||||
|
||||
export default function () {
|
||||
if (process.env.DISABLE_LOGIN) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <LogoutPage />;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { useConfig } from '@/components/hooks';
|
||||
import { FAVICON_URL, GROUPED_DOMAINS } from '@/lib/constants';
|
||||
|
||||
function getHostName(url: string) {
|
||||
|
|
@ -6,11 +7,13 @@ function getHostName(url: string) {
|
|||
}
|
||||
|
||||
export function Favicon({ domain, ...props }) {
|
||||
if (process.env.privateMode) {
|
||||
const config = useConfig();
|
||||
|
||||
if (config?.privateMode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const url = process.env.faviconURL || FAVICON_URL;
|
||||
const url = config?.faviconUrl || FAVICON_URL;
|
||||
const hostName = domain ? getHostName(domain) : null;
|
||||
const domainName = GROUPED_DOMAINS[hostName]?.domain || hostName;
|
||||
const src = hostName ? url.replace(/\{\{\s*domain\s*}}/, domainName) : null;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { useEffect } from 'react';
|
||||
import { useApp, setConfig } from '@/store/app';
|
||||
import { getConfig } from '@/app/actions/getConfig';
|
||||
import { getConfig, Config } from '@/app/actions/getConfig';
|
||||
|
||||
export function useConfig() {
|
||||
export function useConfig(): Config {
|
||||
const { config } = useApp();
|
||||
|
||||
async function loadConfig() {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export const UPDATES_URL = 'https://api.umami.is/v1/updates';
|
|||
export const TELEMETRY_PIXEL = 'https://i.umami.is/a.png';
|
||||
export const FAVICON_URL = 'https://icons.duckduckgo.com/ip3/{{domain}}.ico';
|
||||
|
||||
export const DEFAULT_LOCALE = process.env.defaultLocale || 'en-US';
|
||||
export const DEFAULT_LOCALE = 'en-US';
|
||||
export const DEFAULT_THEME = 'light';
|
||||
export const DEFAULT_ANIMATION_DURATION = 300;
|
||||
export const DEFAULT_DATE_RANGE_VALUE = '24hour';
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ function getDefaultTheme() {
|
|||
}
|
||||
|
||||
const initialState = {
|
||||
locale: getItem(LOCALE_CONFIG) || DEFAULT_LOCALE,
|
||||
locale: getItem(LOCALE_CONFIG) || process.env.defaultLocale || DEFAULT_LOCALE,
|
||||
theme: getItem(THEME_CONFIG) || getDefaultTheme() || DEFAULT_THEME,
|
||||
timezone: getItem(TIMEZONE_CONFIG) || getTimezone(),
|
||||
dateRangeValue: getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE_VALUE,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue