mirror of
https://github.com/umami-software/umami.git
synced 2026-02-14 17:45:38 +01:00
Allow getting team websites.
This commit is contained in:
parent
e610de383a
commit
433ce98719
10 changed files with 79 additions and 56 deletions
|
|
@ -1,20 +1,23 @@
|
|||
import Link from 'next/link';
|
||||
import { WebsitesTable } from './WebsitesTable';
|
||||
import { DataGrid } from '@/components/common/DataGrid';
|
||||
import { useNavigation, useUserWebsitesQuery } from '@/components/hooks';
|
||||
import { useLoginQuery, useNavigation, useUserWebsitesQuery } from '@/components/hooks';
|
||||
|
||||
export function WebsitesDataTable({
|
||||
userId,
|
||||
teamId,
|
||||
allowEdit = true,
|
||||
allowView = true,
|
||||
showActions = true,
|
||||
}: {
|
||||
userId?: string;
|
||||
teamId?: string;
|
||||
allowEdit?: boolean;
|
||||
allowView?: boolean;
|
||||
showActions?: boolean;
|
||||
}) {
|
||||
const queryResult = useUserWebsitesQuery({ teamId });
|
||||
const { user } = useLoginQuery();
|
||||
const queryResult = useUserWebsitesQuery({ userId: userId || user?.id, teamId });
|
||||
const { renderUrl } = useNavigation();
|
||||
|
||||
const renderLink = (row: any) => (
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { Row, Text, Icon, DataTable, DataColumn, MenuItem } from '@umami/react-z
|
|||
import { useMessages, useNavigation } from '@/components/hooks';
|
||||
import { MenuButton } from '@/components/input/MenuButton';
|
||||
import { Eye, SquarePen } from '@/components/icons';
|
||||
import { Empty } from '@/components/common/Empty';
|
||||
|
||||
export function WebsitesTable({
|
||||
data = [],
|
||||
|
|
@ -10,20 +11,18 @@ export function WebsitesTable({
|
|||
allowEdit,
|
||||
allowView,
|
||||
renderLink,
|
||||
children,
|
||||
}: {
|
||||
data: Record<string, any>[];
|
||||
showActions?: boolean;
|
||||
allowEdit?: boolean;
|
||||
allowView?: boolean;
|
||||
renderLink?: (row: any) => ReactNode;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { renderUrl } = useNavigation();
|
||||
|
||||
if (!data?.length) {
|
||||
return children;
|
||||
if (data.length === 0) {
|
||||
return <Empty />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import { WebsiteSelect } from '@/components/input/WebsiteSelect';
|
|||
|
||||
export function WebsiteNav({ websiteId }: { websiteId: string }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { pathname, renderUrl, teamId } = useNavigation();
|
||||
const { pathname, renderUrl, teamId, router } = useNavigation();
|
||||
|
||||
const renderPath = (path: string) =>
|
||||
renderUrl(`/websites/${websiteId}${path}`, {
|
||||
|
|
@ -143,13 +143,17 @@ export function WebsiteNav({ websiteId }: { websiteId: string }) {
|
|||
},
|
||||
];
|
||||
|
||||
const handleChange = (value: string) => {
|
||||
router.push(renderUrl(`/websites/${value}`));
|
||||
};
|
||||
|
||||
const selectedKey = items
|
||||
.flatMap(e => e.items)
|
||||
.find(({ path }) => path && pathname.endsWith(path.split('?')[0]))?.id;
|
||||
|
||||
return (
|
||||
<SideMenu items={items} selectedKey={selectedKey} allowMinimize={false} muteItems={false}>
|
||||
<WebsiteSelect websiteId={websiteId} teamId={teamId} />
|
||||
<WebsiteSelect websiteId={websiteId} teamId={teamId} onChange={handleChange} />
|
||||
</SideMenu>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue