Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Merge branch 'dev' into jajaja

Mike Caob552868e0a77
diff --cc next.config.ts
index f2c07aff9,7f4020084..77a0c1c6c
--- a/next.config.ts
+++ b/next.config.ts
@@@ -168,13 -163,17 +164,11 @@@ if (cloudMode && cloudUrl)
permanent: false,
});
- if (disableLogin) {
- redirects.push({
- source: '/login',
- destination: cloudUrl,
- permanent: false,
- });
- }
- redirects.push({
- source: '/teams/:id/settings/:path*',
- destination: `${cloudUrl}/teams/:id/settings/:path*`,
- permanent: false,
- });
-
+ redirects.push({
+ source: '/login',
+ destination: cloudUrl,
+ permanent: false,
+ });
}
/** @type {import('next').NextConfig} */
diff --cc src/app/(main)/App.tsx
index 53d305fe3,b4cbdfdea..e3602d5a8
--- a/src/app/(main)/App.tsx
+++ b/src/app/(main)/App.tsx
@@@ -25,19 -22,9 +25,15 @@@ export function App({ children })
return null;
}
- if (config.uiDisabled) {
- return null;
- }
-
return (
- <>
- {children}
+ <Grid height="100vh" width="100%" columns="auto 1fr" backgroundColor="2">
+ <Column>
+ <SideNav />
+ </Column>
+ <Column alignItems="center" overflow="auto" position="relative">
+ <TopNav />
+ {children}
+ </Column>
<UpdateNotice user={user} config={config} />
{process.env.NODE_ENV === 'production' && !pathname.includes('/share/') && (
<Script src={`${process.env.basePath || ''}/telemetry.js`} />
diff --cc src/app/(main)/UpdateNotice.tsx
index ed163d521,ea102faa4..357287912
--- a/src/app/(main)/UpdateNotice.tsx
+++ b/src/app/(main)/UpdateNotice.tsx
@@@ -8,9 -9,11 +8,10 @@@ import { usePathname } from 'next/navig
export function UpdateNotice({ user, config }) {
const { formatMessage, labels, messages } = useMessages();
- const { latest, checked, hasUpdate, releaseUrl } = useStore();
+ const { latest, checked, hasUpdate, releaseUrl } = useVersion();
const pathname = usePathname();
const [dismissed, setDismissed] = useState(checked);
+
const allowUpdate =
process.env.NODE_ENV === 'production' &&
user?.isAdmin &&
diff --cc src/app/actions/getConfig.ts
index 7a16a3a4b,32b8a7d09..cc99dd9f4
--- a/src/app/actions/getConfig.ts
+++ b/src/app/actions/getConfig.ts
@@@ -1,11 -1,19 +1,20 @@@
'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,
};
}
diff --cc src/app/layout.tsx
index 448915eb2,e939f8c44..b2430cc29
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@@ -9,8 -9,16 +9,16 @@@ 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" data-scroll="0">
+ <html lang="en">
<head>
<link rel="icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
diff --cc src/app/login/LoginPage.tsx
index a4fc9b55c,2eca070f9..83d17bd4e
--- a/src/app/login/LoginPage.tsx
+++ b/src/app/login/LoginPage.tsx
@@@ -1,15 -1,13 +1,11 @@@
'use client';
-import LoginForm from './LoginForm';
-import styles from './LoginPage.module.css';
+import { Column } from '@umami/react-zen';
+import { LoginForm } from './LoginForm';
export function LoginPage() {
- if (process.env.disableLogin) {
- return null;
- }
-
return (
- <div className={styles.page}>
+ <Column justifyContent="center" alignItems="center" height="100vh" backgroundColor="2">
<LoginForm />
- </div>
+ </Column>
);
}
-
-export default LoginPage;
diff --cc src/app/login/page.tsx
index 364561f1c,cca230c20..4c8d80446
--- a/src/app/login/page.tsx
+++ b/src/app/login/page.tsx
@@@ -1,7 -1,11 +1,11 @@@
import { Metadata } from 'next';
-import LoginPage from './LoginPage';
+import { LoginPage } from './LoginPage';
export default async function () {
+ if (process.env.DISABLE_LOGIN) {
+ return null;
+ }
+
return <LoginPage />;
}
diff --cc src/components/hooks/useConfig.ts
index b0fe287e5,9533d6162..46c815d64
--- a/src/components/hooks/useConfig.ts
+++ b/src/components/hooks/useConfig.ts
@@@ -1,9 -1,9 +1,9 @@@
import { useEffect } from 'react';
-import useStore, { setConfig } from '@/store/app';
+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 } = useStore();
+ const { config } = useApp();
async function loadConfig() {
setConfig(await getConfig());
diff --cc src/lib/constants.ts
index b53508722,7ac1d2abe..1564458d2
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@@ -13,13 -13,13 +13,13 @@@ export const UPDATES_URL = 'https://api
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 = '24hour';
+export const DEFAULT_DATE_RANGE_VALUE = '24hour';
export const DEFAULT_WEBSITE_LIMIT = 10;
export const DEFAULT_RESET_DATE = '2000-01-01';
-export const DEFAULT_PAGE_SIZE = 10;
+export const DEFAULT_PAGE_SIZE = 20;
export const DEFAULT_DATE_COMPARE = 'prev';
export const REALTIME_RANGE = 30;
diff --cc src/store/app.ts
index 56bd589ee,1908023fc..3f22756db
--- a/src/store/app.ts
+++ b/src/store/app.ts
@@@ -20,10 -20,10 +20,10 @@@ 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(),
- dateRange: getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE,
+ dateRangeValue: getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE_VALUE,
shareToken: null,
user: null,
config: null,