mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Fix admin layout and data refresh after update/delete
This commit is contained in:
parent
c81b1c16c8
commit
ef55b63a3b
5 changed files with 29 additions and 13 deletions
|
|
@ -46,8 +46,15 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||||
?.find(({ path }) => path && pathname.startsWith(path))?.id;
|
?.find(({ path }) => path && pathname.startsWith(path))?.id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid columns="auto 1fr" width="100%" height="100%">
|
<Grid columns={{ xs: '1fr', lg: 'auto 1fr' }} width="100%" height="100%">
|
||||||
<Column height="100%" border="right" backgroundColor>
|
<Column
|
||||||
|
display={{ xs: 'none', lg: 'flex' }}
|
||||||
|
width="240px"
|
||||||
|
height="100%"
|
||||||
|
border="right"
|
||||||
|
backgroundColor
|
||||||
|
marginRight="2"
|
||||||
|
>
|
||||||
<SideMenu
|
<SideMenu
|
||||||
items={items}
|
items={items}
|
||||||
title={formatMessage(labels.admin)}
|
title={formatMessage(labels.admin)}
|
||||||
|
|
@ -55,7 +62,9 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||||
allowMinimize={false}
|
allowMinimize={false}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
|
<Column gap="6" margin="2">
|
||||||
<PageBody>{children}</PageBody>
|
<PageBody>{children}</PageBody>
|
||||||
|
</Column>
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { useState } from 'react';
|
|
||||||
import { Row, Text, Icon, DataTable, DataColumn, MenuItem, Modal } from '@umami/react-zen';
|
|
||||||
import Link from 'next/link';
|
|
||||||
import { Trash } from '@/components/icons';
|
|
||||||
import { useMessages } from '@/components/hooks';
|
|
||||||
import { Edit } from '@/components/icons';
|
|
||||||
import { MenuButton } from '@/components/input/MenuButton';
|
|
||||||
import { DateDistance } from '@/components/common/DateDistance';
|
import { DateDistance } from '@/components/common/DateDistance';
|
||||||
|
import { useMessages } from '@/components/hooks';
|
||||||
|
import { Edit, Trash } from '@/components/icons';
|
||||||
|
import { MenuButton } from '@/components/input/MenuButton';
|
||||||
|
import { DataColumn, DataTable, Dialog, Icon, MenuItem, Modal, Row, Text } from '@umami/react-zen';
|
||||||
|
import { TeamDeleteForm } from '../../teams/[teamId]/TeamDeleteForm';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
export function AdminTeamsTable({
|
export function AdminTeamsTable({
|
||||||
data = [],
|
data = [],
|
||||||
|
|
@ -15,7 +15,7 @@ export function AdminTeamsTable({
|
||||||
showActions?: boolean;
|
showActions?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const [deleteUser, setDeleteUser] = useState(null);
|
const [deleteTeam, setDeleteTeam] = useState(null);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -60,7 +60,7 @@ export function AdminTeamsTable({
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
id="delete"
|
id="delete"
|
||||||
onAction={() => setDeleteUser(row)}
|
onAction={() => setDeleteTeam(id)}
|
||||||
data-test="link-button-delete"
|
data-test="link-button-delete"
|
||||||
>
|
>
|
||||||
<Row alignItems="center" gap>
|
<Row alignItems="center" gap>
|
||||||
|
|
@ -76,7 +76,11 @@ export function AdminTeamsTable({
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
)}
|
)}
|
||||||
</DataTable>
|
</DataTable>
|
||||||
<Modal isOpen={!!deleteUser}></Modal>
|
<Modal isOpen={!!deleteTeam}>
|
||||||
|
<Dialog style={{ width: 400 }}>
|
||||||
|
<TeamDeleteForm teamId={deleteTeam} onClose={() => setDeleteTeam(null)} />
|
||||||
|
</Dialog>
|
||||||
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export function UserEditForm({ userId, onSave }: { userId: string; onSave?: () =
|
||||||
await mutateAsync(data, {
|
await mutateAsync(data, {
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
toast(formatMessage(messages.saved));
|
toast(formatMessage(messages.saved));
|
||||||
|
touch('users');
|
||||||
touch(`user:${user.id}`);
|
touch(`user:${user.id}`);
|
||||||
onSave?.();
|
onSave?.();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ export function TeamDeleteForm({
|
||||||
await mutateAsync(null, {
|
await mutateAsync(null, {
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
touch('teams');
|
touch('teams');
|
||||||
|
touch(`teams:${teamId}`);
|
||||||
onSave?.();
|
onSave?.();
|
||||||
onClose?.();
|
onClose?.();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export function WebsiteEditForm({ websiteId, onSave }: { websiteId: string; onSa
|
||||||
await mutateAsync(data, {
|
await mutateAsync(data, {
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
toast(formatMessage(messages.saved));
|
toast(formatMessage(messages.saved));
|
||||||
|
touch('websites');
|
||||||
touch(`website:${website.id}`);
|
touch(`website:${website.id}`);
|
||||||
onSave?.();
|
onSave?.();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue