mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 05:21:14 +02:00
[WEB-3687] fix: teamspaces tab removed for guests + wiki pages restricted for guests (#2812)
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
// layouts
|
||||
import { useParams } from "next/navigation";
|
||||
// components
|
||||
import { EUserPermissions } from "@plane/constants";
|
||||
import { StickyActionBar } from "@/components/stickies";
|
||||
// wrappers
|
||||
import WorkspaceAccessWrapper from "@/layouts/access/workspace-wrapper";
|
||||
import { AuthenticationWrapper } from "@/lib/wrappers";
|
||||
// plane web components
|
||||
import { PagesAppCommandPalette } from "@/plane-web/components/command-palette";
|
||||
@@ -29,7 +31,10 @@ export default function WorkspacePagesLayout({ children }: { children: React.Rea
|
||||
flag="WORKSPACE_PAGES"
|
||||
fallback={<WorkspacePagesUpgrade />}
|
||||
>
|
||||
<>
|
||||
<WorkspaceAccessWrapper
|
||||
pageKey="pages"
|
||||
allowedPermissions={[EUserPermissions.ADMIN, EUserPermissions.MEMBER]}
|
||||
>
|
||||
<PagesAppCommandPalette />
|
||||
<div className="relative flex h-full w-full overflow-hidden">
|
||||
<PagesAppSidebar />
|
||||
@@ -41,7 +46,7 @@ export default function WorkspacePagesLayout({ children }: { children: React.Rea
|
||||
<PiChatFloatingBot />
|
||||
</FloatingActionsRoot>
|
||||
</div>
|
||||
</>
|
||||
</WorkspaceAccessWrapper>
|
||||
</WithFeatureFlagHOC>
|
||||
</WorkspaceAuthWrapper>
|
||||
</AuthenticationWrapper>
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
import { useParams } from "next/navigation";
|
||||
import { EUserPermissions, EUserPermissionsLevel } from "@plane/constants";
|
||||
import { NotAuthorizedView } from "@/components/auth-screens";
|
||||
import { useUserPermissions } from "@/hooks/store";
|
||||
|
||||
interface IWorkspaceAuthWrapper {
|
||||
children: React.ReactNode;
|
||||
pageKey: string;
|
||||
allowedPermissions?: EUserPermissions[];
|
||||
}
|
||||
|
||||
const WorkspaceAccessWrapper = ({ children, ...props }: IWorkspaceAuthWrapper) => {
|
||||
const { pageKey } = props;
|
||||
const { pageKey, allowedPermissions } = props;
|
||||
// router
|
||||
const { workspaceSlug } = useParams();
|
||||
// store
|
||||
const { hasPageAccess } = useUserPermissions();
|
||||
const { hasPageAccess, allowPermissions } = useUserPermissions();
|
||||
// derived values
|
||||
const isAuthorized = hasPageAccess(workspaceSlug?.toString() ?? "", pageKey);
|
||||
const isAuthorized = allowedPermissions
|
||||
? allowPermissions(allowedPermissions, EUserPermissionsLevel.WORKSPACE, workspaceSlug?.toString())
|
||||
: hasPageAccess(workspaceSlug?.toString() ?? "", pageKey);
|
||||
// render
|
||||
if (!isAuthorized) return <NotAuthorizedView />;
|
||||
return <>{children}</>;
|
||||
|
||||
@@ -32,12 +32,14 @@ export const SidebarTeamsList = observer(() => {
|
||||
const { toggleSidebar, sidebarCollapsed } = useAppTheme();
|
||||
const { allowPermissions } = useUserPermissions();
|
||||
const { toggleCreateTeamspaceModal } = useCommandPalette();
|
||||
const { hasPageAccess } = useUserPermissions();
|
||||
const { joinedTeamSpaceIds, isTeamspacesFeatureEnabled, getTeamspaceById } = useTeamspaces();
|
||||
// local storage
|
||||
const { setValue: toggleTeamMenu, storedValue } = useLocalStorage<boolean>("is_teams_list_open", true);
|
||||
// derived values
|
||||
const isTeamspaceListItemOpen = !!storedValue;
|
||||
const isAdmin = allowPermissions([EUserWorkspaceRoles.ADMIN], EUserPermissionsLevel.WORKSPACE);
|
||||
const isAuthorized = hasPageAccess(workspaceSlug?.toString() ?? "", "team_spaces");
|
||||
|
||||
const handleLinkClick = () => {
|
||||
if (window.innerWidth < 768) {
|
||||
@@ -52,6 +54,8 @@ export const SidebarTeamsList = observer(() => {
|
||||
// Return if teamspaces are not enabled or available
|
||||
if (!isTeamspacesFeatureEnabled || joinedTeamSpaceIds.length === 0) return null;
|
||||
|
||||
if (!isAuthorized) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Disclosure as="div" defaultOpen>
|
||||
|
||||
Reference in New Issue
Block a user