Browse Source

fix(page): correct parent grant value and restore FixPageGrantAlert visibility

The /page/grant-data endpoint returned parentPageGrant.grant using the
child page's destructured `grant` instead of `parentPage.grant`. When a
child page with grant=RESTRICTED is saved under a parent with another
grant, FixPageGrantModal's getGrantLabel (called unconditionally during
render) threw for grant=2 and the page whited out.

Also restore the inverted condition in FixPageGrantAlert that was
introduced by an earlier refactor, so the alert appears again when
isGrantNormalized is false.

Fixes #9315

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Yuki Takei 4 days ago
parent
commit
e832016cb8

+ 2 - 1
apps/app/src/components/PageView/PageAlerts/FixPageGrantAlert/FixPageGrantAlert.tsx

@@ -71,7 +71,8 @@ export const FixPageGrantAlert = (): JSX.Element => {
   if (
     pageId == null ||
     !hasParent ||
-    !dataIsGrantNormalized?.isGrantNormalized
+    dataIsGrantNormalized?.isGrantNormalized == null ||
+    dataIsGrantNormalized.isGrantNormalized
   ) {
     // biome-ignore lint/complexity/noUselessFragments: ignore
     return <></>;

+ 1 - 1
apps/app/src/server/routes/apiv3/page/index.ts

@@ -606,7 +606,7 @@ module.exports = (crowi: Crowi) => {
       const parentPageGroupGrantData =
         await pageGrantService.getPageGroupGrantData(parentPage, req.user);
       const parentPageGrant: IPageGrantData = {
-        grant,
+        grant: parentPage.grant,
         groupGrantData: parentPageGroupGrantData,
       };