Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/umami-software/umami into fe…
Browse files Browse the repository at this point in the history
…at/um-290-update-clickhouse-client
  • Loading branch information
franciscao633 committed Oct 2, 2023
2 parents a1edd48 + 9bb89c7 commit 8e240af
Show file tree
Hide file tree
Showing 325 changed files with 2,859 additions and 3,302 deletions.
1 change: 1 addition & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
35 changes: 27 additions & 8 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const pkg = require('./package.json');
const contentSecurityPolicy = `
default-src 'self';
img-src *;
script-src 'self' 'unsafe-eval';
script-src 'self' 'unsafe-eval' 'unsafe-inline';
style-src 'self' 'unsafe-inline';
connect-src 'self' api.umami.is;
frame-ancestors 'self' ${process.env.ALLOWED_FRAME_URLS};
Expand Down Expand Up @@ -74,16 +74,23 @@ if (process.env.CLOUD_MODE && process.env.CLOUD_URL && process.env.DISABLE_LOGIN
});
}

const basePath = process.env.BASE_PATH;

/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: false,
env: {
cloudMode: process.env.CLOUD_MODE,
basePath: basePath || '',
cloudMode: !!process.env.CLOUD_MODE,
cloudUrl: process.env.CLOUD_URL,
configUrl: '/config',
currentVersion: pkg.version,
defaultLocale: process.env.DEFAULT_LOCALE,
disableLogin: process.env.DISABLE_LOGIN,
disableUI: process.env.DISABLE_UI,
isProduction: process.env.NODE_ENV === 'production',
},
basePath: process.env.BASE_PATH,
basePath,
output: 'standalone',
eslint: {
ignoreDuringBuilds: true,
Expand All @@ -92,11 +99,23 @@ const config = {
ignoreBuildErrors: true,
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
issuer: /\.{js|jsx|ts|tsx}$/,
use: ['@svgr/webpack'],
});
const fileLoaderRule = config.module.rules.find(rule => rule.test?.test?.('.svg'));

config.module.rules.push(
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/,
},
{
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] },
use: ['@svgr/webpack'],
},
);

fileLoaderRule.exclude = /\.svg$/i;

config.resolve.alias['public'] = path.resolve('./public');

Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@
"@clickhouse/client": "^0.2.2",
"@fontsource/inter": "^4.5.15",
"@prisma/client": "5.3.1",
"@react-spring/web": "^9.7.3",
"@tanstack/react-query": "^4.33.0",
"@umami/prisma-client": "^0.2.0",
"@umami/prisma-client": "^0.3.0",
"@umami/redis-client": "^0.15.0",
"chalk": "^4.1.1",
"chart.js": "^4.2.1",
Expand All @@ -91,7 +92,7 @@
"kafkajs": "^2.1.0",
"maxmind": "^4.3.6",
"moment-timezone": "^0.5.35",
"next": "13.5.2",
"next": "13.5.3",
"next-basics": "^0.36.0",
"node-fetch": "^3.2.8",
"npm-run-all": "^4.1.5",
Expand All @@ -100,9 +101,8 @@
"react-beautiful-dnd": "^13.1.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.4",
"react-intl": "^5.24.7",
"react-intl": "^6.4.7",
"react-simple-maps": "^2.3.0",
"react-spring": "^9.4.4",
"react-use-measure": "^2.0.4",
"react-window": "^1.8.6",
"request-ip": "^3.3.0",
Expand All @@ -123,12 +123,12 @@
"@rollup/plugin-node-resolve": "^15.2.0",
"@rollup/plugin-replace": "^5.0.2",
"@svgr/rollup": "^8.1.0",
"@svgr/webpack": "^6.2.1",
"@svgr/webpack": "^8.1.0",
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"cross-env": "^7.0.3",
"esbuild": "^0.17.17",
"eslint": "^8.33.0",
Expand All @@ -138,8 +138,8 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"extract-react-intl-messages": "^4.1.1",
"husky": "^7.0.0",
"lint-staged": "^11.0.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"postcss": "^8.4.21",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-import": "^15.1.0",
Expand Down
58 changes: 58 additions & 0 deletions src/app/(app)/NavBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use client';
import { Icon, Text } from 'react-basics';
import Link from 'next/link';
import classNames from 'classnames';
import Icons from 'components/icons';
import ThemeButton from 'components/input/ThemeButton';
import LanguageButton from 'components/input/LanguageButton';
import ProfileButton from 'components/input/ProfileButton';
import useMessages from 'components/hooks/useMessages';
import HamburgerButton from 'components/common/HamburgerButton';
import { usePathname } from 'next/navigation';
import styles from './NavBar.module.css';

export function NavBar() {
const pathname = usePathname();
const { formatMessage, labels } = useMessages();

const links = [
{ label: formatMessage(labels.dashboard), url: '/dashboard' },
{ label: formatMessage(labels.websites), url: '/websites' },
{ label: formatMessage(labels.reports), url: '/reports' },
{ label: formatMessage(labels.settings), url: '/settings' },
].filter(n => n);

return (
<div className={styles.navbar}>
<div className={styles.logo}>
<Icon size="lg">
<Icons.Logo />
</Icon>
<Text>umami</Text>
</div>
<div className={styles.links}>
{links.map(({ url, label }) => {
return (
<Link
key={url}
href={url}
className={classNames({ [styles.selected]: pathname.startsWith(url) })}
>
<Text>{label}</Text>
</Link>
);
})}
</div>
<div className={styles.actions}>
<ThemeButton />
<LanguageButton />
<ProfileButton />
</div>
<div className={styles.mobile}>
<HamburgerButton />
</div>
</div>
);
}

export default NavBar;
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
.navbar {
display: grid;
grid-template-columns: max-content 1fr 1fr;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
height: 60px;
background: var(--base75);
border-bottom: 1px solid var(--base300);
padding: 0 20px;
}

.left,
.right {
display: flex;
flex-direction: row;
align-items: center;
}

.right {
justify-content: flex-end;
}

.logo {
display: flex;
flex-direction: row;
Expand All @@ -35,29 +24,24 @@
flex-direction: row;
gap: 30px;
padding: 0 40px;
flex: 1;
font-weight: 700;
max-height: 60px;
}

.links a {
display: flex;
align-items: center;
gap: 10px;
line-height: 60px;
.links a,
.links a:active,
.links a:visited {
color: var(--font-color200);
line-height: 60px;
border-bottom: 2px solid transparent;
}

.links span {
white-space: nowrap;
}

.links a:hover {
color: var(--font-color100);
border-bottom: 2px solid var(--primary400);
}

.links .selected {
.links a.selected {
color: var(--font-color100);
border-bottom: 2px solid var(--primary400);
}
Expand All @@ -68,14 +52,17 @@
flex-direction: row;
align-items: center;
justify-content: flex-end;
min-width: 0;
}

.mobile {
display: none;
}

@media only screen and (max-width: 768px) {
.navbar {
grid-template-columns: repeat(2, 1fr);
}

.links,
.actions {
display: none;
Expand Down
27 changes: 27 additions & 0 deletions src/app/(app)/Shell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use client';
import Script from 'next/script';
import { usePathname } from 'next/navigation';
import UpdateNotice from 'components/common/UpdateNotice';
import { useRequireLogin, useConfig } from 'components/hooks';

export function Shell({ children }) {
const { user } = useRequireLogin();
const config = useConfig();
const pathname = usePathname();

if (!user || !config) {
return null;
}

return (
<>
{children}
<UpdateNotice user={user} config={config} />
{process.env.NODE_ENV === 'production' && !pathname.includes('/share/') && (
<Script src={`telemetry.js`} />
)}
</>
);
}

export default Shell;
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use client';
import WebsiteSelect from 'components/input/WebsiteSelect';
import Page from 'components/layout/Page';
import PageHeader from 'components/layout/PageHeader';
import EventsChart from 'components/metrics/EventsChart';
import WebsiteChart from 'components/pages/websites/WebsiteChart';
import WebsiteChart from '../websites/[id]/WebsiteChart';
import useApi from 'components/hooks/useApi';
import Head from 'next/head';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { useRouter } from 'next/navigation';
import Script from 'next/script';
import { Button, Column, Row } from 'react-basics';
import styles from './TestConsole.module.css';
Expand Down
20 changes: 20 additions & 0 deletions src/app/(app)/console/[[...id]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import TestConsole from '../TestConsole';
import { Metadata } from 'next';

async function getEnabled() {
return !!process.env.ENABLE_TEST_CONSOLE;
}

export default async function ConsolePage() {
const enabled = await getEnabled();

if (!enabled) {
return null;
}

return <TestConsole />;
}

export const metadata: Metadata = {
title: 'Test Console | umami',
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button, Icon, Icons, Text } from 'react-basics';
'use client';
import { Button, Icon, Icons, Loading, Text } from 'react-basics';
import Link from 'next/link';
import Page from 'components/layout/Page';
import PageHeader from 'components/layout/PageHeader';
import Pager from 'components/common/Pager';
import WebsiteChartList from 'components/pages/websites/WebsiteChartList';
import DashboardSettingsButton from 'components/pages/dashboard/DashboardSettingsButton';
import DashboardEdit from 'components/pages/dashboard/DashboardEdit';
import WebsiteChartList from '../websites/[id]/WebsiteChartList';
import DashboardSettingsButton from 'app/(app)/dashboard/DashboardSettingsButton';
import DashboardEdit from 'app/(app)/dashboard/DashboardEdit';
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
import useApi from 'components/hooks/useApi';
import useDashboard from 'store/dashboard';
Expand All @@ -20,18 +20,18 @@ export function Dashboard() {
const { get, useQuery } = useApi();
const { page, handlePageChange } = useApiFilter();
const pageSize = 10;
const {
data: result,
isLoading,
error,
} = useQuery(['websites', page, pageSize], () =>
const { data: result, isLoading } = useQuery(['websites', page, pageSize], () =>
get('/websites', { includeTeams: 1, page, pageSize }),
);
const { data, count } = result || {};
const hasData = data && data?.length !== 0;

if (isLoading) {
return <Loading size="lg" />;
}

return (
<Page loading={isLoading} error={error}>
<>
<PageHeader title={formatMessage(labels.dashboard)}>
{!editing && hasData && <DashboardSettingsButton />}
</PageHeader>
Expand Down Expand Up @@ -63,7 +63,7 @@ export function Dashboard() {
)}
</>
)}
</Page>
</>
);
}

Expand Down
Loading

0 comments on commit 8e240af

Please sign in to comment.