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 { convertHexEmojiToDecimal } from "@/helpers/emoji.helper";
|
||||||
import { getPageName } from "@/helpers/page.helper";
|
import { getPageName } from "@/helpers/page.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { usePage, useProject } from "@/hooks/store";
|
import { usePage, useProject, useUser, useUserPermissions } from "@/hooks/store";
|
||||||
import { usePlatformOS } from "@/hooks/use-platform-os";
|
import { usePlatformOS } from "@/hooks/use-platform-os";
|
||||||
// plane web components
|
// plane web components
|
||||||
import { PageDetailsHeaderExtraActions } from "@/plane-web/components/pages";
|
import { PageDetailsHeaderExtraActions } from "@/plane-web/components/pages";
|
||||||
|
import { EUserPermissions, EUserPermissionsLevel } from "ee/constants/user-permissions";
|
||||||
|
|
||||||
export interface IPagesHeaderProps {
|
export interface IPagesHeaderProps {
|
||||||
showButton?: boolean;
|
showButton?: boolean;
|
||||||
|
|
@ -32,10 +33,17 @@ export const PageDetailsHeader = observer(() => {
|
||||||
// store hooks
|
// store hooks
|
||||||
const { currentProjectDetails, loader } = useProject();
|
const { currentProjectDetails, loader } = useProject();
|
||||||
const page = usePage(pageId?.toString() ?? "");
|
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
|
// use platform
|
||||||
const { isMobile } = usePlatformOS();
|
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) => {
|
const handlePageLogoUpdate = async (data: TLogoProps) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
updatePageLogo(data)
|
updatePageLogo(data)
|
||||||
|
|
@ -144,6 +152,7 @@ export const PageDetailsHeader = observer(() => {
|
||||||
? EmojiIconPickerTypes.EMOJI
|
? EmojiIconPickerTypes.EMOJI
|
||||||
: EmojiIconPickerTypes.ICON
|
: EmojiIconPickerTypes.ICON
|
||||||
}
|
}
|
||||||
|
disabled={!isEditable}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Tooltip tooltipContent={pageTitle} position="bottom" isMobile={isMobile}>
|
<Tooltip tooltipContent={pageTitle} position="bottom" isMobile={isMobile}>
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export const PagesListHeader = observer(() => {
|
||||||
const { setTrackElement } = useEventTracker();
|
const { setTrackElement } = useEventTracker();
|
||||||
|
|
||||||
const canUserCreatePage = allowPermissions(
|
const canUserCreatePage = allowPermissions(
|
||||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
[EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST],
|
||||||
EUserPermissionsLevel.PROJECT
|
EUserPermissionsLevel.PROJECT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue