Merge branch 'dev' of https://github.com/umami-software/umami into feat/um-290-update-clickhouse-client
This commit is contained in:
commit
8e240af9e8
325 files changed
+2853
-3296
No files matched your search
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
|
/// <reference types="next/navigation-types/compat/navigation" />
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||||
+27
-8
@@ -6,7 +6,7 @@ const pkg = require('./package.json');
|
|||||||
const contentSecurityPolicy = `
|
const contentSecurityPolicy = `
|
||||||
default-src 'self';
|
default-src 'self';
|
||||||
img-src *;
|
img-src *;
|
||||||
script-src 'self' 'unsafe-eval';
|
script-src 'self' 'unsafe-eval' 'unsafe-inline';
|
||||||
style-src 'self' 'unsafe-inline';
|
style-src 'self' 'unsafe-inline';
|
||||||
connect-src 'self' api.umami.is;
|
connect-src 'self' api.umami.is;
|
||||||
frame-ancestors 'self' ${process.env.ALLOWED_FRAME_URLS};
|
frame-ancestors 'self' ${process.env.ALLOWED_FRAME_URLS};
|
||||||
@@ -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 = {
|
const config = {
|
||||||
|
reactStrictMode: false,
|
||||||
env: {
|
env: {
|
||||||
cloudMode: process.env.CLOUD_MODE,
|
basePath: basePath || '',
|
||||||
|
cloudMode: !!process.env.CLOUD_MODE,
|
||||||
cloudUrl: process.env.CLOUD_URL,
|
cloudUrl: process.env.CLOUD_URL,
|
||||||
configUrl: '/config',
|
configUrl: '/config',
|
||||||
currentVersion: pkg.version,
|
currentVersion: pkg.version,
|
||||||
defaultLocale: process.env.DEFAULT_LOCALE,
|
defaultLocale: process.env.DEFAULT_LOCALE,
|
||||||
|
disableLogin: process.env.DISABLE_LOGIN,
|
||||||
|
disableUI: process.env.DISABLE_UI,
|
||||||
isProduction: process.env.NODE_ENV === 'production',
|
isProduction: process.env.NODE_ENV === 'production',
|
||||||
},
|
},
|
||||||
basePath: process.env.BASE_PATH,
|
basePath,
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
eslint: {
|
eslint: {
|
||||||
ignoreDuringBuilds: true,
|
ignoreDuringBuilds: true,
|
||||||
@@ -92,11 +99,23 @@ const config = {
|
|||||||
ignoreBuildErrors: true,
|
ignoreBuildErrors: true,
|
||||||
},
|
},
|
||||||
webpack(config) {
|
webpack(config) {
|
||||||
config.module.rules.push({
|
const fileLoaderRule = config.module.rules.find(rule => rule.test?.test?.('.svg'));
|
||||||
test: /\.svg$/,
|
|
||||||
issuer: /\.{js|jsx|ts|tsx}$/,
|
config.module.rules.push(
|
||||||
use: ['@svgr/webpack'],
|
{
|
||||||
});
|
...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');
|
config.resolve.alias['public'] = path.resolve('./public');
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -64,8 +64,9 @@
|
|||||||
"@clickhouse/client": "^0.2.2",
|
"@clickhouse/client": "^0.2.2",
|
||||||
"@fontsource/inter": "^4.5.15",
|
"@fontsource/inter": "^4.5.15",
|
||||||
"@prisma/client": "5.3.1",
|
"@prisma/client": "5.3.1",
|
||||||
|
"@react-spring/web": "^9.7.3",
|
||||||
"@tanstack/react-query": "^4.33.0",
|
"@tanstack/react-query": "^4.33.0",
|
||||||
"@umami/prisma-client": "^0.2.0",
|
"@umami/prisma-client": "^0.3.0",
|
||||||
"@umami/redis-client": "^0.15.0",
|
"@umami/redis-client": "^0.15.0",
|
||||||
"chalk": "^4.1.1",
|
"chalk": "^4.1.1",
|
||||||
"chart.js": "^4.2.1",
|
"chart.js": "^4.2.1",
|
||||||
@@ -91,7 +92,7 @@
|
|||||||
"kafkajs": "^2.1.0",
|
"kafkajs": "^2.1.0",
|
||||||
"maxmind": "^4.3.6",
|
"maxmind": "^4.3.6",
|
||||||
"moment-timezone": "^0.5.35",
|
"moment-timezone": "^0.5.35",
|
||||||
"next": "13.5.2",
|
"next": "13.5.3",
|
||||||
"next-basics": "^0.36.0",
|
"next-basics": "^0.36.0",
|
||||||
"node-fetch": "^3.2.8",
|
"node-fetch": "^3.2.8",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
@@ -100,9 +101,8 @@
|
|||||||
"react-beautiful-dnd": "^13.1.0",
|
"react-beautiful-dnd": "^13.1.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-error-boundary": "^4.0.4",
|
"react-error-boundary": "^4.0.4",
|
||||||
"react-intl": "^5.24.7",
|
"react-intl": "^6.4.7",
|
||||||
"react-simple-maps": "^2.3.0",
|
"react-simple-maps": "^2.3.0",
|
||||||
"react-spring": "^9.4.4",
|
|
||||||
"react-use-measure": "^2.0.4",
|
"react-use-measure": "^2.0.4",
|
||||||
"react-window": "^1.8.6",
|
"react-window": "^1.8.6",
|
||||||
"request-ip": "^3.3.0",
|
"request-ip": "^3.3.0",
|
||||||
@@ -123,12 +123,12 @@
|
|||||||
"@rollup/plugin-node-resolve": "^15.2.0",
|
"@rollup/plugin-node-resolve": "^15.2.0",
|
||||||
"@rollup/plugin-replace": "^5.0.2",
|
"@rollup/plugin-replace": "^5.0.2",
|
||||||
"@svgr/rollup": "^8.1.0",
|
"@svgr/rollup": "^8.1.0",
|
||||||
"@svgr/webpack": "^6.2.1",
|
"@svgr/webpack": "^8.1.0",
|
||||||
"@types/node": "^18.11.9",
|
"@types/node": "^18.11.9",
|
||||||
"@types/react": "^18.0.25",
|
"@types/react": "^18.0.25",
|
||||||
"@types/react-dom": "^18.0.8",
|
"@types/react-dom": "^18.0.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
||||||
"@typescript-eslint/parser": "^5.50.0",
|
"@typescript-eslint/parser": "^6.7.3",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"esbuild": "^0.17.17",
|
"esbuild": "^0.17.17",
|
||||||
"eslint": "^8.33.0",
|
"eslint": "^8.33.0",
|
||||||
@@ -138,8 +138,8 @@
|
|||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"extract-react-intl-messages": "^4.1.1",
|
"extract-react-intl-messages": "^4.1.1",
|
||||||
"husky": "^7.0.0",
|
"husky": "^8.0.3",
|
||||||
"lint-staged": "^11.0.0",
|
"lint-staged": "^14.0.1",
|
||||||
"postcss": "^8.4.21",
|
"postcss": "^8.4.21",
|
||||||
"postcss-flexbugs-fixes": "^5.0.2",
|
"postcss-flexbugs-fixes": "^5.0.2",
|
||||||
"postcss-import": "^15.1.0",
|
"postcss-import": "^15.1.0",
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
.navbar {
|
.navbar {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: max-content 1fr 1fr;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
background: var(--base75);
|
background: var(--base75);
|
||||||
@@ -9,17 +9,6 @@
|
|||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left,
|
|
||||||
.right {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right {
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@@ -35,29 +24,24 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
gap: 30px;
|
gap: 30px;
|
||||||
padding: 0 40px;
|
padding: 0 40px;
|
||||||
flex: 1;
|
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
max-height: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.links a {
|
.links a,
|
||||||
display: flex;
|
.links a:active,
|
||||||
align-items: center;
|
.links a:visited {
|
||||||
gap: 10px;
|
|
||||||
line-height: 60px;
|
|
||||||
color: var(--font-color200);
|
color: var(--font-color200);
|
||||||
|
line-height: 60px;
|
||||||
border-bottom: 2px solid transparent;
|
border-bottom: 2px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.links span {
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.links a:hover {
|
.links a:hover {
|
||||||
color: var(--font-color100);
|
color: var(--font-color100);
|
||||||
border-bottom: 2px solid var(--primary400);
|
border-bottom: 2px solid var(--primary400);
|
||||||
}
|
}
|
||||||
|
|
||||||
.links .selected {
|
.links a.selected {
|
||||||
color: var(--font-color100);
|
color: var(--font-color100);
|
||||||
border-bottom: 2px solid var(--primary400);
|
border-bottom: 2px solid var(--primary400);
|
||||||
}
|
}
|
||||||
@@ -68,7 +52,6 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
min-width: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile {
|
.mobile {
|
||||||
@@ -76,6 +59,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 768px) {
|
@media only screen and (max-width: 768px) {
|
||||||
|
.navbar {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
.links,
|
.links,
|
||||||
.actions {
|
.actions {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -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;
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
|
'use client';
|
||||||
import WebsiteSelect from 'components/input/WebsiteSelect';
|
import WebsiteSelect from 'components/input/WebsiteSelect';
|
||||||
import Page from 'components/layout/Page';
|
import Page from 'components/layout/Page';
|
||||||
import PageHeader from 'components/layout/PageHeader';
|
import PageHeader from 'components/layout/PageHeader';
|
||||||
import EventsChart from 'components/metrics/EventsChart';
|
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 useApi from 'components/hooks/useApi';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/navigation';
|
||||||
import Script from 'next/script';
|
import Script from 'next/script';
|
||||||
import { Button, Column, Row } from 'react-basics';
|
import { Button, Column, Row } from 'react-basics';
|
||||||
import styles from './TestConsole.module.css';
|
import styles from './TestConsole.module.css';
|
||||||
File renamed without changes.
@@ -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',
|
||||||
|
};
|
||||||
+12
-12
@@ -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 Link from 'next/link';
|
||||||
import Page from 'components/layout/Page';
|
|
||||||
import PageHeader from 'components/layout/PageHeader';
|
import PageHeader from 'components/layout/PageHeader';
|
||||||
import Pager from 'components/common/Pager';
|
import Pager from 'components/common/Pager';
|
||||||
import WebsiteChartList from 'components/pages/websites/WebsiteChartList';
|
import WebsiteChartList from '../websites/[id]/WebsiteChartList';
|
||||||
import DashboardSettingsButton from 'components/pages/dashboard/DashboardSettingsButton';
|
import DashboardSettingsButton from 'app/(app)/dashboard/DashboardSettingsButton';
|
||||||
import DashboardEdit from 'components/pages/dashboard/DashboardEdit';
|
import DashboardEdit from 'app/(app)/dashboard/DashboardEdit';
|
||||||
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
|
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
|
||||||
import useApi from 'components/hooks/useApi';
|
import useApi from 'components/hooks/useApi';
|
||||||
import useDashboard from 'store/dashboard';
|
import useDashboard from 'store/dashboard';
|
||||||
@@ -20,18 +20,18 @@ export function Dashboard() {
|
|||||||
const { get, useQuery } = useApi();
|
const { get, useQuery } = useApi();
|
||||||
const { page, handlePageChange } = useApiFilter();
|
const { page, handlePageChange } = useApiFilter();
|
||||||
const pageSize = 10;
|
const pageSize = 10;
|
||||||
const {
|
const { data: result, isLoading } = useQuery(['websites', page, pageSize], () =>
|
||||||
data: result,
|
|
||||||
isLoading,
|
|
||||||
error,
|
|
||||||
} = useQuery(['websites', page, pageSize], () =>
|
|
||||||
get('/websites', { includeTeams: 1, page, pageSize }),
|
get('/websites', { includeTeams: 1, page, pageSize }),
|
||||||
);
|
);
|
||||||
const { data, count } = result || {};
|
const { data, count } = result || {};
|
||||||
const hasData = data && data?.length !== 0;
|
const hasData = data && data?.length !== 0;
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <Loading size="lg" />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page loading={isLoading} error={error}>
|
<>
|
||||||
<PageHeader title={formatMessage(labels.dashboard)}>
|
<PageHeader title={formatMessage(labels.dashboard)}>
|
||||||
{!editing && hasData && <DashboardSettingsButton />}
|
{!editing && hasData && <DashboardSettingsButton />}
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
@@ -63,7 +63,7 @@ export function Dashboard() {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Page>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
+4
-8
@@ -1,3 +1,4 @@
|
|||||||
|
'use client';
|
||||||
import { useState, useMemo } from 'react';
|
import { useState, useMemo } from 'react';
|
||||||
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
|
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@@ -7,7 +8,6 @@ import useDashboard, { saveDashboard } from 'store/dashboard';
|
|||||||
import useMessages from 'components/hooks/useMessages';
|
import useMessages from 'components/hooks/useMessages';
|
||||||
import useApi from 'components/hooks/useApi';
|
import useApi from 'components/hooks/useApi';
|
||||||
import styles from './DashboardEdit.module.css';
|
import styles from './DashboardEdit.module.css';
|
||||||
import Page from 'components/layout/Page';
|
|
||||||
|
|
||||||
const dragId = 'dashboard-website-ordering';
|
const dragId = 'dashboard-website-ordering';
|
||||||
|
|
||||||
@@ -17,11 +17,7 @@ export function DashboardEdit() {
|
|||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const [order, setOrder] = useState(websiteOrder || []);
|
const [order, setOrder] = useState(websiteOrder || []);
|
||||||
const { get, useQuery } = useApi();
|
const { get, useQuery } = useApi();
|
||||||
const {
|
const { data: result } = useQuery(['websites'], () => get('/websites', { includeTeams: 1 }));
|
||||||
data: result,
|
|
||||||
isLoading,
|
|
||||||
error,
|
|
||||||
} = useQuery(['websites'], () => get('/websites', { includeTeams: 1 }));
|
|
||||||
const { data: websites } = result || {};
|
const { data: websites } = result || {};
|
||||||
|
|
||||||
const ordered = useMemo(() => {
|
const ordered = useMemo(() => {
|
||||||
@@ -59,7 +55,7 @@ export function DashboardEdit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page loading={isLoading} error={error}>
|
<>
|
||||||
<div className={styles.buttons}>
|
<div className={styles.buttons}>
|
||||||
<Button onClick={handleSave} variant="action" size="small">
|
<Button onClick={handleSave} variant="action" size="small">
|
||||||
{formatMessage(labels.save)}
|
{formatMessage(labels.save)}
|
||||||
@@ -105,7 +101,7 @@ export function DashboardEdit() {
|
|||||||
</Droppable>
|
</Droppable>
|
||||||
</DragDropContext>
|
</DragDropContext>
|
||||||
</div>
|
</div>
|
||||||
</Page>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,10 @@
|
|||||||
|
import Dashboard from 'app/(app)/dashboard/Dashboard';
|
||||||
|
import { Metadata } from 'next';
|
||||||
|
|
||||||
|
export default function DashboardPage() {
|
||||||
|
return <Dashboard />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: 'Dashboard | umami',
|
||||||
|
};
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
width: 100vw;
|
width: 100vw;
|
||||||
grid-column: 1;
|
grid-column: 1;
|
||||||
grid-row: 1 / 2;
|
grid-row: 1 / 2;
|
||||||
z-index: var(--z-index-popup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.body {
|
.body {
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import Shell from './Shell';
|
||||||
|
import NavBar from './NavBar';
|
||||||
|
import Page from 'components/layout/Page';
|
||||||
|
import styles from './layout.module.css';
|
||||||
|
|
||||||
|
export default function AppLayout({ children }) {
|
||||||
|
return (
|
||||||
|
<Shell>
|
||||||
|
<main className={styles.layout}>
|
||||||
|
<nav className={styles.nav}>
|
||||||
|
<NavBar />
|
||||||
|
</nav>
|
||||||
|
<section className={styles.body}>
|
||||||
|
<Page>{children}</Page>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
</Shell>
|
||||||
|
);
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
|
|||||||
|
'use client';
|
||||||
import { createContext } from 'react';
|
import { createContext } from 'react';
|
||||||
import Page from 'components/layout/Page';
|
|
||||||
import styles from './reports.module.css';
|
|
||||||
import { useReport } from 'components/hooks';
|
import { useReport } from 'components/hooks';
|
||||||
|
import styles from './Report.module.css';
|
||||||
|
|
||||||
export const ReportContext = createContext(null);
|
export const ReportContext = createContext(null);
|
||||||
|
|
||||||
@@ -10,9 +10,9 @@ export function Report({ reportId, defaultParameters, children, ...props }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ReportContext.Provider value={{ ...report }}>
|
<ReportContext.Provider value={{ ...report }}>
|
||||||
<Page {...props} className={styles.container}>
|
<div {...props} className={styles.container}>
|
||||||
{children}
|
{children}
|
||||||
</Page>
|
</div>
|
||||||
</ReportContext.Provider>
|
</ReportContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
import styles from './reports.module.css';
|
import styles from './Report.module.css';
|
||||||
|
|
||||||
export function ReportBody({ children }) {
|
export function ReportBody({ children }) {
|
||||||
return <div className={styles.body}>{children}</div>;
|
return <div className={styles.body}>{children}</div>;
|
||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/navigation';
|
||||||
import { Icon, LoadingButton, InlineEditField, useToasts } from 'react-basics';
|
import { Icon, LoadingButton, InlineEditField, useToasts } from 'react-basics';
|
||||||
import PageHeader from 'components/layout/PageHeader';
|
import PageHeader from 'components/layout/PageHeader';
|
||||||
import { useMessages, useApi } from 'components/hooks';
|
import { useMessages, useApi } from 'components/hooks';
|
||||||
import { ReportContext } from './Report';
|
import { ReportContext } from './Report';
|
||||||
import styles from './ReportHeader.module.css';
|
import styles from './ReportHeader.module.css';
|
||||||
import reportStyles from './reports.module.css';
|
import reportStyles from './Report.module.css';
|
||||||
|
|
||||||
export function ReportHeader({ icon }) {
|
export function ReportHeader({ icon }) {
|
||||||
const { report, updateReport } = useContext(ReportContext);
|
const { report, updateReport } = useContext(ReportContext);
|
||||||
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
import styles from './reports.module.css';
|
import styles from './Report.module.css';
|
||||||
|
|
||||||
export function ReportMenu({ children }) {
|
export function ReportMenu({ children }) {
|
||||||
return <div className={styles.menu}>{children}</div>;
|
return <div className={styles.menu}>{children}</div>;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
'use client';
|
||||||
|
import PageHeader from 'components/layout/PageHeader';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { Button, Icon, Icons, Text } from 'react-basics';
|
||||||
|
import { useMessages } from 'components/hooks';
|
||||||
|
|
||||||
|
export function ReportsHeader() {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageHeader title={formatMessage(labels.reports)}>
|
||||||
|
<Link href="/reports/create">
|
||||||
|
<Button variant="primary">
|
||||||
|
<Icon>
|
||||||
|
<Icons.Plus />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.createReport)}</Text>
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</PageHeader>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ReportsHeader;
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
'use client';
|
||||||
|
import { useApi } from 'components/hooks';
|
||||||
|
import ReportsTable from './ReportsTable';
|
||||||
|
import useFilterQuery from 'components/hooks/useFilterQuery';
|
||||||
|
import DataTable from 'components/common/DataTable';
|
||||||
|
|
||||||
|
function useReports() {
|
||||||
|
const { get, del, useMutation } = useApi();
|
||||||
|
const { mutate } = useMutation(reportId => del(`/reports/${reportId}`));
|
||||||
|
const reports = useFilterQuery(['reports'], params => get(`/reports`, params));
|
||||||
|
|
||||||
|
const deleteReport = id => {
|
||||||
|
mutate(id, {
|
||||||
|
onSuccess: () => {
|
||||||
|
reports.refetch();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return { reports, deleteReport };
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ReportsList() {
|
||||||
|
const { reports, deleteReport } = useReports();
|
||||||
|
|
||||||
|
const handleDelete = async (id, callback) => {
|
||||||
|
await deleteReport(id);
|
||||||
|
await reports.refetch();
|
||||||
|
callback?.();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DataTable {...reports.getProps()}>
|
||||||
|
{({ data }) => <ReportsTable data={data} showDomain={true} onDelete={handleDelete} />}
|
||||||
|
</DataTable>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import ConfirmDeleteForm from 'components/common/ConfirmDeleteForm';
|
||||||
|
import LinkButton from 'components/common/LinkButton';
|
||||||
|
import { useMessages } from 'components/hooks';
|
||||||
|
import useUser from 'components/hooks/useUser';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
GridColumn,
|
||||||
|
GridTable,
|
||||||
|
Icon,
|
||||||
|
Icons,
|
||||||
|
Modal,
|
||||||
|
ModalTrigger,
|
||||||
|
Text,
|
||||||
|
} from 'react-basics';
|
||||||
|
import { REPORT_TYPES } from 'lib/constants';
|
||||||
|
|
||||||
|
export function ReportsTable({ data = [], onDelete, showDomain }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { user } = useUser();
|
||||||
|
|
||||||
|
const handleConfirm = (id, callback) => {
|
||||||
|
onDelete?.(id, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<GridTable data={data}>
|
||||||
|
<GridColumn name="name" label={formatMessage(labels.name)} />
|
||||||
|
<GridColumn name="description" label={formatMessage(labels.description)} />
|
||||||
|
<GridColumn name="type" label={formatMessage(labels.type)}>
|
||||||
|
{row => {
|
||||||
|
return formatMessage(
|
||||||
|
labels[Object.keys(REPORT_TYPES).find(key => REPORT_TYPES[key] === row.type)],
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</GridColumn>
|
||||||
|
{showDomain && (
|
||||||
|
<GridColumn name="domain" label={formatMessage(labels.domain)}>
|
||||||
|
{row => row.website.domain}
|
||||||
|
</GridColumn>
|
||||||
|
)}
|
||||||
|
<GridColumn name="action" label="" alignment="end">
|
||||||
|
{row => {
|
||||||
|
const { id, name, userId, website } = row;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<LinkButton href={`/reports/${id}`}>{formatMessage(labels.view)}</LinkButton>
|
||||||
|
{(user.id === userId || user.id === website?.userId) && (
|
||||||
|
<ModalTrigger>
|
||||||
|
<Button>
|
||||||
|
<Icon>
|
||||||
|
<Icons.Trash />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.delete)}</Text>
|
||||||
|
</Button>
|
||||||
|
<Modal>
|
||||||
|
{close => (
|
||||||
|
<ConfirmDeleteForm
|
||||||
|
name={name}
|
||||||
|
onConfirm={handleConfirm.bind(null, id, close)}
|
||||||
|
onClose={close}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
</ModalTrigger>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</GridColumn>
|
||||||
|
</GridTable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ReportsTable;
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
'use client';
|
||||||
|
import FunnelReport from '../funnel/FunnelReport';
|
||||||
|
import EventDataReport from '../event-data/EventDataReport';
|
||||||
|
import InsightsReport from '../insights/InsightsReport';
|
||||||
|
import RetentionReport from '../retention/RetentionReport';
|
||||||
|
import { useApi } from 'components/hooks';
|
||||||
|
|
||||||
|
const reports = {
|
||||||
|
funnel: FunnelReport,
|
||||||
|
'event-data': EventDataReport,
|
||||||
|
insights: InsightsReport,
|
||||||
|
retention: RetentionReport,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ReportDetails({ reportId }) {
|
||||||
|
const { get, useQuery } = useApi();
|
||||||
|
const { data: report } = useQuery(['reports', reportId], () => get(`/reports/${reportId}`));
|
||||||
|
|
||||||
|
if (!report) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReportComponent = reports[report.type];
|
||||||
|
|
||||||
|
return <ReportComponent reportId={reportId} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import ReportDetails from './ReportDetails';
|
||||||
|
import { Metadata } from 'next';
|
||||||
|
|
||||||
|
export default function ReportDetailsPage({ params: { id } }) {
|
||||||
|
if (!id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <ReportDetails reportId={id} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: 'Reports | umami',
|
||||||
|
};
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
|
'use client';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Button, Icons, Text, Icon } from 'react-basics';
|
import { Button, Icons, Text, Icon } from 'react-basics';
|
||||||
import Page from 'components/layout/Page';
|
|
||||||
import PageHeader from 'components/layout/PageHeader';
|
import PageHeader from 'components/layout/PageHeader';
|
||||||
import Funnel from 'assets/funnel.svg';
|
import Funnel from 'assets/funnel.svg';
|
||||||
import Lightbulb from 'assets/lightbulb.svg';
|
import Lightbulb from 'assets/lightbulb.svg';
|
||||||
@@ -57,7 +57,7 @@ export function ReportTemplates({ showHeader = true }) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<>
|
||||||
{showHeader && <PageHeader title={formatMessage(labels.reports)} />}
|
{showHeader && <PageHeader title={formatMessage(labels.reports)} />}
|
||||||
<div className={styles.reports}>
|
<div className={styles.reports}>
|
||||||
{reports.map(({ title, description, url, icon }) => {
|
{reports.map(({ title, description, url, icon }) => {
|
||||||
@@ -66,7 +66,7 @@ export function ReportTemplates({ showHeader = true }) {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</Page>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
File renamed without changes.
@@ -0,0 +1,10 @@
|
|||||||
|
import ReportTemplates from './ReportTemplates';
|
||||||
|
import { Metadata } from 'next';
|
||||||
|
|
||||||
|
export default function ReportsCreatePage() {
|
||||||
|
return <ReportTemplates />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: 'Create Report | umami',
|
||||||
|
};
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { useContext, useRef } from 'react';
|
import { useContext, useRef } from 'react';
|
||||||
import { useApi, useMessages } from 'components/hooks';
|
import { useApi, useMessages } from 'components/hooks';
|
||||||
import { Form, FormRow, FormButtons, SubmitButton, PopupTrigger, Icon, Popup } from 'react-basics';
|
import { Form, FormRow, FormButtons, SubmitButton, PopupTrigger, Icon, Popup } from 'react-basics';
|
||||||
import { ReportContext } from 'components/pages/reports/Report';
|
import { ReportContext } from '../Report';
|
||||||
import Empty from 'components/common/Empty';
|
import Empty from 'components/common/Empty';
|
||||||
import { DATA_TYPES, REPORT_PARAMETERS } from 'lib/constants';
|
import { DATA_TYPES, REPORT_PARAMETERS } from 'lib/constants';
|
||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -13,7 +13,7 @@ import {
|
|||||||
} from 'react-basics';
|
} from 'react-basics';
|
||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
import UrlAddForm from './UrlAddForm';
|
import UrlAddForm from './UrlAddForm';
|
||||||
import { ReportContext } from 'components/pages/reports/Report';
|
import { ReportContext } from '../Report';
|
||||||
import BaseParameters from '../BaseParameters';
|
import BaseParameters from '../BaseParameters';
|
||||||
import ParameterList from '../ParameterList';
|
import ParameterList from '../ParameterList';
|
||||||
import PopupForm from '../PopupForm';
|
import PopupForm from '../PopupForm';
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
'use client';
|
||||||
import FunnelChart from './FunnelChart';
|
import FunnelChart from './FunnelChart';
|
||||||
import FunnelTable from './FunnelTable';
|
import FunnelTable from './FunnelTable';
|
||||||
import FunnelParameters from './FunnelParameters';
|
import FunnelParameters from './FunnelParameters';
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,10 @@
|
|||||||
|
import FunnelReport from './FunnelReport';
|
||||||
|
import { Metadata } from 'next';
|
||||||
|
|
||||||
|
export default function FunnelReportPage() {
|
||||||
|
return <FunnelReport reportId={null} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: 'Funnel Report | umami',
|
||||||
|
};
|
||||||
+1
-1
@@ -10,7 +10,7 @@ import {
|
|||||||
Popup,
|
Popup,
|
||||||
TooltipPopup,
|
TooltipPopup,
|
||||||
} from 'react-basics';
|
} from 'react-basics';
|
||||||
import { ReportContext } from 'components/pages/reports/Report';
|
import { ReportContext } from '../Report';
|
||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
import BaseParameters from '../BaseParameters';
|
import BaseParameters from '../BaseParameters';
|
||||||
import ParameterList from '../ParameterList';
|
import ParameterList from '../ParameterList';
|
||||||
File renamed without changes.
+1
@@ -1,3 +1,4 @@
|
|||||||
|
'use client';
|
||||||
import Report from '../Report';
|
import Report from '../Report';
|
||||||
import ReportHeader from '../ReportHeader';
|
import ReportHeader from '../ReportHeader';
|
||||||
import ReportMenu from '../ReportMenu';
|
import ReportMenu from '../ReportMenu';
|
||||||
File renamed without changes.
@@ -0,0 +1,10 @@
|
|||||||
|
import InsightsReport from './InsightsReport';
|
||||||
|
import { Metadata } from 'next';
|
||||||
|
|
||||||
|
export default function InsightsReportPage() {
|
||||||
|
return <InsightsReport reportId={null} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: 'Insights Report | umami',
|
||||||
|
};
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import ReportsHeader from './ReportsHeader';
|
||||||
|
import ReportsList from './ReportsList';
|
||||||
|
|
||||||
|
export default function ReportsPage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ReportsHeader />
|
||||||
|
<ReportsList />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export const metadata = {
|
||||||
|
title: 'Reports | umami',
|
||||||
|
};
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { useContext, useRef } from 'react';
|
import { useContext, useRef } from 'react';
|
||||||
import { useMessages } from 'components/hooks';
|
import { useMessages } from 'components/hooks';
|
||||||
import { Form, FormButtons, FormRow, SubmitButton } from 'react-basics';
|
import { Form, FormButtons, FormRow, SubmitButton } from 'react-basics';
|
||||||
import { ReportContext } from 'components/pages/reports/Report';
|
import { ReportContext } from '../Report';
|
||||||
import { MonthSelect } from 'components/input/MonthSelect';
|
import { MonthSelect } from 'components/input/MonthSelect';
|
||||||
import BaseParameters from '../BaseParameters';
|
import BaseParameters from '../BaseParameters';
|
||||||
import { parseDateRange } from 'lib/date';
|
import { parseDateRange } from 'lib/date';
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
'use client';
|
||||||
import RetentionTable from './RetentionTable';
|
import RetentionTable from './RetentionTable';
|
||||||
import RetentionParameters from './RetentionParameters';
|
import RetentionParameters from './RetentionParameters';
|
||||||
import Report from '../Report';
|
import Report from '../Report';
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,9 @@
|
|||||||
|
import RetentionReport from './RetentionReport';
|
||||||
|
|
||||||
|
export default function RetentionReportPage() {
|
||||||
|
return <RetentionReport reportId={null} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const metadata = {
|
||||||
|
title: 'Create Report | umami',
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Menu, Item } from 'react-basics';
|
import { Menu, Item } from 'react-basics';
|
||||||
import { useRouter } from 'next/router';
|
import { usePathname } from 'next/navigation';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import styles from './SideNav.module.css';
|
import styles from './SideNav.module.css';
|
||||||
|
|
||||||
@@ -11,13 +11,13 @@ export function SideNav({
|
|||||||
scroll = false,
|
scroll = false,
|
||||||
onSelect = () => {},
|
onSelect = () => {},
|
||||||
}) {
|
}) {
|
||||||
const { asPath } = useRouter();
|
const pathname = usePathname();
|
||||||
return (
|
return (
|
||||||
<Menu items={items} selectedKey={selectedKey} className={styles.menu} onSelect={onSelect}>
|
<Menu items={items} selectedKey={selectedKey} className={styles.menu} onSelect={onSelect}>
|
||||||
{({ key, label, url }) => (
|
{({ key, label, url }) => (
|
||||||
<Item
|
<Item
|
||||||
key={key}
|
key={key}
|
||||||
className={classNames(styles.item, { [styles.selected]: asPath.startsWith(url) })}
|
className={classNames(styles.item, { [styles.selected]: pathname.startsWith(url) })}
|
||||||
>
|
>
|
||||||
<Link href={url} shallow={shallow} scroll={scroll}>
|
<Link href={url} shallow={shallow} scroll={scroll}>
|
||||||
{label}
|
{label}
|
||||||
File renamed without changes.
+9
-2
@@ -1,11 +1,18 @@
|
|||||||
|
.layout {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: max-content 1fr;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.menu {
|
.menu {
|
||||||
display: flex;
|
width: 240px;
|
||||||
flex-direction: column;
|
|
||||||
padding-top: 40px;
|
padding-top: 40px;
|
||||||
padding-right: 20px;
|
padding-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
min-height: 50vh;
|
min-height: 50vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import { Row, Column } from 'react-basics';
|
'use client';
|
||||||
import { useRouter } from 'next/router';
|
import { usePathname } from 'next/navigation';
|
||||||
import SideNav from './SideNav';
|
|
||||||
import useUser from 'components/hooks/useUser';
|
import useUser from 'components/hooks/useUser';
|
||||||
import useMessages from 'components/hooks/useMessages';
|
import useMessages from 'components/hooks/useMessages';
|
||||||
import styles from './SettingsLayout.module.css';
|
import SideNav from './SideNav';
|
||||||
|
import styles from './layout.module.css';
|
||||||
|
|
||||||
export function SettingsLayout({ children }) {
|
export default function SettingsLayout({ children }) {
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const { pathname } = useRouter();
|
const pathname = usePathname();
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const cloudMode = Boolean(process.env.cloudMode);
|
const cloudMode = Boolean(process.env.cloudMode);
|
||||||
|
|
||||||
@@ -21,17 +21,13 @@ export function SettingsLayout({ children }) {
|
|||||||
const getKey = () => items.find(({ url }) => pathname === url)?.key;
|
const getKey = () => items.find(({ url }) => pathname === url)?.key;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row>
|
<div className={styles.layout}>
|
||||||
{!cloudMode && (
|
{!cloudMode && (
|
||||||
<Column className={styles.menu} defaultSize={12} md={4} lg={3} xl={2}>
|
<div className={styles.menu}>
|
||||||
<SideNav items={items} shallow={true} selectedKey={getKey()} />
|
<SideNav items={items} shallow={true} selectedKey={getKey()} />
|
||||||
</Column>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Column className={styles.content} defaultSize={12} md={8} lg={9} xl={10}>
|
<div className={styles.content}>{children}</div>
|
||||||
{children}
|
</div>
|
||||||
</Column>
|
|
||||||
</Row>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SettingsLayout;
|
|
||||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import { Button, Icon, Text, useToasts, ModalTrigger, Modal } from 'react-basics';
|
import { Button, Icon, Text, useToasts, ModalTrigger, Modal } from 'react-basics';
|
||||||
import PasswordEditForm from 'components/pages/settings/profile/PasswordEditForm';
|
import PasswordEditForm from 'app/(app)/settings/profile/PasswordEditForm';
|
||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
import useMessages from 'components/hooks/useMessages';
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
|
||||||
File renamed without changes.
@@ -0,0 +1,11 @@
|
|||||||
|
'use client';
|
||||||
|
import PageHeader from 'components/layout/PageHeader';
|
||||||
|
import { useMessages } from 'components/hooks';
|
||||||
|
|
||||||
|
export function ProfileHeader() {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
return <PageHeader title={formatMessage(labels.profile)}></PageHeader>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ProfileHeader;
|
||||||
+7
-6
@@ -1,14 +1,15 @@
|
|||||||
|
'use client';
|
||||||
import { Form, FormRow } from 'react-basics';
|
import { Form, FormRow } from 'react-basics';
|
||||||
import TimezoneSetting from 'components/pages/settings/profile/TimezoneSetting';
|
import TimezoneSetting from 'app/(app)/settings/profile/TimezoneSetting';
|
||||||
import DateRangeSetting from 'components/pages/settings/profile/DateRangeSetting';
|
import DateRangeSetting from 'app/(app)/settings/profile/DateRangeSetting';
|
||||||
import LanguageSetting from 'components/pages/settings/profile/LanguageSetting';
|
import LanguageSetting from 'app/(app)/settings/profile/LanguageSetting';
|
||||||
import ThemeSetting from 'components/pages/settings/profile/ThemeSetting';
|
import ThemeSetting from 'app/(app)/settings/profile/ThemeSetting';
|
||||||
import PasswordChangeButton from './PasswordChangeButton';
|
import PasswordChangeButton from './PasswordChangeButton';
|
||||||
import useUser from 'components/hooks/useUser';
|
import useUser from 'components/hooks/useUser';
|
||||||
import useMessages from 'components/hooks/useMessages';
|
import useMessages from 'components/hooks/useMessages';
|
||||||
import { ROLES } from 'lib/constants';
|
import { ROLES } from 'lib/constants';
|
||||||
|
|
||||||
export function ProfileDetails() {
|
export function ProfileSettings() {
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const cloudMode = Boolean(process.env.cloudMode);
|
const cloudMode = Boolean(process.env.cloudMode);
|
||||||
@@ -58,4 +59,4 @@ export function ProfileDetails() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ProfileDetails;
|
export default ProfileSettings;
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,11 @@
|
|||||||
|
import ProfileHeader from './ProfileHeader';
|
||||||
|
import ProfileSettings from './ProfileSettings';
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ProfileHeader />
|
||||||
|
<ProfileSettings />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -0,0 +1,25 @@
|
|||||||
|
import { Button, Icon, Icons, Modal, ModalTrigger, Text } from 'react-basics';
|
||||||
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
import TeamDeleteForm from './TeamDeleteForm';
|
||||||
|
|
||||||
|
export function TeamDeleteButton({ teamId, teamName, onDelete }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalTrigger>
|
||||||
|
<Button>
|
||||||
|
<Icon>
|
||||||
|
<Icons.Trash />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.delete)}</Text>
|
||||||
|
</Button>
|
||||||
|
<Modal title={formatMessage(labels.deleteTeam)}>
|
||||||
|
{close => (
|
||||||
|
<TeamDeleteForm teamId={teamId} teamName={teamName} onSave={onDelete} onClose={close} />
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
</ModalTrigger>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TeamDeleteButton;
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,35 @@
|
|||||||
|
import { Button, Icon, Icons, Modal, ModalTrigger, Text } from 'react-basics';
|
||||||
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
import useLocale from 'components/hooks/useLocale';
|
||||||
|
import useUser from 'components/hooks/useUser';
|
||||||
|
import TeamDeleteForm from './TeamLeaveForm';
|
||||||
|
|
||||||
|
export function TeamLeaveButton({ teamId, teamName, onLeave }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { dir } = useLocale();
|
||||||
|
const { user } = useUser();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalTrigger>
|
||||||
|
<Button>
|
||||||
|
<Icon rotate={dir === 'rtl' ? 180 : 0}>
|
||||||
|
<Icons.ArrowRight />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.leave)}</Text>
|
||||||
|
</Button>
|
||||||
|
<Modal title={formatMessage(labels.leaveTeam)}>
|
||||||
|
{close => (
|
||||||
|
<TeamDeleteForm
|
||||||
|
teamId={teamId}
|
||||||
|
userId={user.id}
|
||||||
|
teamName={teamName}
|
||||||
|
onSave={onLeave}
|
||||||
|
onClose={close}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
</ModalTrigger>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TeamLeaveButton;
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,24 @@
|
|||||||
|
import { Button, Icon, Modal, ModalTrigger, Text } from 'react-basics';
|
||||||
|
import Icons from 'components/icons';
|
||||||
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
import TeamAddForm from './TeamAddForm';
|
||||||
|
|
||||||
|
export function TeamsAddButton({ onAdd }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalTrigger>
|
||||||
|
<Button variant="primary">
|
||||||
|
<Icon>
|
||||||
|
<Icons.Plus />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.createTeam)}</Text>
|
||||||
|
</Button>
|
||||||
|
<Modal title={formatMessage(labels.createTeam)}>
|
||||||
|
{close => <TeamAddForm onSave={onAdd} onClose={close} />}
|
||||||
|
</Modal>
|
||||||
|
</ModalTrigger>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TeamsAddButton;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
'use client';
|
||||||
|
import { Flexbox } from 'react-basics';
|
||||||
|
import PageHeader from 'components/layout/PageHeader';
|
||||||
|
import { ROLES } from 'lib/constants';
|
||||||
|
import useUser from 'components/hooks/useUser';
|
||||||
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
import TeamsJoinButton from './TeamsJoinButton';
|
||||||
|
import TeamsAddButton from './TeamsAddButton';
|
||||||
|
|
||||||
|
export function TeamsHeader() {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { user } = useUser();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageHeader title={formatMessage(labels.teams)}>
|
||||||
|
<Flexbox gap={10}>
|
||||||
|
<TeamsJoinButton />
|
||||||
|
{user.role !== ROLES.viewOnly && <TeamsAddButton />}
|
||||||
|
</Flexbox>
|
||||||
|
</PageHeader>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TeamsHeader;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { Button, Icon, Modal, ModalTrigger, Text, useToasts } from 'react-basics';
|
||||||
|
import Icons from 'components/icons';
|
||||||
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
import TeamJoinForm from './TeamJoinForm';
|
||||||
|
|
||||||
|
export function TeamsJoinButton() {
|
||||||
|
const { formatMessage, labels, messages } = useMessages();
|
||||||
|
const { showToast } = useToasts();
|
||||||
|
|
||||||
|
const handleJoin = () => {
|
||||||
|
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalTrigger>
|
||||||
|
<Button variant="secondary">
|
||||||
|
<Icon>
|
||||||
|
<Icons.AddUser />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.joinTeam)}</Text>
|
||||||
|
</Button>
|
||||||
|
<Modal title={formatMessage(labels.joinTeam)}>
|
||||||
|
{close => <TeamJoinForm onSave={handleJoin} onClose={close} />}
|
||||||
|
</Modal>
|
||||||
|
</ModalTrigger>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TeamsJoinButton;
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
'use client';
|
||||||
|
import DataTable from 'components/common/DataTable';
|
||||||
|
import TeamsTable from 'app/(app)/settings/teams/TeamsTable';
|
||||||
|
import useApi from 'components/hooks/useApi';
|
||||||
|
import useFilterQuery from 'components/hooks/useFilterQuery';
|
||||||
|
|
||||||
|
export function TeamsList() {
|
||||||
|
const { get } = useApi();
|
||||||
|
const filterQuery = useFilterQuery(['teams'], params => {
|
||||||
|
return get(`/teams`, {
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const { getProps } = filterQuery;
|
||||||
|
|
||||||
|
return <DataTable {...getProps()}>{({ data }) => <TeamsTable data={data} />}</DataTable>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TeamsList;
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
'use client';
|
||||||
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
import useUser from 'components/hooks/useUser';
|
||||||
|
import { ROLES } from 'lib/constants';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { Button, GridColumn, GridTable, Icon, Icons, Text } from 'react-basics';
|
||||||
|
import TeamDeleteButton from './TeamDeleteButton';
|
||||||
|
import TeamLeaveButton from './TeamLeaveButton';
|
||||||
|
|
||||||
|
export function TeamsTable({ data = [] }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { user } = useUser();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<GridTable data={data}>
|
||||||
|
<GridColumn name="name" label={formatMessage(labels.name)} />
|
||||||
|
<GridColumn name="owner" label={formatMessage(labels.owner)}>
|
||||||
|
{row => row.teamUser.find(({ role }) => role === ROLES.teamOwner)?.user?.username}
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn name="action" label=" " alignment="end">
|
||||||
|
{row => {
|
||||||
|
const { id, name, teamUser } = row;
|
||||||
|
const owner = teamUser.find(({ role }) => role === ROLES.teamOwner);
|
||||||
|
const showDelete = user.id === owner?.userId;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Link href={`/settings/teams/${id}`}>
|
||||||
|
<Button>
|
||||||
|
<Icon>
|
||||||
|
<Icons.Edit />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.view)}</Text>
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
{showDelete && <TeamDeleteButton teamId={id} teamName={name} />}
|
||||||
|
{!showDelete && <TeamLeaveButton teamId={id} teamName={name} />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</GridColumn>
|
||||||
|
</GridTable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TeamsTable;
|
||||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import useApi from 'components/hooks/useApi';
|
import useApi from 'components/hooks/useApi';
|
||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import { Button, Dropdown, Form, FormButtons, FormRow, Item, SubmitButton } from 'react-basics';
|
import { Button, Dropdown, Form, FormButtons, FormRow, Item, SubmitButton } from 'react-basics';
|
||||||
import WebsiteTags from './WebsiteTags';
|
import WebsiteTags from '../WebsiteTags';
|
||||||
import useMessages from 'components/hooks/useMessages';
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
|
||||||
export function TeamAddWebsiteForm({ teamId, onSave, onClose }) {
|
export function TeamAddWebsiteForm({ teamId, onSave, onClose }) {
|
||||||
File renamed without changes.
File renamed without changes.
Loaded 100 of 325 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user