mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-01 20:39:44 +01:00
fix create website / teams permissions
This commit is contained in:
parent
8fbd6871f7
commit
490bb11771
@ -11,9 +11,9 @@ export function TeamMembersPage({ teamId }: { teamId: string }) {
|
||||
const { user } = useLogin();
|
||||
const { formatMessage, labels } = useMessages();
|
||||
|
||||
const canEdit = team?.teamUser?.find(
|
||||
({ userId, role }) => role === ROLES.teamOwner && userId === user.id,
|
||||
);
|
||||
const canEdit =
|
||||
team?.teamUser?.find(({ userId, role }) => role === ROLES.teamOwner && userId === user.id) &&
|
||||
user.role !== ROLES.viewOnly;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -15,9 +15,9 @@ export function TeamDetails({ teamId }: { teamId: string }) {
|
||||
const { user } = useLogin();
|
||||
const [tab, setTab] = useState('details');
|
||||
|
||||
const canEdit = !!team?.teamUser?.find(
|
||||
({ userId, role }) => role === ROLES.teamOwner && userId === user.id,
|
||||
);
|
||||
const canEdit =
|
||||
!!team?.teamUser?.find(({ userId, role }) => role === ROLES.teamOwner && userId === user.id) &&
|
||||
user.role !== ROLES.viewOnly;
|
||||
|
||||
return (
|
||||
<Flexbox direction="column">
|
||||
|
@ -12,16 +12,17 @@ export function TeamWebsitesPage({ teamId }: { teamId: string }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { user } = useLogin();
|
||||
|
||||
const allowEdit = !!team?.teamUser?.find(
|
||||
({ userId, role }) => userId === user.id && role !== ROLES.teamViewOnly,
|
||||
);
|
||||
const canEdit =
|
||||
!!team?.teamUser?.find(
|
||||
({ userId, role }) => userId === user.id && role !== ROLES.teamViewOnly,
|
||||
) && user.role !== ROLES.viewOnly;
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader title={formatMessage(labels.websites)}>
|
||||
{allowEdit && <WebsiteAddButton teamId={teamId} />}
|
||||
{canEdit && <WebsiteAddButton teamId={teamId} />}
|
||||
</PageHeader>
|
||||
<TeamWebsitesDataTable teamId={teamId} allowEdit={allowEdit} />
|
||||
<TeamWebsitesDataTable teamId={teamId} allowEdit={canEdit} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
'use client';
|
||||
import { useLogin } from 'components/hooks';
|
||||
import WebsitesDataTable from './WebsitesDataTable';
|
||||
import WebsitesHeader from './WebsitesHeader';
|
||||
import { ROLES } from 'lib/constants';
|
||||
|
||||
export default function WebsitesSettingsPage({ teamId }: { teamId: string }) {
|
||||
const { user } = useLogin();
|
||||
const canCreate = user.role !== ROLES.viewOnly;
|
||||
|
||||
return (
|
||||
<>
|
||||
<WebsitesHeader teamId={teamId} />
|
||||
<WebsitesHeader teamId={teamId} allowCreate={canCreate} />
|
||||
<WebsitesDataTable teamId={teamId} />
|
||||
</>
|
||||
);
|
||||
|
@ -1,14 +1,11 @@
|
||||
'use client';
|
||||
import WebsitesHeader from 'app/(main)/settings/websites/WebsitesHeader';
|
||||
import WebsitesDataTable from 'app/(main)/settings/websites/WebsitesDataTable';
|
||||
import { useLogin } from 'components/hooks';
|
||||
|
||||
export default function WebsitesPage({ teamId }: { teamId: string; userId: string }) {
|
||||
const { user } = useLogin();
|
||||
|
||||
export default function WebsitesPage({ teamId }: { teamId: string }) {
|
||||
return (
|
||||
<>
|
||||
<WebsitesHeader teamId={teamId} allowCreate={user.role !== 'view-only'} />
|
||||
<WebsitesHeader teamId={teamId} allowCreate={false} />
|
||||
<WebsitesDataTable teamId={teamId} allowEdit={false} />
|
||||
</>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user