fix: page permission validation (#5589)
This commit is contained in:
parent
eb84f165f4
commit
aed2f2dd47
2 changed files with 12 additions and 3 deletions
|
|
@ -15,10 +15,11 @@ import { PageEditInformationPopover } from "@/components/pages";
|
|||
import { convertHexEmojiToDecimal } from "@/helpers/emoji.helper";
|
||||
import { getPageName } from "@/helpers/page.helper";
|
||||
// hooks
|
||||
import { usePage, useProject } from "@/hooks/store";
|
||||
import { usePage, useProject, useUser, useUserPermissions } from "@/hooks/store";
|
||||
import { usePlatformOS } from "@/hooks/use-platform-os";
|
||||
// plane web components
|
||||
import { PageDetailsHeaderExtraActions } from "@/plane-web/components/pages";
|
||||
import { EUserPermissions, EUserPermissionsLevel } from "ee/constants/user-permissions";
|
||||
|
||||
export interface IPagesHeaderProps {
|
||||
showButton?: boolean;
|
||||
|
|
@ -32,10 +33,17 @@ export const PageDetailsHeader = observer(() => {
|
|||
// store hooks
|
||||
const { currentProjectDetails, loader } = useProject();
|
||||
const page = usePage(pageId?.toString() ?? "");
|
||||
const { name, logo_props, updatePageLogo } = page;
|
||||
const { name, logo_props, updatePageLogo, owned_by } = page;
|
||||
const { allowPermissions } = useUserPermissions();
|
||||
const { data: currentUser } = useUser();
|
||||
// use platform
|
||||
const { isMobile } = usePlatformOS();
|
||||
|
||||
const isAdmin = allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT);
|
||||
const isOwner = owned_by === currentUser?.id;
|
||||
|
||||
const isEditable = isAdmin || isOwner;
|
||||
|
||||
const handlePageLogoUpdate = async (data: TLogoProps) => {
|
||||
if (data) {
|
||||
updatePageLogo(data)
|
||||
|
|
@ -144,6 +152,7 @@ export const PageDetailsHeader = observer(() => {
|
|||
? EmojiIconPickerTypes.EMOJI
|
||||
: EmojiIconPickerTypes.ICON
|
||||
}
|
||||
disabled={!isEditable}
|
||||
/>
|
||||
</div>
|
||||
<Tooltip tooltipContent={pageTitle} position="bottom" isMobile={isMobile}>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const PagesListHeader = observer(() => {
|
|||
const { setTrackElement } = useEventTracker();
|
||||
|
||||
const canUserCreatePage = allowPermissions(
|
||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST],
|
||||
EUserPermissionsLevel.PROJECT
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue