mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 20:02:38 +10:00
fix: hide trash from can view permission (#1445)
This commit is contained in:
@ -34,7 +34,7 @@ import { useTrackOrigin } from "@/hooks/use-track-origin";
|
|||||||
import SpacesPage from "@/pages/spaces/spaces.tsx";
|
import SpacesPage from "@/pages/spaces/spaces.tsx";
|
||||||
import { MfaChallengePage } from "@/ee/mfa/pages/mfa-challenge-page";
|
import { MfaChallengePage } from "@/ee/mfa/pages/mfa-challenge-page";
|
||||||
import { MfaSetupRequiredPage } from "@/ee/mfa/pages/mfa-setup-required-page";
|
import { MfaSetupRequiredPage } from "@/ee/mfa/pages/mfa-setup-required-page";
|
||||||
import SpaceTrash from "@/pages/space/trash.tsx";
|
import SpaceTrash from "@/pages/space/space-trash.tsx";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -50,10 +50,7 @@ export default function App() {
|
|||||||
<Route path={"/forgot-password"} element={<ForgotPassword />} />
|
<Route path={"/forgot-password"} element={<ForgotPassword />} />
|
||||||
<Route path={"/password-reset"} element={<PasswordReset />} />
|
<Route path={"/password-reset"} element={<PasswordReset />} />
|
||||||
<Route path={"/login/mfa"} element={<MfaChallengePage />} />
|
<Route path={"/login/mfa"} element={<MfaChallengePage />} />
|
||||||
<Route
|
<Route path={"/login/mfa/setup"} element={<MfaSetupRequiredPage />} />
|
||||||
path={"/login/mfa/setup"}
|
|
||||||
element={<MfaSetupRequiredPage />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{!isCloud() && (
|
{!isCloud() && (
|
||||||
<Route path={"/setup/register"} element={<SetupWorkspace />} />
|
<Route path={"/setup/register"} element={<SetupWorkspace />} />
|
||||||
|
|||||||
@ -32,7 +32,7 @@ import { UserInfo } from "@/components/common/user-info.tsx";
|
|||||||
import Paginate from "@/components/common/paginate.tsx";
|
import Paginate from "@/components/common/paginate.tsx";
|
||||||
import { usePaginateAndSearch } from "@/hooks/use-paginate-and-search";
|
import { usePaginateAndSearch } from "@/hooks/use-paginate-and-search";
|
||||||
|
|
||||||
export default function SpaceTrash() {
|
export default function Trash() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { spaceSlug } = useParams();
|
const { spaceSlug } = useParams();
|
||||||
const { page, setPage } = usePaginateAndSearch();
|
const { page, setPage } = usePaginateAndSearch();
|
||||||
27
apps/client/src/pages/space/space-trash.tsx
Normal file
27
apps/client/src/pages/space/space-trash.tsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import Trash from "@/features/page/trash/components/trash.tsx";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts";
|
||||||
|
import { useSpaceAbility } from "@/features/space/permissions/use-space-ability.ts";
|
||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
SpaceCaslAction,
|
||||||
|
SpaceCaslSubject,
|
||||||
|
} from "@/features/space/permissions/permissions.type.ts";
|
||||||
|
|
||||||
|
export default function SpaceTrash() {
|
||||||
|
const { spaceSlug } = useParams();
|
||||||
|
const { data: space } = useGetSpaceBySlugQuery(spaceSlug);
|
||||||
|
|
||||||
|
const spaceRules = space?.membership?.permissions;
|
||||||
|
const spaceAbility = useSpaceAbility(spaceRules);
|
||||||
|
|
||||||
|
if (!space) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spaceAbility.cannot(SpaceCaslAction.Manage, SpaceCaslSubject.Page)) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Trash />;
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import { IsOptional, IsString } from 'class-validator';
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class DeletedPageDto {
|
export class DeletedPageDto {
|
||||||
@IsOptional()
|
@IsNotEmpty()
|
||||||
@IsString()
|
@IsString()
|
||||||
spaceId: string;
|
spaceId: string;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ export class PageController {
|
|||||||
deletedPageDto.spaceId,
|
deletedPageDto.spaceId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Page)) {
|
if (ability.cannot(SpaceCaslAction.Manage, SpaceCaslSubject.Page)) {
|
||||||
throw new ForbiddenException();
|
throw new ForbiddenException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user