mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +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 { user } = useLogin();
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
const canEdit = team?.teamUser?.find(
|
const canEdit =
|
||||||
({ userId, role }) => role === ROLES.teamOwner && userId === user.id,
|
team?.teamUser?.find(({ userId, role }) => role === ROLES.teamOwner && userId === user.id) &&
|
||||||
);
|
user.role !== ROLES.viewOnly;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -15,9 +15,9 @@ export function TeamDetails({ teamId }: { teamId: string }) {
|
|||||||
const { user } = useLogin();
|
const { user } = useLogin();
|
||||||
const [tab, setTab] = useState('details');
|
const [tab, setTab] = useState('details');
|
||||||
|
|
||||||
const canEdit = !!team?.teamUser?.find(
|
const canEdit =
|
||||||
({ userId, role }) => role === ROLES.teamOwner && userId === user.id,
|
!!team?.teamUser?.find(({ userId, role }) => role === ROLES.teamOwner && userId === user.id) &&
|
||||||
);
|
user.role !== ROLES.viewOnly;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flexbox direction="column">
|
<Flexbox direction="column">
|
||||||
|
@ -12,16 +12,17 @@ export function TeamWebsitesPage({ teamId }: { teamId: string }) {
|
|||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { user } = useLogin();
|
const { user } = useLogin();
|
||||||
|
|
||||||
const allowEdit = !!team?.teamUser?.find(
|
const canEdit =
|
||||||
({ userId, role }) => userId === user.id && role !== ROLES.teamViewOnly,
|
!!team?.teamUser?.find(
|
||||||
);
|
({ userId, role }) => userId === user.id && role !== ROLES.teamViewOnly,
|
||||||
|
) && user.role !== ROLES.viewOnly;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageHeader title={formatMessage(labels.websites)}>
|
<PageHeader title={formatMessage(labels.websites)}>
|
||||||
{allowEdit && <WebsiteAddButton teamId={teamId} />}
|
{canEdit && <WebsiteAddButton teamId={teamId} />}
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<TeamWebsitesDataTable teamId={teamId} allowEdit={allowEdit} />
|
<TeamWebsitesDataTable teamId={teamId} allowEdit={canEdit} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
import { useLogin } from 'components/hooks';
|
||||||
import WebsitesDataTable from './WebsitesDataTable';
|
import WebsitesDataTable from './WebsitesDataTable';
|
||||||
import WebsitesHeader from './WebsitesHeader';
|
import WebsitesHeader from './WebsitesHeader';
|
||||||
|
import { ROLES } from 'lib/constants';
|
||||||
|
|
||||||
export default function WebsitesSettingsPage({ teamId }: { teamId: string }) {
|
export default function WebsitesSettingsPage({ teamId }: { teamId: string }) {
|
||||||
|
const { user } = useLogin();
|
||||||
|
const canCreate = user.role !== ROLES.viewOnly;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WebsitesHeader teamId={teamId} />
|
<WebsitesHeader teamId={teamId} allowCreate={canCreate} />
|
||||||
<WebsitesDataTable teamId={teamId} />
|
<WebsitesDataTable teamId={teamId} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
import WebsitesHeader from 'app/(main)/settings/websites/WebsitesHeader';
|
import WebsitesHeader from 'app/(main)/settings/websites/WebsitesHeader';
|
||||||
import WebsitesDataTable from 'app/(main)/settings/websites/WebsitesDataTable';
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<WebsitesHeader teamId={teamId} allowCreate={user.role !== 'view-only'} />
|
<WebsitesHeader teamId={teamId} allowCreate={false} />
|
||||||
<WebsitesDataTable teamId={teamId} allowEdit={false} />
|
<WebsitesDataTable teamId={teamId} allowEdit={false} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user