mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Updated edit permissions on settings components.
This commit is contained in:
parent
ffc8f6faae
commit
7effa16f00
15 changed files with 128 additions and 148 deletions
48
pnpm-lock.yaml
generated
48
pnpm-lock.yaml
generated
|
|
@ -364,6 +364,45 @@ importers:
|
||||||
specifier: ^5.9.2
|
specifier: ^5.9.2
|
||||||
version: 5.9.2
|
version: 5.9.2
|
||||||
|
|
||||||
|
dist:
|
||||||
|
dependencies:
|
||||||
|
chart.js:
|
||||||
|
specifier: ^4.5.0
|
||||||
|
version: 4.5.0
|
||||||
|
chartjs-adapter-date-fns:
|
||||||
|
specifier: ^3.0.0
|
||||||
|
version: 3.0.0(chart.js@4.5.0)(date-fns@2.30.0)
|
||||||
|
colord:
|
||||||
|
specifier: ^2.9.2
|
||||||
|
version: 2.9.3
|
||||||
|
jsonwebtoken:
|
||||||
|
specifier: ^9.0.2
|
||||||
|
version: 9.0.2
|
||||||
|
lucide-react:
|
||||||
|
specifier: ^0.542.0
|
||||||
|
version: 0.542.0(react@19.1.1)
|
||||||
|
pure-rand:
|
||||||
|
specifier: ^7.0.1
|
||||||
|
version: 7.0.1
|
||||||
|
react-simple-maps:
|
||||||
|
specifier: ^2.3.0
|
||||||
|
version: 2.3.0(prop-types@15.8.1)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
||||||
|
react-use-measure:
|
||||||
|
specifier: ^2.0.4
|
||||||
|
version: 2.1.7(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
||||||
|
react-window:
|
||||||
|
specifier: ^1.8.6
|
||||||
|
version: 1.8.11(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
||||||
|
serialize-error:
|
||||||
|
specifier: ^12.0.0
|
||||||
|
version: 12.0.0
|
||||||
|
thenby:
|
||||||
|
specifier: ^1.3.4
|
||||||
|
version: 1.3.4
|
||||||
|
uuid:
|
||||||
|
specifier: ^11.1.0
|
||||||
|
version: 11.1.0
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
'@ampproject/remapping@2.3.0':
|
'@ampproject/remapping@2.3.0':
|
||||||
|
|
@ -5235,6 +5274,11 @@ packages:
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||||
|
|
||||||
|
lucide-react@0.542.0:
|
||||||
|
resolution: {integrity: sha512-w3hD8/SQB7+lzU2r4VdFyzzOzKnUjTZIF/MQJGSSvni7Llewni4vuViRppfRAa2guOsY5k4jZyxw/i9DQHv+dw==}
|
||||||
|
peerDependencies:
|
||||||
|
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||||
|
|
||||||
lucide-react@0.543.0:
|
lucide-react@0.543.0:
|
||||||
resolution: {integrity: sha512-fpVfuOQO0V3HBaOA1stIiP/A2fPCXHIleRZL16Mx3HmjTYwNSbimhnFBygs2CAfU1geexMX5ItUcWBGUaqw5CA==}
|
resolution: {integrity: sha512-fpVfuOQO0V3HBaOA1stIiP/A2fPCXHIleRZL16Mx3HmjTYwNSbimhnFBygs2CAfU1geexMX5ItUcWBGUaqw5CA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|
@ -13350,6 +13394,10 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.1.1
|
react: 19.1.1
|
||||||
|
|
||||||
|
lucide-react@0.542.0(react@19.1.1):
|
||||||
|
dependencies:
|
||||||
|
react: 19.1.1
|
||||||
|
|
||||||
lucide-react@0.543.0(react@19.1.1):
|
lucide-react@0.543.0(react@19.1.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.1.1
|
react: 19.1.1
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export function SettingsLayout({ children }: { children: ReactNode }) {
|
||||||
|
|
||||||
const selectedKey = items
|
const selectedKey = items
|
||||||
.flatMap(e => e.items)
|
.flatMap(e => e.items)
|
||||||
.find(({ path }) => path && pathname.endsWith(path.split('?')[0]))?.id;
|
.find(({ path }) => path && pathname.includes(path.split('?')[0]))?.id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid columns="auto 1fr" width="100%" height="100%">
|
<Grid columns="auto 1fr" width="100%" height="100%">
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export function TeamsSettingsPage() {
|
||||||
<Column gap="6">
|
<Column gap="6">
|
||||||
<TeamsHeader />
|
<TeamsHeader />
|
||||||
<Panel>
|
<Panel>
|
||||||
<TeamsDataTable showActions={true} />
|
<TeamsDataTable />
|
||||||
</Panel>
|
</Panel>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,13 @@ import { Column } from '@umami/react-zen';
|
||||||
import { WebsiteProvider } from '@/app/(main)/websites/WebsiteProvider';
|
import { WebsiteProvider } from '@/app/(main)/websites/WebsiteProvider';
|
||||||
import { WebsiteSettings } from '@/app/(main)/websites/[websiteId]/settings/WebsiteSettings';
|
import { WebsiteSettings } from '@/app/(main)/websites/[websiteId]/settings/WebsiteSettings';
|
||||||
import { WebsiteSettingsHeader } from '@/app/(main)/websites/[websiteId]/settings/WebsiteSettingsHeader';
|
import { WebsiteSettingsHeader } from '@/app/(main)/websites/[websiteId]/settings/WebsiteSettingsHeader';
|
||||||
import { Panel } from '@/components/common/Panel';
|
|
||||||
|
|
||||||
export function WebsiteSettingsPage({ websiteId }: { websiteId: string }) {
|
export function WebsiteSettingsPage({ websiteId }: { websiteId: string }) {
|
||||||
return (
|
return (
|
||||||
<WebsiteProvider websiteId={websiteId}>
|
<WebsiteProvider websiteId={websiteId}>
|
||||||
<Column gap="6" margin="2">
|
<Column gap="6" margin="2">
|
||||||
<WebsiteSettingsHeader />
|
<WebsiteSettingsHeader />
|
||||||
<Panel>
|
<WebsiteSettings websiteId={websiteId} />
|
||||||
<WebsiteSettings websiteId={websiteId} />
|
|
||||||
</Panel>
|
|
||||||
</Column>
|
</Column>
|
||||||
</WebsiteProvider>
|
</WebsiteProvider>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,11 @@ import {
|
||||||
Button,
|
Button,
|
||||||
FormSubmitButton,
|
FormSubmitButton,
|
||||||
} from '@umami/react-zen';
|
} from '@umami/react-zen';
|
||||||
import { useMessages, useModified, useUpdateQuery } from '@/components/hooks';
|
import { useMessages, useUpdateQuery } from '@/components/hooks';
|
||||||
|
|
||||||
export function TeamJoinForm({ onSave, onClose }: { onSave: () => void; onClose: () => void }) {
|
export function TeamJoinForm({ onSave, onClose }: { onSave: () => void; onClose: () => void }) {
|
||||||
const { formatMessage, labels, getErrorMessage } = useMessages();
|
const { formatMessage, labels, getErrorMessage } = useMessages();
|
||||||
const { mutate, error } = useUpdateQuery('/teams/join');
|
const { mutate, error, isPending, touch } = useUpdateQuery('/teams/join');
|
||||||
const { touch } = useModified();
|
|
||||||
|
|
||||||
const handleSubmit = async (data: any) => {
|
const handleSubmit = async (data: any) => {
|
||||||
mutate(data, {
|
mutate(data, {
|
||||||
|
|
@ -34,7 +33,9 @@ export function TeamJoinForm({ onSave, onClose }: { onSave: () => void; onClose:
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormButtons>
|
<FormButtons>
|
||||||
<Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
|
<Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
|
||||||
<FormSubmitButton variant="primary">{formatMessage(labels.join)}</FormSubmitButton>
|
<FormSubmitButton variant="primary" isLoading={isPending} isDisabled={isPending}>
|
||||||
|
{formatMessage(labels.join)}
|
||||||
|
</FormSubmitButton>
|
||||||
</FormButtons>
|
</FormButtons>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
import { DataColumn, DataTable, Icon, MenuItem, Text, Row } from '@umami/react-zen';
|
import { DataColumn, DataTable } from '@umami/react-zen';
|
||||||
import { useMessages } from '@/components/hooks';
|
import { useMessages } from '@/components/hooks';
|
||||||
import { Eye, Edit } from '@/components/icons';
|
|
||||||
import { ROLES } from '@/lib/constants';
|
import { ROLES } from '@/lib/constants';
|
||||||
import { MenuButton } from '@/components/input/MenuButton';
|
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
export function TeamsTable({
|
export function TeamsTable({
|
||||||
data = [],
|
data = [],
|
||||||
showActions = false,
|
|
||||||
renderLink,
|
renderLink,
|
||||||
}: {
|
}: {
|
||||||
data: any[];
|
data: any[];
|
||||||
showActions?: boolean;
|
|
||||||
renderLink?: (row: any) => ReactNode;
|
renderLink?: (row: any) => ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
@ -30,34 +26,6 @@ export function TeamsTable({
|
||||||
<DataColumn id="members" label={formatMessage(labels.members)} align="end">
|
<DataColumn id="members" label={formatMessage(labels.members)} align="end">
|
||||||
{(row: any) => row?._count?.members}
|
{(row: any) => row?._count?.members}
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
{showActions ? (
|
|
||||||
<DataColumn id="action" label=" " align="end">
|
|
||||||
{(row: any) => {
|
|
||||||
const { id } = row;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<MenuButton>
|
|
||||||
<MenuItem href={`/teams/${id}`}>
|
|
||||||
<Row alignItems="center" gap>
|
|
||||||
<Icon>
|
|
||||||
<Eye />
|
|
||||||
</Icon>
|
|
||||||
<Text>{formatMessage(labels.view)}</Text>
|
|
||||||
</Row>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem href={`/settings/teams/${id}`}>
|
|
||||||
<Row alignItems="center" gap>
|
|
||||||
<Icon>
|
|
||||||
<Edit />
|
|
||||||
</Icon>
|
|
||||||
<Text>{formatMessage(labels.edit)}</Text>
|
|
||||||
</Row>
|
|
||||||
</MenuItem>
|
|
||||||
</MenuButton>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
</DataColumn>
|
|
||||||
) : null}
|
|
||||||
</DataTable>
|
</DataTable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,12 @@ const generateId = () => `team_${getRandomChars(16)}`;
|
||||||
export function TeamEditForm({
|
export function TeamEditForm({
|
||||||
teamId,
|
teamId,
|
||||||
allowEdit,
|
allowEdit,
|
||||||
|
showAccessCode,
|
||||||
onSave,
|
onSave,
|
||||||
}: {
|
}: {
|
||||||
teamId: string;
|
teamId: string;
|
||||||
allowEdit?: boolean;
|
allowEdit?: boolean;
|
||||||
|
showAccessCode?: boolean;
|
||||||
onSave?: () => void;
|
onSave?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const team = useTeam();
|
const team = useTeam();
|
||||||
|
|
@ -51,9 +53,11 @@ export function TeamEditForm({
|
||||||
>
|
>
|
||||||
<TextField isReadOnly={!allowEdit} />
|
<TextField isReadOnly={!allowEdit} />
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormField name="accessCode" label={formatMessage(labels.accessCode)}>
|
{showAccessCode && (
|
||||||
<TextField isReadOnly allowCopy />
|
<FormField name="accessCode" label={formatMessage(labels.accessCode)}>
|
||||||
</FormField>
|
<TextField isReadOnly allowCopy />
|
||||||
|
</FormField>
|
||||||
|
)}
|
||||||
{allowEdit && (
|
{allowEdit && (
|
||||||
<FormButtons justifyContent="space-between">
|
<FormButtons justifyContent="space-between">
|
||||||
<Button onPress={() => setValue('accessCode', generateId(), { shouldDirty: true })}>
|
<Button onPress={() => setValue('accessCode', generateId(), { shouldDirty: true })}>
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
'use client';
|
|
||||||
import { TeamMembersDataTable } from './TeamMembersDataTable';
|
|
||||||
import { SectionHeader } from '@/components/common/SectionHeader';
|
|
||||||
import { useLoginQuery, useMessages, useTeam } from '@/components/hooks';
|
|
||||||
import { ROLES } from '@/lib/constants';
|
|
||||||
import { Column } from '@umami/react-zen';
|
|
||||||
|
|
||||||
export function TeamMembersPage({ teamId }: { teamId: string }) {
|
|
||||||
const team = useTeam();
|
|
||||||
const { user } = useLoginQuery();
|
|
||||||
const { formatMessage, labels } = useMessages();
|
|
||||||
|
|
||||||
const canEdit =
|
|
||||||
team?.members?.find(
|
|
||||||
({ userId, role }) =>
|
|
||||||
(role === ROLES.teamOwner || role === ROLES.teamManager) && userId === user.id,
|
|
||||||
) && user.role !== ROLES.viewOnly;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Column gap>
|
|
||||||
<SectionHeader title={formatMessage(labels.members)} />
|
|
||||||
<TeamMembersDataTable teamId={teamId} allowEdit={canEdit} />
|
|
||||||
</Column>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +1,20 @@
|
||||||
import { useState } from 'react';
|
import Link from 'next/link';
|
||||||
import { Column, Tabs, TabList, Tab, TabPanel } from '@umami/react-zen';
|
import { Column, Icon, Text, Row } from '@umami/react-zen';
|
||||||
import { useLoginQuery, useMessages, useNavigation, useTeam } from '@/components/hooks';
|
import { useLoginQuery, useMessages, useNavigation, useTeam } from '@/components/hooks';
|
||||||
|
|
||||||
import { ROLES } from '@/lib/constants';
|
import { ROLES } from '@/lib/constants';
|
||||||
import { Users } from '@/components/icons';
|
import { Users, Arrow } from '@/components/icons';
|
||||||
import { TeamLeaveButton } from '@/app/(main)/teams/TeamLeaveButton';
|
import { TeamLeaveButton } from '@/app/(main)/teams/TeamLeaveButton';
|
||||||
import { TeamManage } from './TeamManage';
|
import { TeamManage } from './TeamManage';
|
||||||
import { TeamEditForm } from './TeamEditForm';
|
import { TeamEditForm } from './TeamEditForm';
|
||||||
import { TeamWebsitesDataTable } from './TeamWebsitesDataTable';
|
|
||||||
import { TeamMembersDataTable } from './TeamMembersDataTable';
|
import { TeamMembersDataTable } from './TeamMembersDataTable';
|
||||||
import { PageHeader } from '@/components/common/PageHeader';
|
import { PageHeader } from '@/components/common/PageHeader';
|
||||||
import { Panel } from '@/components/common/Panel';
|
import { Panel } from '@/components/common/Panel';
|
||||||
|
|
||||||
export function TeamSettings({ teamId }: { teamId: string }) {
|
export function TeamSettings({ teamId }: { teamId: string }) {
|
||||||
const team: any = useTeam();
|
const team: any = useTeam();
|
||||||
const { formatMessage, labels } = useMessages();
|
|
||||||
const { user } = useLoginQuery();
|
const { user } = useLoginQuery();
|
||||||
const { query, pathname } = useNavigation();
|
const { formatMessage, labels } = useMessages();
|
||||||
const [tab, setTab] = useState(query?.tab || 'details');
|
const { pathname } = useNavigation();
|
||||||
|
|
||||||
const isAdmin = pathname.includes('/admin');
|
const isAdmin = pathname.includes('/admin');
|
||||||
|
|
||||||
|
|
@ -34,32 +31,32 @@ export function TeamSettings({ teamId }: { teamId: string }) {
|
||||||
user.role !== ROLES.viewOnly);
|
user.role !== ROLES.viewOnly);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column gap="6">
|
<>
|
||||||
<PageHeader title={team?.name} icon={<Users />}>
|
<Link href="/settings/teams">
|
||||||
{!isTeamOwner && !isAdmin && <TeamLeaveButton teamId={team.id} teamName={team.name} />}
|
<Row marginTop="2" alignItems="center" gap>
|
||||||
</PageHeader>
|
<Icon rotate={180}>
|
||||||
<Panel>
|
<Arrow />
|
||||||
<Tabs selectedKey={tab} onSelectionChange={(value: any) => setTab(value)}>
|
</Icon>
|
||||||
<TabList>
|
<Text>{formatMessage(labels.teams)}</Text>
|
||||||
<Tab id="details">{formatMessage(labels.details)}</Tab>
|
</Row>
|
||||||
<Tab id="members">{formatMessage(labels.members)}</Tab>
|
</Link>
|
||||||
<Tab id="websites">{formatMessage(labels.websites)}</Tab>
|
|
||||||
{isTeamOwner && <Tab id="manage">{formatMessage(labels.manage)}</Tab>}
|
<Column gap="6">
|
||||||
</TabList>
|
<PageHeader title={team?.name} icon={<Users />}>
|
||||||
<TabPanel id="details" style={{ width: 500 }}>
|
{!isTeamOwner && !isAdmin && <TeamLeaveButton teamId={team.id} teamName={team.name} />}
|
||||||
<TeamEditForm teamId={teamId} allowEdit={canEdit} />
|
</PageHeader>
|
||||||
</TabPanel>
|
<Panel>
|
||||||
<TabPanel id="members">
|
<TeamEditForm teamId={teamId} allowEdit={canEdit} showAccessCode={canEdit} />
|
||||||
<TeamMembersDataTable teamId={teamId} allowEdit />
|
</Panel>
|
||||||
</TabPanel>
|
<Panel>
|
||||||
<TabPanel id="websites">
|
<TeamMembersDataTable teamId={teamId} allowEdit={canEdit} />
|
||||||
<TeamWebsitesDataTable teamId={teamId} allowEdit />
|
</Panel>
|
||||||
</TabPanel>
|
{isTeamOwner && (
|
||||||
<TabPanel id="manage">
|
<Panel>
|
||||||
<TeamManage teamId={teamId} />
|
<TeamManage teamId={teamId} />
|
||||||
</TabPanel>
|
</Panel>
|
||||||
</Tabs>
|
)}
|
||||||
</Panel>
|
</Column>
|
||||||
</Column>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { DOMAIN_REGEX } from '@/lib/constants';
|
||||||
export function WebsiteEditForm({ websiteId, onSave }: { websiteId: string; onSave?: () => void }) {
|
export function WebsiteEditForm({ websiteId, onSave }: { websiteId: string; onSave?: () => void }) {
|
||||||
const website = useWebsite();
|
const website = useWebsite();
|
||||||
const { formatMessage, labels, messages, getErrorMessage } = useMessages();
|
const { formatMessage, labels, messages, getErrorMessage } = useMessages();
|
||||||
const { mutate, error, touch, toast } = useUpdateQuery(`/websites/${websiteId}`);
|
const { mutate, error, touch, toast, isPending } = useUpdateQuery(`/websites/${websiteId}`);
|
||||||
|
|
||||||
const handleSubmit = async (data: any) => {
|
const handleSubmit = async (data: any) => {
|
||||||
mutate(data, {
|
mutate(data, {
|
||||||
|
|
@ -45,7 +45,12 @@ export function WebsiteEditForm({ websiteId, onSave }: { websiteId: string; onSa
|
||||||
<TextField />
|
<TextField />
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormButtons>
|
<FormButtons>
|
||||||
<FormSubmitButton data-test="button-submit" variant="primary">
|
<FormSubmitButton
|
||||||
|
data-test="button-submit"
|
||||||
|
variant="primary"
|
||||||
|
isLoading={isPending}
|
||||||
|
isDisabled={isPending}
|
||||||
|
>
|
||||||
{formatMessage(labels.save)}
|
{formatMessage(labels.save)}
|
||||||
</FormSubmitButton>
|
</FormSubmitButton>
|
||||||
</FormButtons>
|
</FormButtons>
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,28 @@
|
||||||
import { Tabs, TabList, Tab, TabPanel } from '@umami/react-zen';
|
import { Column } from '@umami/react-zen';
|
||||||
import { useMessages, useWebsite } from '@/components/hooks';
|
import { useWebsite } from '@/components/hooks';
|
||||||
import { WebsiteShareForm } from './WebsiteShareForm';
|
import { WebsiteShareForm } from './WebsiteShareForm';
|
||||||
import { WebsiteTrackingCode } from './WebsiteTrackingCode';
|
import { WebsiteTrackingCode } from './WebsiteTrackingCode';
|
||||||
import { WebsiteData } from './WebsiteData';
|
import { WebsiteData } from './WebsiteData';
|
||||||
import { WebsiteEditForm } from './WebsiteEditForm';
|
import { WebsiteEditForm } from './WebsiteEditForm';
|
||||||
|
import { Panel } from '@/components/common/Panel';
|
||||||
|
|
||||||
export function WebsiteSettings({ websiteId }: { websiteId: string; openExternal?: boolean }) {
|
export function WebsiteSettings({ websiteId }: { websiteId: string; openExternal?: boolean }) {
|
||||||
const website = useWebsite();
|
const website = useWebsite();
|
||||||
const { formatMessage, labels } = useMessages();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs>
|
<Column gap="6">
|
||||||
<TabList>
|
<Panel>
|
||||||
<Tab id="details">{formatMessage(labels.details)}</Tab>
|
|
||||||
<Tab id="tracking">{formatMessage(labels.trackingCode)}</Tab>
|
|
||||||
<Tab id="share"> {formatMessage(labels.shareUrl)}</Tab>
|
|
||||||
<Tab id="manage">{formatMessage(labels.manage)}</Tab>
|
|
||||||
</TabList>
|
|
||||||
<TabPanel id="details" style={{ width: 500 }}>
|
|
||||||
<WebsiteEditForm websiteId={websiteId} />
|
<WebsiteEditForm websiteId={websiteId} />
|
||||||
</TabPanel>
|
</Panel>
|
||||||
<TabPanel id="tracking">
|
<Panel>
|
||||||
<WebsiteTrackingCode websiteId={websiteId} />
|
<WebsiteTrackingCode websiteId={websiteId} />
|
||||||
</TabPanel>
|
</Panel>
|
||||||
<TabPanel id="share" style={{ width: 500 }}>
|
<Panel>
|
||||||
<WebsiteShareForm websiteId={websiteId} shareId={website.shareId} />
|
<WebsiteShareForm websiteId={websiteId} shareId={website.shareId} />
|
||||||
</TabPanel>
|
</Panel>
|
||||||
<TabPanel id="manage">
|
<Panel>
|
||||||
<WebsiteData websiteId={websiteId} />
|
<WebsiteData websiteId={websiteId} />
|
||||||
</TabPanel>
|
</Panel>
|
||||||
</Tabs>
|
</Column>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { TextField, Text, Column } from '@umami/react-zen';
|
import { TextField, Text, Column, Label } from '@umami/react-zen';
|
||||||
import { useMessages, useConfig } from '@/components/hooks';
|
import { useMessages, useConfig } from '@/components/hooks';
|
||||||
|
|
||||||
const SCRIPT_NAME = 'script.js';
|
const SCRIPT_NAME = 'script.js';
|
||||||
|
|
@ -10,7 +10,7 @@ export function WebsiteTrackingCode({
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
hostUrl?: string;
|
hostUrl?: string;
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage, messages } = useMessages();
|
const { formatMessage, messages, labels } = useMessages();
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
|
|
||||||
const trackerScriptName =
|
const trackerScriptName =
|
||||||
|
|
@ -26,7 +26,8 @@ export function WebsiteTrackingCode({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column gap>
|
<Column gap>
|
||||||
<Text>{formatMessage(messages.trackingCode)}</Text>
|
<Label>{formatMessage(labels.trackingCode)}</Label>
|
||||||
|
<Text color="muted">{formatMessage(messages.trackingCode)}</Text>
|
||||||
<TextField value={code} isReadOnly allowCopy asTextArea resize="none" />
|
<TextField value={code} isReadOnly allowCopy asTextArea resize="none" />
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { unauthorized, json, badRequest, notFound } from '@/lib/response';
|
import { json, badRequest, notFound } from '@/lib/response';
|
||||||
import { canCreateTeam } from '@/permissions';
|
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { ROLES } from '@/lib/constants';
|
import { ROLES } from '@/lib/constants';
|
||||||
import { createTeamUser, findTeam, getTeamUser } from '@/queries';
|
import { createTeamUser, findTeam, getTeamUser } from '@/queries';
|
||||||
|
|
@ -16,10 +15,6 @@ export async function POST(request: Request) {
|
||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(await canCreateTeam(auth))) {
|
|
||||||
return unauthorized();
|
|
||||||
}
|
|
||||||
|
|
||||||
const { accessCode } = body;
|
const { accessCode } = body;
|
||||||
|
|
||||||
const team = await findTeam({
|
const team = await findTeam({
|
||||||
|
|
@ -29,7 +24,7 @@ export async function POST(request: Request) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!team) {
|
if (!team) {
|
||||||
return notFound({ message: 'Team not found.' });
|
return notFound({ message: 'Team not found.', code: 'team-not-found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const teamUser = await getTeamUser(team.id, auth.user.id);
|
const teamUser = await getTeamUser(team.id, auth.user.id);
|
||||||
|
|
|
||||||
|
|
@ -8,23 +8,18 @@ import { removeClientAuthToken } from '@/lib/client';
|
||||||
export function LogoutPage() {
|
export function LogoutPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { post } = useApi();
|
const { post } = useApi();
|
||||||
const disabled = process.env.cloudUrl;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function logout() {
|
async function logout() {
|
||||||
await post('/auth/logout');
|
await post('/auth/logout');
|
||||||
}
|
|
||||||
|
|
||||||
if (!disabled) {
|
|
||||||
removeClientAuthToken();
|
|
||||||
|
|
||||||
logout();
|
|
||||||
|
|
||||||
router.push('/login');
|
router.push('/login');
|
||||||
|
|
||||||
return () => setUser(null);
|
|
||||||
}
|
}
|
||||||
}, [disabled, router, post]);
|
|
||||||
|
removeClientAuthToken();
|
||||||
|
setUser(null);
|
||||||
|
logout();
|
||||||
|
}, [router, post]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
MenuSection,
|
MenuSection,
|
||||||
} from '@umami/react-zen';
|
} from '@umami/react-zen';
|
||||||
import { useMessages, useLoginQuery, useNavigation, useConfig } from '@/components/hooks';
|
import { useMessages, useLoginQuery, useNavigation, useConfig } from '@/components/hooks';
|
||||||
import { LogOut, LockKeyhole, Settings } from '@/components/icons';
|
import { LogOut, LockKeyhole, Settings, UserCircle } from '@/components/icons';
|
||||||
|
|
||||||
export function SettingsButton() {
|
export function SettingsButton() {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
@ -33,7 +33,7 @@ export function SettingsButton() {
|
||||||
<MenuTrigger>
|
<MenuTrigger>
|
||||||
<Button data-test="button-profile" variant="quiet" autoFocus={false}>
|
<Button data-test="button-profile" variant="quiet" autoFocus={false}>
|
||||||
<Icon>
|
<Icon>
|
||||||
<Settings />
|
<UserCircle />
|
||||||
</Icon>
|
</Icon>
|
||||||
</Button>
|
</Button>
|
||||||
<Popover placement="bottom end">
|
<Popover placement="bottom end">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue