mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Fixed paging. Updated edit props.
This commit is contained in:
parent
d392e500c6
commit
b9825304c3
10 changed files with 32 additions and 46 deletions
|
|
@ -1,13 +1,12 @@
|
|||
'use client';
|
||||
import { GridColumn, GridTable, Icon, Text, useBreakpoint } from 'react-basics';
|
||||
import { useMessages, useLogin } from 'components/hooks';
|
||||
import { useMessages } from 'components/hooks';
|
||||
import Icons from 'components/icons';
|
||||
import { ROLES } from 'lib/constants';
|
||||
import LinkButton from 'components/common/LinkButton';
|
||||
|
||||
export function TeamsTable({
|
||||
data = [],
|
||||
allowEdit = false,
|
||||
showActions = true,
|
||||
}: {
|
||||
data: any[];
|
||||
|
|
@ -15,7 +14,6 @@ export function TeamsTable({
|
|||
showActions?: boolean;
|
||||
}) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { user } = useLogin();
|
||||
const breakpoint = useBreakpoint();
|
||||
|
||||
return (
|
||||
|
|
@ -30,34 +28,22 @@ export function TeamsTable({
|
|||
<GridColumn name="members" label={formatMessage(labels.members)}>
|
||||
{row => row._count.teamUser}
|
||||
</GridColumn>
|
||||
<GridColumn name="action" label=" " alignment="end">
|
||||
{row => {
|
||||
const { id, teamUser } = row;
|
||||
const owner = teamUser.find(({ role }) => role === ROLES.teamOwner);
|
||||
const isOwner = user.id === owner?.userId;
|
||||
{showActions && (
|
||||
<GridColumn name="action" label=" " alignment="end">
|
||||
{row => {
|
||||
const { id } = row;
|
||||
|
||||
return (
|
||||
showActions && (
|
||||
<>
|
||||
{allowEdit && isOwner && (
|
||||
<LinkButton href={`/teams/${id}/settings`}>
|
||||
<Icon>
|
||||
<Icons.Edit />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.edit)}</Text>
|
||||
</LinkButton>
|
||||
)}
|
||||
<LinkButton href={`/teams/${id}`}>
|
||||
<Icon>
|
||||
<Icons.Change />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.switch)}</Text>
|
||||
</LinkButton>
|
||||
</>
|
||||
)
|
||||
);
|
||||
}}
|
||||
</GridColumn>
|
||||
return (
|
||||
<LinkButton href={`/teams/${id}/settings`}>
|
||||
<Icon>
|
||||
<Icons.ArrowRight />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.view)}</Text>
|
||||
</LinkButton>
|
||||
);
|
||||
}}
|
||||
</GridColumn>
|
||||
)}
|
||||
</GridTable>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ import WebsiteAddButton from './WebsiteAddButton';
|
|||
|
||||
export interface WebsitesHeaderProps {
|
||||
teamId?: string;
|
||||
showActions?: boolean;
|
||||
allowCreate?: boolean;
|
||||
}
|
||||
|
||||
export function WebsitesHeader({ teamId, showActions = true }: WebsitesHeaderProps) {
|
||||
export function WebsitesHeader({ teamId, allowCreate = true }: WebsitesHeaderProps) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
|
||||
return (
|
||||
<PageHeader title={formatMessage(labels.websites)}>
|
||||
{!process.env.cloudMode && showActions && <WebsiteAddButton teamId={teamId} />}
|
||||
{allowCreate && !process.env.cloudMode && <WebsiteAddButton teamId={teamId} />}
|
||||
</PageHeader>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue