|
@@ -10,7 +10,7 @@ import type {
|
|
|
IDataWithMeta, IPageInfoForEntity, IPagePopulatedToShowRevision, IUserHasId,
|
|
IDataWithMeta, IPageInfoForEntity, IPagePopulatedToShowRevision, IUserHasId,
|
|
|
} from '@growi/core';
|
|
} from '@growi/core';
|
|
|
import ExtensibleCustomError from 'extensible-custom-error';
|
|
import ExtensibleCustomError from 'extensible-custom-error';
|
|
|
-import {
|
|
|
|
|
|
|
+import type {
|
|
|
GetServerSideProps, GetServerSidePropsContext,
|
|
GetServerSideProps, GetServerSidePropsContext,
|
|
|
} from 'next';
|
|
} from 'next';
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
|
@@ -31,39 +31,36 @@ import type { IUserUISettings } from '~/interfaces/user-ui-settings';
|
|
|
import type { PageModel, PageDocument } from '~/server/models/page';
|
|
import type { PageModel, PageDocument } from '~/server/models/page';
|
|
|
import type { PageRedirectModel } from '~/server/models/page-redirect';
|
|
import type { PageRedirectModel } from '~/server/models/page-redirect';
|
|
|
import type { UserUISettingsModel } from '~/server/models/user-ui-settings';
|
|
import type { UserUISettingsModel } from '~/server/models/user-ui-settings';
|
|
|
|
|
+import {
|
|
|
|
|
+ useCurrentUser,
|
|
|
|
|
+ useIsLatestRevision,
|
|
|
|
|
+ useIsForbidden, useIsNotFound, useIsSharedUser,
|
|
|
|
|
+ useIsEnabledStaleNotification, useIsIdenticalPath,
|
|
|
|
|
+ useIsSearchServiceConfigured, useIsSearchServiceReachable, useDisableLinkSharing,
|
|
|
|
|
+ useDrawioUri, useHackmdUri, useDefaultIndentSize, useIsIndentSizeForced,
|
|
|
|
|
+ useIsAclEnabled, useIsSearchPage, useTemplateTagData, useTemplateBodyData, useIsEnabledAttachTitleHeader,
|
|
|
|
|
+ useCsrfToken, useIsSearchScopeChildrenAsDefault, useCurrentPageId, useCurrentPathname,
|
|
|
|
|
+ useIsSlackConfigured, useRendererConfig,
|
|
|
|
|
+ useEditorConfig, useIsAllReplyShown, useIsUploadableFile, useIsUploadableImage, useIsContainerFluid, useIsNotCreatable,
|
|
|
|
|
+} from '~/stores/context';
|
|
|
import { useEditingMarkdown } from '~/stores/editor';
|
|
import { useEditingMarkdown } from '~/stores/editor';
|
|
|
import { useHasDraftOnHackmd, usePageIdOnHackmd, useRevisionIdHackmdSynced } from '~/stores/hackmd';
|
|
import { useHasDraftOnHackmd, usePageIdOnHackmd, useRevisionIdHackmdSynced } from '~/stores/hackmd';
|
|
|
import { useSWRxCurrentPage, useSWRxIsGrantNormalized } from '~/stores/page';
|
|
import { useSWRxCurrentPage, useSWRxIsGrantNormalized } from '~/stores/page';
|
|
|
import { useRedirectFrom } from '~/stores/page-redirect';
|
|
import { useRedirectFrom } from '~/stores/page-redirect';
|
|
|
import { useRemoteRevisionId } from '~/stores/remote-latest-page';
|
|
import { useRemoteRevisionId } from '~/stores/remote-latest-page';
|
|
|
-import {
|
|
|
|
|
- useSelectedGrant,
|
|
|
|
|
- usePreferDrawerModeByUser, usePreferDrawerModeOnEditByUser, useSidebarCollapsed, useCurrentSidebarContents, useCurrentProductNavWidth,
|
|
|
|
|
-} from '~/stores/ui';
|
|
|
|
|
|
|
+import { useSelectedGrant } from '~/stores/ui';
|
|
|
import { useSetupGlobalSocket, useSetupGlobalSocketForPage } from '~/stores/websocket';
|
|
import { useSetupGlobalSocket, useSetupGlobalSocketForPage } from '~/stores/websocket';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
-import { DescendantsPageListModal } from '../components/DescendantsPageListModal';
|
|
|
|
|
import { BasicLayout } from '../components/Layout/BasicLayout';
|
|
import { BasicLayout } from '../components/Layout/BasicLayout';
|
|
|
import GrowiContextualSubNavigationSubstance from '../components/Navbar/GrowiContextualSubNavigation';
|
|
import GrowiContextualSubNavigationSubstance from '../components/Navbar/GrowiContextualSubNavigation';
|
|
|
import type { GrowiSubNavigationSwitcherProps } from '../components/Navbar/GrowiSubNavigationSwitcher';
|
|
import type { GrowiSubNavigationSwitcherProps } from '../components/Navbar/GrowiSubNavigationSwitcher';
|
|
|
import { DisplaySwitcher } from '../components/Page/DisplaySwitcher';
|
|
import { DisplaySwitcher } from '../components/Page/DisplaySwitcher';
|
|
|
-import {
|
|
|
|
|
- useCurrentUser,
|
|
|
|
|
- useIsLatestRevision,
|
|
|
|
|
- useIsForbidden, useIsNotFound, useIsSharedUser,
|
|
|
|
|
- useIsEnabledStaleNotification, useIsIdenticalPath,
|
|
|
|
|
- useIsSearchServiceConfigured, useIsSearchServiceReachable, useDisableLinkSharing,
|
|
|
|
|
- useDrawioUri, useHackmdUri, useDefaultIndentSize, useIsIndentSizeForced,
|
|
|
|
|
- useIsAclEnabled, useIsSearchPage, useTemplateTagData, useTemplateBodyData, useIsEnabledAttachTitleHeader,
|
|
|
|
|
- useCsrfToken, useIsSearchScopeChildrenAsDefault, useCurrentPageId, useCurrentPathname,
|
|
|
|
|
- useIsSlackConfigured, useRendererConfig,
|
|
|
|
|
- useEditorConfig, useIsAllReplyShown, useIsUploadableFile, useIsUploadableImage, useIsContainerFluid, useIsNotCreatable,
|
|
|
|
|
-} from '../stores/context';
|
|
|
|
|
|
|
|
|
|
-import { NextPageWithLayout } from './_app.page';
|
|
|
|
|
|
|
+import type { NextPageWithLayout } from './_app.page';
|
|
|
|
|
+import type { CommonProps } from './utils/commons';
|
|
|
import {
|
|
import {
|
|
|
- CommonProps, getNextI18NextConfig, getServerSideCommonProps, generateCustomTitleForPage, useInitSidebarConfig,
|
|
|
|
|
|
|
+ getNextI18NextConfig, getServerSideCommonProps, generateCustomTitleForPage, useInitSidebarConfig,
|
|
|
} from './utils/commons';
|
|
} from './utils/commons';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -73,6 +70,7 @@ declare global {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+const DescendantsPageListModal = dynamic(() => import('../components/DescendantsPageListModal').then(mod => mod.DescendantsPageListModal), { ssr: false });
|
|
|
const UnsavedAlertDialog = dynamic(() => import('../components/UnsavedAlertDialog'), { ssr: false });
|
|
const UnsavedAlertDialog = dynamic(() => import('../components/UnsavedAlertDialog'), { ssr: false });
|
|
|
const GrowiSubNavigationSwitcher = dynamic<GrowiSubNavigationSwitcherProps>(() => import('../components/Navbar/GrowiSubNavigationSwitcher')
|
|
const GrowiSubNavigationSwitcher = dynamic<GrowiSubNavigationSwitcherProps>(() => import('../components/Navbar/GrowiSubNavigationSwitcher')
|
|
|
.then(mod => mod.GrowiSubNavigationSwitcher), { ssr: false });
|
|
.then(mod => mod.GrowiSubNavigationSwitcher), { ssr: false });
|
|
@@ -185,16 +183,15 @@ type Props = CommonProps & {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
- // const { t } = useTranslation();
|
|
|
|
|
- const router = useRouter();
|
|
|
|
|
-
|
|
|
|
|
- const { data: currentUser } = useCurrentUser(props.currentUser ?? null);
|
|
|
|
|
-
|
|
|
|
|
// register global EventEmitter
|
|
// register global EventEmitter
|
|
|
if (isClient() && window.globalEmitter == null) {
|
|
if (isClient() && window.globalEmitter == null) {
|
|
|
window.globalEmitter = new EventEmitter();
|
|
window.globalEmitter = new EventEmitter();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const router = useRouter();
|
|
|
|
|
+
|
|
|
|
|
+ useCurrentUser(props.currentUser ?? null);
|
|
|
|
|
+
|
|
|
// commons
|
|
// commons
|
|
|
useEditorConfig(props.editorConfig);
|
|
useEditorConfig(props.editorConfig);
|
|
|
useCsrfToken(props.csrfToken);
|
|
useCsrfToken(props.csrfToken);
|
|
@@ -241,7 +238,7 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
useIsUploadableFile(props.editorConfig.upload.isUploadableFile);
|
|
useIsUploadableFile(props.editorConfig.upload.isUploadableFile);
|
|
|
useIsUploadableImage(props.editorConfig.upload.isUploadableImage);
|
|
useIsUploadableImage(props.editorConfig.upload.isUploadableImage);
|
|
|
|
|
|
|
|
- const { pageWithMeta, userUISettings } = props;
|
|
|
|
|
|
|
+ const { pageWithMeta } = props;
|
|
|
|
|
|
|
|
const pageId = pageWithMeta?.data._id;
|
|
const pageId = pageWithMeta?.data._id;
|
|
|
const pagePath = pageWithMeta?.data.path ?? props.currentPathname;
|
|
const pagePath = pageWithMeta?.data.path ?? props.currentPathname;
|
|
@@ -466,9 +463,9 @@ async function injectUserUISettings(context: GetServerSidePropsContext, props: P
|
|
|
const { user } = req;
|
|
const { user } = req;
|
|
|
const UserUISettings = mongooseModel('UserUISettings') as UserUISettingsModel;
|
|
const UserUISettings = mongooseModel('UserUISettings') as UserUISettingsModel;
|
|
|
|
|
|
|
|
- const userUISettings = user == null ? null : await UserUISettings.findOne({ user: user._id }).exec();
|
|
|
|
|
|
|
+ const userUISettings = user == null ? req.session.uiSettings : await UserUISettings.findOne({ user: user._id }).exec();
|
|
|
if (userUISettings != null) {
|
|
if (userUISettings != null) {
|
|
|
- props.userUISettings = userUISettings.toObject();
|
|
|
|
|
|
|
+ props.userUISettings = userUISettings.toObject?.() ?? userUISettings;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -530,7 +527,7 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
const { crowi } = req;
|
|
const { crowi } = req;
|
|
|
const {
|
|
const {
|
|
|
- appService, searchService, configManager, aclService, slackNotificationService, mailService,
|
|
|
|
|
|
|
+ searchService, configManager, aclService,
|
|
|
} = crowi;
|
|
} = crowi;
|
|
|
|
|
|
|
|
props.isSearchServiceConfigured = searchService.isConfigured;
|
|
props.isSearchServiceConfigured = searchService.isConfigured;
|