mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 06:07:17 +01:00
Merge branch 'dev' into jajaja
This commit is contained in:
commit
b331da193f
27 changed files with 217 additions and 50 deletions
|
|
@ -41,7 +41,7 @@ export function ReportDeleteButton({
|
|||
{({ close }) => (
|
||||
<ConfirmationForm
|
||||
message={formatMessage(messages.confirmDelete, {
|
||||
target: <b key="report-name">{reportName}</b>,
|
||||
target: <b key={messages.confirmDelete.id}>{reportName}</b>,
|
||||
})}
|
||||
isLoading={isPending}
|
||||
error={error}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ export function TeamLeaveForm({
|
|||
return (
|
||||
<ConfirmationForm
|
||||
buttonLabel={formatMessage(labels.leave)}
|
||||
message={formatMessage(messages.confirmLeave, { target: <b>{teamName}</b> })}
|
||||
message={formatMessage(messages.confirmLeave, {
|
||||
target: <b key={messages.confirmLeave.id}>{teamName}</b>,
|
||||
})}
|
||||
onConfirm={handleConfirm}
|
||||
onClose={onClose}
|
||||
isLoading={isPending}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export function UserAddButton({ onSave }: { onSave?: () => void }) {
|
|||
|
||||
return (
|
||||
<DialogTrigger>
|
||||
<Button variant="primary">
|
||||
<Button variant="primary" data-test="button-create-user">
|
||||
<Icon>
|
||||
<Icons.Plus />
|
||||
</Icon>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
} from '@umami/react-zen';
|
||||
import { useApi, useMessages } from '@/components/hooks';
|
||||
import { ROLES } from '@/lib/constants';
|
||||
import { messages } from '@/components/messages';
|
||||
|
||||
export function UserAddForm({ onSave, onClose }) {
|
||||
const { post, useMutation } = useApi();
|
||||
|
|
@ -35,14 +36,14 @@ export function UserAddForm({ onSave, onClose }) {
|
|||
name="username"
|
||||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
<TextField autoComplete="new-username" />
|
||||
<TextField autoComplete="new-username" data-test="input-username" />
|
||||
</FormField>
|
||||
<FormField
|
||||
label={formatMessage(labels.password)}
|
||||
name="password"
|
||||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
<PasswordField autoComplete="new-password" />
|
||||
<PasswordField autoComplete="new-password" data-test="input-password" />
|
||||
</FormField>
|
||||
<FormField
|
||||
label={formatMessage(labels.role)}
|
||||
|
|
@ -50,13 +51,13 @@ export function UserAddForm({ onSave, onClose }) {
|
|||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
<Select>
|
||||
<ListItem id={ROLES.viewOnly}>{formatMessage(labels.viewOnly)}</ListItem>
|
||||
<ListItem id={ROLES.user}>{formatMessage(labels.user)}</ListItem>
|
||||
<ListItem id={ROLES.admin}>{formatMessage(labels.admin)}</ListItem>
|
||||
<ListItem id={ROLES.viewOnly} data-test="dropdown-item-viewOnly">{formatMessage(labels.viewOnly)}</ListItem>
|
||||
<ListItem id={ROLES.user} data-test="dropdown-item-user">{formatMessage(labels.user)}</ListItem>
|
||||
<ListItem id={ROLES.admin} data-test="dropdown-item-admin">{formatMessage(labels.admin)}</ListItem>
|
||||
</Select>
|
||||
</FormField>
|
||||
<FormButtons>
|
||||
<FormSubmitButton variant="primary" disabled={false}>
|
||||
<FormSubmitButton variant="primary" data-test="button-submit" isDisabled={false}>
|
||||
{formatMessage(labels.save)}
|
||||
</FormSubmitButton>
|
||||
<Button isDisabled={isPending} onPress={onClose}>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export function UserDeleteButton({
|
|||
|
||||
return (
|
||||
<DialogTrigger>
|
||||
<Button isDisabled={userId === user?.id}>
|
||||
<Button isDisabled={userId === user?.id} data-test="button-delete">
|
||||
<Icon size="sm">
|
||||
<Icons.Trash />
|
||||
</Icon>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ export function UserDeleteForm({ userId, username, onSave, onClose }) {
|
|||
|
||||
return (
|
||||
<ConfirmationForm
|
||||
message={formatMessage(messages.confirmDelete, { target: <b>{username}</b> })}
|
||||
message={formatMessage(messages.confirmDelete, {
|
||||
target: <b key={messages.confirmDelete.id}>{username}</b>,
|
||||
})}
|
||||
onConfirm={handleConfirm}
|
||||
onClose={onClose}
|
||||
buttonLabel={formatMessage(labels.delete)}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import Link from 'next/link';
|
|||
import { formatDistance } from 'date-fns';
|
||||
import { ROLES } from '@/lib/constants';
|
||||
import { useMessages, useLocale } from '@/components/hooks';
|
||||
import { UserDeleteButton } from './UserDeleteButton';
|
||||
import UserDeleteButton from './UserDeleteButton';
|
||||
import LinkButton from '@/components/common/LinkButton';
|
||||
|
||||
export function UsersTable({
|
||||
data = [],
|
||||
|
|
@ -44,7 +45,7 @@ export function UsersTable({
|
|||
<Row gap="3">
|
||||
<UserDeleteButton userId={id} username={username} />
|
||||
<Button asChild>
|
||||
<Link href={`/settings/users/${id}`}>
|
||||
<Link href={`/settings/users/${id}`} data-test="link-button-edit">
|
||||
<Icon>
|
||||
<Icons.Edit />
|
||||
</Icon>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export function UserEditForm({ userId, onSave }: { userId: string; onSave?: () =
|
|||
return (
|
||||
<Form onSubmit={handleSubmit} error={getMessage(error)} values={user} style={{ width: 300 }}>
|
||||
<FormField name="username" label={formatMessage(labels.username)}>
|
||||
<TextField />
|
||||
<TextField data-test="input-username" />
|
||||
</FormField>
|
||||
<FormField
|
||||
name="password"
|
||||
|
|
@ -56,7 +56,7 @@ export function UserEditForm({ userId, onSave }: { userId: string; onSave?: () =
|
|||
minLength: { value: 8, message: formatMessage(messages.minPasswordLength, { n: 8 }) },
|
||||
}}
|
||||
>
|
||||
<PasswordField autoComplete="new-password" />
|
||||
<PasswordField autoComplete="new-password" data-test="input-password" />
|
||||
</FormField>
|
||||
|
||||
{user.id !== login.id && (
|
||||
|
|
@ -66,14 +66,14 @@ export function UserEditForm({ userId, onSave }: { userId: string; onSave?: () =
|
|||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
<Select defaultSelectedKey={user.role}>
|
||||
<ListItem id={ROLES.viewOnly}>{formatMessage(labels.viewOnly)}</ListItem>
|
||||
<ListItem id={ROLES.user}>{formatMessage(labels.user)}</ListItem>
|
||||
<ListItem id={ROLES.admin}>{formatMessage(labels.admin)}</ListItem>
|
||||
<ListItem id={ROLES.viewOnly} data-test="dropdown-item-viewOnly">{formatMessage(labels.viewOnly)}</ListItem>
|
||||
<ListItem id={ROLES.user} data-test="dropdown-item-user">{formatMessage(labels.user)}</ListItem>
|
||||
<ListItem id={ROLES.admin} data-test="dropdown-item-admin">{formatMessage(labels.admin)}</ListItem>
|
||||
</Select>
|
||||
</FormField>
|
||||
)}
|
||||
<FormButtons>
|
||||
<FormSubmitButton variant="primary">{formatMessage(labels.save)}</FormSubmitButton>
|
||||
<FormSubmitButton data-test="button-submit" variant="primary">{formatMessage(labels.save)}</FormSubmitButton>
|
||||
</FormButtons>
|
||||
</Form>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ export function TeamMemberRemoveButton({
|
|||
{({ close }) => (
|
||||
<ConfirmationForm
|
||||
message={formatMessage(messages.confirmRemove, {
|
||||
target: <b key="username">{userName}</b>,
|
||||
target: <b key={messages.confirmRemove.id}>{userName}</b>,
|
||||
})}
|
||||
isLoading={isPending}
|
||||
error={error}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ export async function POST(request: Request) {
|
|||
const schema = z.object({
|
||||
...reportParms,
|
||||
steps: z.coerce.number().min(3).max(7),
|
||||
startStep: z.string(),
|
||||
endStep: z.string(),
|
||||
startStep: z.string().optional(),
|
||||
endStep: z.string().optional(),
|
||||
});
|
||||
|
||||
const { auth, body, error } = await parseRequest(request, schema);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { createToken, parseToken } from '@/lib/jwt';
|
|||
import { secret, uuid, hash } from '@/lib/crypto';
|
||||
import { COLLECTION_TYPE } from '@/lib/constants';
|
||||
import { anyObjectParam, urlOrPathParam } from '@/lib/schema';
|
||||
import { safeDecodeURI, safeDecodeURIComponent } from '@/lib/url';
|
||||
import { createSession, saveEvent, saveSessionData } from '@/queries';
|
||||
|
||||
const schema = z.object({
|
||||
|
|
@ -168,12 +169,12 @@ export async function POST(request: Request) {
|
|||
websiteId,
|
||||
sessionId,
|
||||
visitId,
|
||||
urlPath,
|
||||
urlPath: safeDecodeURI(urlPath),
|
||||
urlQuery,
|
||||
referrerPath,
|
||||
referrerPath: safeDecodeURI(referrerPath),
|
||||
referrerQuery,
|
||||
referrerDomain,
|
||||
pageTitle: title,
|
||||
pageTitle: safeDecodeURIComponent(title),
|
||||
eventName: name,
|
||||
eventData: data,
|
||||
hostname: hostname || urlDomain,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export function ConfirmationForm({
|
|||
<Row marginY="4">{message}</Row>
|
||||
<FormButtons>
|
||||
<Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
|
||||
<FormSubmitButton isLoading={isLoading} variant={buttonVariant}>
|
||||
<FormSubmitButton data-test="button-confirm" isLoading={isLoading} variant={buttonVariant}>
|
||||
{buttonLabel || formatMessage(labels.ok)}
|
||||
</FormSubmitButton>
|
||||
</FormButtons>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export function TypeConfirmationForm({
|
|||
<Form onSubmit={onConfirm} error={error}>
|
||||
<p>
|
||||
{formatMessage(messages.actionConfirmation, {
|
||||
confirmation: <b key="value">{confirmationValue}</b>,
|
||||
confirmation: <b key={messages.actionConfirmation.id}>{confirmationValue}</b>,
|
||||
})}
|
||||
</p>
|
||||
<FormField
|
||||
|
|
|
|||
|
|
@ -69,11 +69,10 @@ export function ReferrersTable({ allowFilter, ...props }: ReferrersTableProps) {
|
|||
if (!groups[domain]) {
|
||||
groups[domain] = 0;
|
||||
}
|
||||
groups[domain] += y;
|
||||
} else {
|
||||
groups._other += y;
|
||||
groups[domain] += +y;
|
||||
}
|
||||
}
|
||||
groups._other += +y;
|
||||
}
|
||||
|
||||
return Object.keys(groups)
|
||||
|
|
|
|||
|
|
@ -397,6 +397,14 @@ export const PAID_AD_PARAMS = [
|
|||
'epik=',
|
||||
'ttclid=',
|
||||
'scid=',
|
||||
'aid=',
|
||||
'pc_id=',
|
||||
'ad_id=',
|
||||
'rdt_cid=',
|
||||
'ob_click_id=',
|
||||
'utm_medium=cpc',
|
||||
'utm_medium=paid',
|
||||
'utm_medium=paid_social',
|
||||
];
|
||||
|
||||
export const GROUPED_DOMAINS = [
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ export async function getClientInfo(request: Request, payload: Record<string, an
|
|||
const userAgent = payload?.userAgent || request.headers.get('user-agent');
|
||||
const ip = payload?.ip || getIpAddress(request.headers);
|
||||
const location = await getLocation(ip, request.headers, !!payload?.ip);
|
||||
const country = payload?.userAgent || location?.country;
|
||||
const country = location?.country;
|
||||
const subdivision1 = location?.subdivision1;
|
||||
const subdivision2 = location?.subdivision2;
|
||||
const city = location?.city;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ZodSchema } from 'zod';
|
||||
import { z, ZodSchema } from 'zod';
|
||||
import { FILTER_COLUMNS } from '@/lib/constants';
|
||||
import { badRequest, unauthorized } from '@/lib/response';
|
||||
import { getAllowedUnits, getMinimumUnit } from '@/lib/date';
|
||||
|
|
@ -24,12 +24,21 @@ export async function parseRequest(
|
|||
let error: () => void | undefined;
|
||||
let auth = null;
|
||||
|
||||
const getErrorMessages = (error: z.ZodError) => {
|
||||
return Object.entries(error.format())
|
||||
.map(([key, value]) => {
|
||||
const messages = (value as any)._errors;
|
||||
return messages ? `${key}: ${messages.join(', ')}` : null;
|
||||
})
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
if (schema) {
|
||||
const isGet = request.method === 'GET';
|
||||
const result = schema.safeParse(isGet ? query : body);
|
||||
|
||||
if (!result.success) {
|
||||
error = () => badRequest(result.error);
|
||||
error = () => badRequest(getErrorMessages(result.error));
|
||||
} else if (isGet) {
|
||||
query = result.data;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue