|
@@ -1,116 +1,220 @@
|
|
|
-import type { ReactNode, JSX } from 'react';
|
|
|
|
|
-import React, { useEffect } from 'react';
|
|
|
|
|
-
|
|
|
|
|
-import EventEmitter from 'events';
|
|
|
|
|
-
|
|
|
|
|
-import { isIPageInfo } from '@growi/core';
|
|
|
|
|
|
|
+import type React from 'react';
|
|
|
|
|
+import type { JSX, ReactNode } from 'react';
|
|
|
|
|
+import { useEffect } from 'react';
|
|
|
|
|
+import type { GetServerSideProps, GetServerSidePropsContext } from 'next';
|
|
|
|
|
+import dynamic from 'next/dynamic';
|
|
|
|
|
+import Head from 'next/head';
|
|
|
|
|
+import { useRouter } from 'next/router';
|
|
|
import type {
|
|
import type {
|
|
|
- IDataWithMeta, IPageInfo, IPagePopulatedToShowRevision,
|
|
|
|
|
|
|
+ IDataWithMeta,
|
|
|
|
|
+ IPageInfo,
|
|
|
|
|
+ IPagePopulatedToShowRevision,
|
|
|
} from '@growi/core';
|
|
} from '@growi/core';
|
|
|
-import {
|
|
|
|
|
- isClient, pagePathUtils, pathUtils,
|
|
|
|
|
-} from '@growi/core/dist/utils';
|
|
|
|
|
|
|
+import { isIPageInfo } from '@growi/core';
|
|
|
|
|
+import { isClient, pagePathUtils, pathUtils } from '@growi/core/dist/utils';
|
|
|
|
|
+import EventEmitter from 'events';
|
|
|
import ExtensibleCustomError from 'extensible-custom-error';
|
|
import ExtensibleCustomError from 'extensible-custom-error';
|
|
|
-import type {
|
|
|
|
|
- GetServerSideProps, GetServerSidePropsContext,
|
|
|
|
|
-} from 'next';
|
|
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
|
|
-import dynamic from 'next/dynamic';
|
|
|
|
|
-import Head from 'next/head';
|
|
|
|
|
-import { useRouter } from 'next/router';
|
|
|
|
|
import superjson from 'superjson';
|
|
import superjson from 'superjson';
|
|
|
|
|
|
|
|
import { BasicLayout } from '~/components/Layout/BasicLayout';
|
|
import { BasicLayout } from '~/components/Layout/BasicLayout';
|
|
|
import { PageView } from '~/components/PageView/PageView';
|
|
import { PageView } from '~/components/PageView/PageView';
|
|
|
import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript';
|
|
import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript';
|
|
|
-import { SupportedAction, type SupportedActionType } from '~/interfaces/activity';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ SupportedAction,
|
|
|
|
|
+ type SupportedActionType,
|
|
|
|
|
+} from '~/interfaces/activity';
|
|
|
import type { CrowiRequest } from '~/interfaces/crowi-request';
|
|
import type { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
import { RegistrationMode } from '~/interfaces/registration-mode';
|
|
import { RegistrationMode } from '~/interfaces/registration-mode';
|
|
|
import type { RendererConfig } from '~/interfaces/services/renderer';
|
|
import type { RendererConfig } from '~/interfaces/services/renderer';
|
|
|
import type { ISidebarConfig } from '~/interfaces/sidebar-config';
|
|
import type { ISidebarConfig } from '~/interfaces/sidebar-config';
|
|
|
import type { CurrentPageYjsData } from '~/interfaces/yjs';
|
|
import type { CurrentPageYjsData } from '~/interfaces/yjs';
|
|
|
-import type { PageModel, PageDocument } from '~/server/models/page';
|
|
|
|
|
|
|
+import type { PageDocument, PageModel } from '~/server/models/page';
|
|
|
import type { PageRedirectModel } from '~/server/models/page-redirect';
|
|
import type { PageRedirectModel } from '~/server/models/page-redirect';
|
|
|
import { useEditorModeClassName } from '~/services/layout/use-editor-mode-class-name';
|
|
import { useEditorModeClassName } from '~/services/layout/use-editor-mode-class-name';
|
|
|
|
|
+import { useEditingMarkdown } from '~/stores/editor';
|
|
|
import {
|
|
import {
|
|
|
|
|
+ useCurrentPageId,
|
|
|
|
|
+ useIsLatestRevision,
|
|
|
|
|
+ useIsNotFound,
|
|
|
|
|
+ useSWRMUTxCurrentPage,
|
|
|
|
|
+ useSWRxCurrentPage,
|
|
|
|
|
+ useTemplateBodyData,
|
|
|
|
|
+ useTemplateTagData,
|
|
|
|
|
+} from '~/stores/page';
|
|
|
|
|
+import { useRedirectFrom } from '~/stores/page-redirect';
|
|
|
|
|
+import { useRemoteRevisionId } from '~/stores/remote-latest-page';
|
|
|
|
|
+import {
|
|
|
|
|
+ useSetupGlobalSocket,
|
|
|
|
|
+ useSetupGlobalSocketForPage,
|
|
|
|
|
+} from '~/stores/websocket';
|
|
|
|
|
+import {
|
|
|
|
|
+ useCurrentPageYjsData,
|
|
|
|
|
+ useSWRMUTxCurrentPageYjsData,
|
|
|
|
|
+} from '~/stores/yjs';
|
|
|
|
|
+import {
|
|
|
|
|
+ useCsrfToken,
|
|
|
|
|
+ useCurrentPathname,
|
|
|
useCurrentUser,
|
|
useCurrentUser,
|
|
|
- useIsForbidden, useIsSharedUser,
|
|
|
|
|
- useIsEnabledStaleNotification, useIsIdenticalPath,
|
|
|
|
|
- useIsSearchServiceConfigured, useIsSearchServiceReachable, useDisableLinkSharing,
|
|
|
|
|
- useDefaultIndentSize, useIsIndentSizeForced,
|
|
|
|
|
- useIsAclEnabled, useIsSearchPage, useIsEnabledAttachTitleHeader,
|
|
|
|
|
- useCsrfToken, useIsSearchScopeChildrenAsDefault, useIsEnabledMarp, useCurrentPathname,
|
|
|
|
|
- useIsSlackConfigured, useRendererConfig, useGrowiCloudUri,
|
|
|
|
|
- useIsAllReplyShown, useShowPageSideAuthors, useIsContainerFluid, useIsNotCreatable,
|
|
|
|
|
- useIsUploadAllFileAllowed, useIsUploadEnabled, useIsBulkExportPagesEnabled,
|
|
|
|
|
|
|
+ useDefaultIndentSize,
|
|
|
|
|
+ useDisableLinkSharing,
|
|
|
useElasticsearchMaxBodyLengthToIndex,
|
|
useElasticsearchMaxBodyLengthToIndex,
|
|
|
|
|
+ useGrowiCloudUri,
|
|
|
|
|
+ useIsAclEnabled,
|
|
|
|
|
+ useIsAiEnabled,
|
|
|
|
|
+ useIsAllReplyShown,
|
|
|
|
|
+ useIsBulkExportPagesEnabled,
|
|
|
|
|
+ useIsContainerFluid,
|
|
|
|
|
+ useIsEnabledAttachTitleHeader,
|
|
|
|
|
+ useIsEnabledMarp,
|
|
|
|
|
+ useIsEnabledStaleNotification,
|
|
|
|
|
+ useIsForbidden,
|
|
|
|
|
+ useIsGuestUser,
|
|
|
|
|
+ useIsIdenticalPath,
|
|
|
|
|
+ useIsIndentSizeForced,
|
|
|
useIsLocalAccountRegistrationEnabled,
|
|
useIsLocalAccountRegistrationEnabled,
|
|
|
- useIsRomUserAllowedToComment,
|
|
|
|
|
|
|
+ useIsNotCreatable,
|
|
|
useIsPdfBulkExportEnabled,
|
|
useIsPdfBulkExportEnabled,
|
|
|
- useIsAiEnabled, useLimitLearnablePageCountPerAssistant, useIsUsersHomepageDeletionEnabled, useIsGuestUser,
|
|
|
|
|
|
|
+ useIsRomUserAllowedToComment,
|
|
|
|
|
+ useIsSearchPage,
|
|
|
|
|
+ useIsSearchScopeChildrenAsDefault,
|
|
|
|
|
+ useIsSearchServiceConfigured,
|
|
|
|
|
+ useIsSearchServiceReachable,
|
|
|
|
|
+ useIsSharedUser,
|
|
|
|
|
+ useIsSlackConfigured,
|
|
|
|
|
+ useIsUploadAllFileAllowed,
|
|
|
|
|
+ useIsUploadEnabled,
|
|
|
|
|
+ useIsUsersHomepageDeletionEnabled,
|
|
|
|
|
+ useLimitLearnablePageCountPerAssistant,
|
|
|
|
|
+ useRendererConfig,
|
|
|
|
|
+ useShowPageSideAuthors,
|
|
|
} from '~/stores-universal/context';
|
|
} from '~/stores-universal/context';
|
|
|
-import { useEditingMarkdown } from '~/stores/editor';
|
|
|
|
|
-import {
|
|
|
|
|
- useSWRxCurrentPage, useSWRMUTxCurrentPage, useCurrentPageId,
|
|
|
|
|
- useIsNotFound, useIsLatestRevision, useTemplateTagData, useTemplateBodyData,
|
|
|
|
|
-} from '~/stores/page';
|
|
|
|
|
-import { useRedirectFrom } from '~/stores/page-redirect';
|
|
|
|
|
-import { useRemoteRevisionId } from '~/stores/remote-latest-page';
|
|
|
|
|
-import { useSetupGlobalSocket, useSetupGlobalSocketForPage } from '~/stores/websocket';
|
|
|
|
|
-import { useCurrentPageYjsData, useSWRMUTxCurrentPageYjsData } from '~/stores/yjs';
|
|
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import type { NextPageWithLayout } from './_app.page';
|
|
import type { NextPageWithLayout } from './_app.page';
|
|
|
import type { CommonProps } from './utils/commons';
|
|
import type { CommonProps } from './utils/commons';
|
|
|
import {
|
|
import {
|
|
|
- getNextI18NextConfig, getServerSideCommonProps, generateCustomTitleForPage, useInitSidebarConfig, skipSSR, addActivity,
|
|
|
|
|
|
|
+ addActivity,
|
|
|
|
|
+ generateCustomTitleForPage,
|
|
|
|
|
+ getNextI18NextConfig,
|
|
|
|
|
+ getServerSideCommonProps,
|
|
|
|
|
+ skipSSR,
|
|
|
|
|
+ useInitSidebarConfig,
|
|
|
} from './utils/commons';
|
|
} from './utils/commons';
|
|
|
|
|
|
|
|
-
|
|
|
|
|
declare global {
|
|
declare global {
|
|
|
// eslint-disable-next-line vars-on-top, no-var
|
|
// eslint-disable-next-line vars-on-top, no-var
|
|
|
var globalEmitter: EventEmitter;
|
|
var globalEmitter: EventEmitter;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const GrowiContextualSubNavigationSubstance = dynamic(
|
|
|
|
|
+ () => import('~/client/components/Navbar/GrowiContextualSubNavigation'),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
-const GrowiContextualSubNavigationSubstance = dynamic(() => import('~/client/components/Navbar/GrowiContextualSubNavigation'), { ssr: false });
|
|
|
|
|
-
|
|
|
|
|
-const GrowiPluginsActivator = dynamic(() => import('~/features/growi-plugin/client/components').then(mod => mod.GrowiPluginsActivator), { ssr: false });
|
|
|
|
|
|
|
+const GrowiPluginsActivator = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/features/growi-plugin/client/components').then(
|
|
|
|
|
+ (mod) => mod.GrowiPluginsActivator,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
-const DisplaySwitcher = dynamic(() => import('~/client/components/Page/DisplaySwitcher').then(mod => mod.DisplaySwitcher), { ssr: false });
|
|
|
|
|
-const PageStatusAlert = dynamic(() => import('~/client/components/PageStatusAlert').then(mod => mod.PageStatusAlert), { ssr: false });
|
|
|
|
|
|
|
+const DisplaySwitcher = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/Page/DisplaySwitcher').then(
|
|
|
|
|
+ (mod) => mod.DisplaySwitcher,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
+const PageStatusAlert = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/PageStatusAlert').then(
|
|
|
|
|
+ (mod) => mod.PageStatusAlert,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
-const UnsavedAlertDialog = dynamic(() => import('~/client/components/UnsavedAlertDialog'), { ssr: false });
|
|
|
|
|
|
|
+const UnsavedAlertDialog = dynamic(
|
|
|
|
|
+ () => import('~/client/components/UnsavedAlertDialog'),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
const DescendantsPageListModal = dynamic(
|
|
const DescendantsPageListModal = dynamic(
|
|
|
- () => import('~/client/components/DescendantsPageListModal').then(mod => mod.DescendantsPageListModal),
|
|
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/DescendantsPageListModal').then(
|
|
|
|
|
+ (mod) => mod.DescendantsPageListModal,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
+const DrawioModal = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/PageEditor/DrawioModal').then(
|
|
|
|
|
+ (mod) => mod.DrawioModal,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
+const HandsontableModal = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/PageEditor/HandsontableModal').then(
|
|
|
|
|
+ (mod) => mod.HandsontableModal,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
+const TemplateModal = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/TemplateModal').then(
|
|
|
|
|
+ (mod) => mod.TemplateModal,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
+const LinkEditModal = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/PageEditor/LinkEditModal').then(
|
|
|
|
|
+ (mod) => mod.LinkEditModal,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
+const TagEditModal = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/PageTags/TagEditModal').then(
|
|
|
|
|
+ (mod) => mod.TagEditModal,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
+const ConflictDiffModal = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/PageEditor/ConflictDiffModal').then(
|
|
|
|
|
+ (mod) => mod.ConflictDiffModal,
|
|
|
|
|
+ ),
|
|
|
{ ssr: false },
|
|
{ ssr: false },
|
|
|
);
|
|
);
|
|
|
-const DrawioModal = dynamic(() => import('~/client/components/PageEditor/DrawioModal').then(mod => mod.DrawioModal), { ssr: false });
|
|
|
|
|
-const HandsontableModal = dynamic(() => import('~/client/components/PageEditor/HandsontableModal').then(mod => mod.HandsontableModal), { ssr: false });
|
|
|
|
|
-const TemplateModal = dynamic(() => import('~/client/components/TemplateModal').then(mod => mod.TemplateModal), { ssr: false });
|
|
|
|
|
-const LinkEditModal = dynamic(() => import('~/client/components/PageEditor/LinkEditModal').then(mod => mod.LinkEditModal), { ssr: false });
|
|
|
|
|
-const TagEditModal = dynamic(() => import('~/client/components/PageTags/TagEditModal').then(mod => mod.TagEditModal), { ssr: false });
|
|
|
|
|
-const ConflictDiffModal = dynamic(() => import('~/client/components/PageEditor/ConflictDiffModal').then(mod => mod.ConflictDiffModal), { ssr: false });
|
|
|
|
|
-
|
|
|
|
|
-const EditablePageEffects = dynamic(() => import('~/client/components/Page/EditablePageEffects').then(mod => mod.EditablePageEffects), { ssr: false });
|
|
|
|
|
|
|
|
|
|
|
|
+const EditablePageEffects = dynamic(
|
|
|
|
|
+ () =>
|
|
|
|
|
+ import('~/client/components/Page/EditablePageEffects').then(
|
|
|
|
|
+ (mod) => mod.EditablePageEffects,
|
|
|
|
|
+ ),
|
|
|
|
|
+ { ssr: false },
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:pages:all');
|
|
const logger = loggerFactory('growi:pages:all');
|
|
|
|
|
|
|
|
-const {
|
|
|
|
|
- isPermalink: _isPermalink, isCreatablePage,
|
|
|
|
|
-} = pagePathUtils;
|
|
|
|
|
|
|
+const { isPermalink: _isPermalink, isCreatablePage } = pagePathUtils;
|
|
|
const { removeHeadingSlash } = pathUtils;
|
|
const { removeHeadingSlash } = pathUtils;
|
|
|
|
|
|
|
|
-type IPageToShowRevisionWithMeta = IDataWithMeta<IPagePopulatedToShowRevision & PageDocument, IPageInfo>;
|
|
|
|
|
|
|
+type IPageToShowRevisionWithMeta = IDataWithMeta<
|
|
|
|
|
+ IPagePopulatedToShowRevision & PageDocument,
|
|
|
|
|
+ IPageInfo
|
|
|
|
|
+>;
|
|
|
type IPageToShowRevisionWithMetaSerialized = IDataWithMeta<string, string>;
|
|
type IPageToShowRevisionWithMetaSerialized = IDataWithMeta<string, string>;
|
|
|
|
|
|
|
|
-superjson.registerCustom<IPageToShowRevisionWithMeta, IPageToShowRevisionWithMetaSerialized>(
|
|
|
|
|
|
|
+superjson.registerCustom<
|
|
|
|
|
+ IPageToShowRevisionWithMeta,
|
|
|
|
|
+ IPageToShowRevisionWithMetaSerialized
|
|
|
|
|
+>(
|
|
|
{
|
|
{
|
|
|
isApplicable: (v): v is IPageToShowRevisionWithMeta => {
|
|
isApplicable: (v): v is IPageToShowRevisionWithMeta => {
|
|
|
- return v?.data != null
|
|
|
|
|
- && v?.data.toObject != null
|
|
|
|
|
- && isIPageInfo(v.meta);
|
|
|
|
|
|
|
+ return v?.data != null && v?.data.toObject != null && isIPageInfo(v.meta);
|
|
|
},
|
|
},
|
|
|
serialize: (v) => {
|
|
serialize: (v) => {
|
|
|
return {
|
|
return {
|
|
@@ -130,76 +234,81 @@ superjson.registerCustom<IPageToShowRevisionWithMeta, IPageToShowRevisionWithMet
|
|
|
|
|
|
|
|
// GrowiContextualSubNavigation for NOT shared page
|
|
// GrowiContextualSubNavigation for NOT shared page
|
|
|
type GrowiContextualSubNavigationProps = {
|
|
type GrowiContextualSubNavigationProps = {
|
|
|
- isLinkSharingDisabled: boolean,
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ isLinkSharingDisabled: boolean;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
-const GrowiContextualSubNavigation = (props: GrowiContextualSubNavigationProps): JSX.Element => {
|
|
|
|
|
|
|
+const GrowiContextualSubNavigation = (
|
|
|
|
|
+ props: GrowiContextualSubNavigationProps,
|
|
|
|
|
+): JSX.Element => {
|
|
|
const { isLinkSharingDisabled } = props;
|
|
const { isLinkSharingDisabled } = props;
|
|
|
const { data: currentPage } = useSWRxCurrentPage();
|
|
const { data: currentPage } = useSWRxCurrentPage();
|
|
|
return (
|
|
return (
|
|
|
- <GrowiContextualSubNavigationSubstance currentPage={currentPage} isLinkSharingDisabled={isLinkSharingDisabled} />
|
|
|
|
|
|
|
+ <GrowiContextualSubNavigationSubstance
|
|
|
|
|
+ currentPage={currentPage}
|
|
|
|
|
+ isLinkSharingDisabled={isLinkSharingDisabled}
|
|
|
|
|
+ />
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
type Props = CommonProps & {
|
|
type Props = CommonProps & {
|
|
|
- pageWithMeta: IPageToShowRevisionWithMeta | null,
|
|
|
|
|
|
|
+ pageWithMeta: IPageToShowRevisionWithMeta | null;
|
|
|
// pageUser?: any,
|
|
// pageUser?: any,
|
|
|
redirectFrom?: string;
|
|
redirectFrom?: string;
|
|
|
|
|
|
|
|
// shareLinkId?: string;
|
|
// shareLinkId?: string;
|
|
|
- isLatestRevision?: boolean,
|
|
|
|
|
|
|
+ isLatestRevision?: boolean;
|
|
|
|
|
|
|
|
- isIdenticalPathPage?: boolean,
|
|
|
|
|
- isForbidden: boolean,
|
|
|
|
|
- isNotFound: boolean,
|
|
|
|
|
- isNotCreatable: boolean,
|
|
|
|
|
|
|
+ isIdenticalPathPage?: boolean;
|
|
|
|
|
+ isForbidden: boolean;
|
|
|
|
|
+ isNotFound: boolean;
|
|
|
|
|
+ isNotCreatable: boolean;
|
|
|
// isAbleToDeleteCompletely: boolean,
|
|
// isAbleToDeleteCompletely: boolean,
|
|
|
|
|
|
|
|
- templateTagData?: string[],
|
|
|
|
|
- templateBodyData?: string,
|
|
|
|
|
|
|
+ templateTagData?: string[];
|
|
|
|
|
+ templateBodyData?: string;
|
|
|
|
|
|
|
|
- isLocalAccountRegistrationEnabled: boolean,
|
|
|
|
|
|
|
+ isLocalAccountRegistrationEnabled: boolean;
|
|
|
|
|
|
|
|
- isSearchServiceConfigured: boolean,
|
|
|
|
|
- isSearchServiceReachable: boolean,
|
|
|
|
|
- isSearchScopeChildrenAsDefault: boolean,
|
|
|
|
|
- elasticsearchMaxBodyLengthToIndex: number,
|
|
|
|
|
- isEnabledMarp: boolean,
|
|
|
|
|
|
|
+ isSearchServiceConfigured: boolean;
|
|
|
|
|
+ isSearchServiceReachable: boolean;
|
|
|
|
|
+ isSearchScopeChildrenAsDefault: boolean;
|
|
|
|
|
+ elasticsearchMaxBodyLengthToIndex: number;
|
|
|
|
|
+ isEnabledMarp: boolean;
|
|
|
|
|
|
|
|
- isRomUserAllowedToComment: boolean,
|
|
|
|
|
|
|
+ isRomUserAllowedToComment: boolean;
|
|
|
|
|
|
|
|
- sidebarConfig: ISidebarConfig,
|
|
|
|
|
|
|
+ sidebarConfig: ISidebarConfig;
|
|
|
|
|
|
|
|
- isSlackConfigured: boolean,
|
|
|
|
|
|
|
+ isSlackConfigured: boolean;
|
|
|
// isMailerSetup: boolean,
|
|
// isMailerSetup: boolean,
|
|
|
- isAclEnabled: boolean,
|
|
|
|
|
|
|
+ isAclEnabled: boolean;
|
|
|
// hasSlackConfig: boolean,
|
|
// hasSlackConfig: boolean,
|
|
|
- drawioUri: string | null,
|
|
|
|
|
|
|
+ drawioUri: string | null;
|
|
|
// highlightJsStyle: string,
|
|
// highlightJsStyle: string,
|
|
|
- isAllReplyShown: boolean,
|
|
|
|
|
- showPageSideAuthors: boolean,
|
|
|
|
|
- isContainerFluid: boolean,
|
|
|
|
|
- isUploadEnabled: boolean,
|
|
|
|
|
- isUploadAllFileAllowed: boolean,
|
|
|
|
|
- isBulkExportPagesEnabled: boolean,
|
|
|
|
|
- isPdfBulkExportEnabled: boolean,
|
|
|
|
|
- isEnabledStaleNotification: boolean,
|
|
|
|
|
- isEnabledAttachTitleHeader: boolean,
|
|
|
|
|
|
|
+ isAllReplyShown: boolean;
|
|
|
|
|
+ showPageSideAuthors: boolean;
|
|
|
|
|
+ isContainerFluid: boolean;
|
|
|
|
|
+ isUploadEnabled: boolean;
|
|
|
|
|
+ isUploadAllFileAllowed: boolean;
|
|
|
|
|
+ isBulkExportPagesEnabled: boolean;
|
|
|
|
|
+ isPdfBulkExportEnabled: boolean;
|
|
|
|
|
+ isEnabledStaleNotification: boolean;
|
|
|
|
|
+ isEnabledAttachTitleHeader: boolean;
|
|
|
// isEnabledLinebreaks: boolean,
|
|
// isEnabledLinebreaks: boolean,
|
|
|
// isEnabledLinebreaksInComments: boolean,
|
|
// isEnabledLinebreaksInComments: boolean,
|
|
|
- adminPreferredIndentSize: number,
|
|
|
|
|
- isIndentSizeForced: boolean,
|
|
|
|
|
- disableLinkSharing: boolean,
|
|
|
|
|
- skipSSR: boolean,
|
|
|
|
|
- ssrMaxRevisionBodyLength: number,
|
|
|
|
|
|
|
+ adminPreferredIndentSize: number;
|
|
|
|
|
+ isIndentSizeForced: boolean;
|
|
|
|
|
+ disableLinkSharing: boolean;
|
|
|
|
|
+ skipSSR: boolean;
|
|
|
|
|
+ ssrMaxRevisionBodyLength: number;
|
|
|
|
|
|
|
|
- yjsData: CurrentPageYjsData,
|
|
|
|
|
|
|
+ yjsData: CurrentPageYjsData;
|
|
|
|
|
|
|
|
- rendererConfig: RendererConfig,
|
|
|
|
|
|
|
+ rendererConfig: RendererConfig;
|
|
|
|
|
|
|
|
- aiEnabled: boolean,
|
|
|
|
|
- limitLearnablePageCountPerAssistant: number,
|
|
|
|
|
- isUsersHomepageDeletionEnabled: boolean,
|
|
|
|
|
|
|
+ aiEnabled: boolean;
|
|
|
|
|
+ limitLearnablePageCountPerAssistant: number;
|
|
|
|
|
+ isUsersHomepageDeletionEnabled: boolean;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
@@ -256,11 +365,12 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
useIsRomUserAllowedToComment(props.isRomUserAllowedToComment);
|
|
useIsRomUserAllowedToComment(props.isRomUserAllowedToComment);
|
|
|
|
|
|
|
|
useIsAiEnabled(props.aiEnabled);
|
|
useIsAiEnabled(props.aiEnabled);
|
|
|
- useLimitLearnablePageCountPerAssistant(props.limitLearnablePageCountPerAssistant);
|
|
|
|
|
|
|
+ useLimitLearnablePageCountPerAssistant(
|
|
|
|
|
+ props.limitLearnablePageCountPerAssistant,
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
useIsUsersHomepageDeletionEnabled(props.isUsersHomepageDeletionEnabled);
|
|
useIsUsersHomepageDeletionEnabled(props.isUsersHomepageDeletionEnabled);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
const { pageWithMeta } = props;
|
|
const { pageWithMeta } = props;
|
|
|
|
|
|
|
|
const pageId = pageWithMeta?.data._id;
|
|
const pageId = pageWithMeta?.data._id;
|
|
@@ -272,10 +382,12 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
const { data: currentPage } = useSWRxCurrentPage(pageWithMeta?.data ?? null); // store initial data
|
|
const { data: currentPage } = useSWRxCurrentPage(pageWithMeta?.data ?? null); // store initial data
|
|
|
|
|
|
|
|
const { trigger: mutateCurrentPage } = useSWRMUTxCurrentPage();
|
|
const { trigger: mutateCurrentPage } = useSWRMUTxCurrentPage();
|
|
|
- const { trigger: mutateCurrentPageYjsDataFromApi } = useSWRMUTxCurrentPageYjsData();
|
|
|
|
|
|
|
+ const { trigger: mutateCurrentPageYjsDataFromApi } =
|
|
|
|
|
+ useSWRMUTxCurrentPageYjsData();
|
|
|
|
|
|
|
|
const { mutate: mutateEditingMarkdown } = useEditingMarkdown();
|
|
const { mutate: mutateEditingMarkdown } = useEditingMarkdown();
|
|
|
- const { data: currentPageId, mutate: mutateCurrentPageId } = useCurrentPageId();
|
|
|
|
|
|
|
+ const { data: currentPageId, mutate: mutateCurrentPageId } =
|
|
|
|
|
+ useCurrentPageId();
|
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
|
|
|
|
|
|
const { mutate: mutateIsNotFound } = useIsNotFound();
|
|
const { mutate: mutateIsNotFound } = useIsNotFound();
|
|
@@ -299,7 +411,7 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (currentPageId != null && revisionId != null && !props.isNotFound) {
|
|
if (currentPageId != null && revisionId != null && !props.isNotFound) {
|
|
|
- const mutatePageData = async() => {
|
|
|
|
|
|
|
+ const mutatePageData = async () => {
|
|
|
const pageData = await mutateCurrentPage();
|
|
const pageData = await mutateCurrentPage();
|
|
|
mutateEditingMarkdown(pageData?.revision?.body);
|
|
mutateEditingMarkdown(pageData?.revision?.body);
|
|
|
};
|
|
};
|
|
@@ -309,24 +421,41 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
mutatePageData();
|
|
mutatePageData();
|
|
|
}
|
|
}
|
|
|
}, [
|
|
}, [
|
|
|
- revisionId, currentPageId,
|
|
|
|
|
- mutateCurrentPage, mutateEditingMarkdown,
|
|
|
|
|
- props.isNotFound, props.skipSSR,
|
|
|
|
|
|
|
+ revisionId,
|
|
|
|
|
+ currentPageId,
|
|
|
|
|
+ mutateCurrentPage,
|
|
|
|
|
+ mutateEditingMarkdown,
|
|
|
|
|
+ props.isNotFound,
|
|
|
|
|
+ props.skipSSR,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
// Load current yjs data
|
|
// Load current yjs data
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- if (!isGuestUser && currentPageId != null && revisionId != null && mutateCurrentPageYjsDataFromApi != null && !props.isNotFound) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ !isGuestUser &&
|
|
|
|
|
+ currentPageId != null &&
|
|
|
|
|
+ revisionId != null &&
|
|
|
|
|
+ mutateCurrentPageYjsDataFromApi != null &&
|
|
|
|
|
+ !props.isNotFound
|
|
|
|
|
+ ) {
|
|
|
mutateCurrentPageYjsDataFromApi();
|
|
mutateCurrentPageYjsDataFromApi();
|
|
|
}
|
|
}
|
|
|
- }, [isGuestUser, currentPageId, mutateCurrentPageYjsDataFromApi, props.isNotFound, revisionId]);
|
|
|
|
|
|
|
+ }, [
|
|
|
|
|
+ isGuestUser,
|
|
|
|
|
+ currentPageId,
|
|
|
|
|
+ mutateCurrentPageYjsDataFromApi,
|
|
|
|
|
+ props.isNotFound,
|
|
|
|
|
+ revisionId,
|
|
|
|
|
+ ]);
|
|
|
|
|
|
|
|
// sync pathname by Shallow Routing https://nextjs.org/docs/routing/shallow-routing
|
|
// sync pathname by Shallow Routing https://nextjs.org/docs/routing/shallow-routing
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
const decodedURI = decodeURI(window.location.pathname);
|
|
const decodedURI = decodeURI(window.location.pathname);
|
|
|
if (isClient() && decodedURI !== props.currentPathname) {
|
|
if (isClient() && decodedURI !== props.currentPathname) {
|
|
|
const { search, hash } = window.location;
|
|
const { search, hash } = window.location;
|
|
|
- router.replace(`${props.currentPathname}${search}${hash}`, undefined, { shallow: true });
|
|
|
|
|
|
|
+ router.replace(`${props.currentPathname}${search}${hash}`, undefined, {
|
|
|
|
|
+ shallow: true,
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}, [props.currentPathname, router]);
|
|
}, [props.currentPathname, router]);
|
|
|
|
|
|
|
@@ -368,7 +497,8 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
|
|
|
|
|
// If the data on the page changes without router.push, pageWithMeta remains old because getServerSideProps() is not executed
|
|
// If the data on the page changes without router.push, pageWithMeta remains old because getServerSideProps() is not executed
|
|
|
// So preferentially take page data from useSWRxCurrentPage
|
|
// So preferentially take page data from useSWRxCurrentPage
|
|
|
- const pagePath = currentPage?.path ?? pageWithMeta?.data.path ?? props.currentPathname;
|
|
|
|
|
|
|
+ const pagePath =
|
|
|
|
|
+ currentPage?.path ?? pageWithMeta?.data.path ?? props.currentPathname;
|
|
|
|
|
|
|
|
const title = generateCustomTitleForPage(props, pagePath);
|
|
const title = generateCustomTitleForPage(props, pagePath);
|
|
|
|
|
|
|
@@ -378,8 +508,9 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
<title>{title}</title>
|
|
<title>{title}</title>
|
|
|
</Head>
|
|
</Head>
|
|
|
<div className="dynamic-layout-root justify-content-between">
|
|
<div className="dynamic-layout-root justify-content-between">
|
|
|
-
|
|
|
|
|
- <GrowiContextualSubNavigation isLinkSharingDisabled={props.disableLinkSharing} />
|
|
|
|
|
|
|
+ <GrowiContextualSubNavigation
|
|
|
|
|
+ isLinkSharingDisabled={props.disableLinkSharing}
|
|
|
|
|
+ />
|
|
|
|
|
|
|
|
<PageView
|
|
<PageView
|
|
|
className="d-edit-none"
|
|
className="d-edit-none"
|
|
@@ -397,15 +528,18 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-const BasicLayoutWithEditor = ({ children }: { children?: ReactNode }): JSX.Element => {
|
|
|
|
|
|
|
+const BasicLayoutWithEditor = ({
|
|
|
|
|
+ children,
|
|
|
|
|
+}: {
|
|
|
|
|
+ children?: ReactNode;
|
|
|
|
|
+}): JSX.Element => {
|
|
|
const editorModeClassName = useEditorModeClassName();
|
|
const editorModeClassName = useEditorModeClassName();
|
|
|
return <BasicLayout className={editorModeClassName}>{children}</BasicLayout>;
|
|
return <BasicLayout className={editorModeClassName}>{children}</BasicLayout>;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
type LayoutProps = Props & {
|
|
type LayoutProps = Props & {
|
|
|
- children?: ReactNode
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ children?: ReactNode;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
const Layout = ({ children, ...props }: LayoutProps): JSX.Element => {
|
|
const Layout = ({ children, ...props }: LayoutProps): JSX.Element => {
|
|
|
// init sidebar config with UserUISettings and sidebarConfig
|
|
// init sidebar config with UserUISettings and sidebarConfig
|
|
@@ -420,9 +554,7 @@ Page.getLayout = function getLayout(page: React.ReactElement<Props>) {
|
|
|
<GrowiPluginsActivator />
|
|
<GrowiPluginsActivator />
|
|
|
<DrawioViewerScript drawioUri={page.props.rendererConfig.drawioUri} />
|
|
<DrawioViewerScript drawioUri={page.props.rendererConfig.drawioUri} />
|
|
|
|
|
|
|
|
- <Layout {...page.props}>
|
|
|
|
|
- {page}
|
|
|
|
|
- </Layout>
|
|
|
|
|
|
|
+ <Layout {...page.props}>{page}</Layout>
|
|
|
<UnsavedAlertDialog />
|
|
<UnsavedAlertDialog />
|
|
|
<DescendantsPageListModal />
|
|
<DescendantsPageListModal />
|
|
|
<DrawioModal />
|
|
<DrawioModal />
|
|
@@ -435,23 +567,25 @@ Page.getLayout = function getLayout(page: React.ReactElement<Props>) {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
function getPageIdFromPathname(currentPathname: string): string | null {
|
|
function getPageIdFromPathname(currentPathname: string): string | null {
|
|
|
- return _isPermalink(currentPathname) ? removeHeadingSlash(currentPathname) : null;
|
|
|
|
|
|
|
+ return _isPermalink(currentPathname)
|
|
|
|
|
+ ? removeHeadingSlash(currentPathname)
|
|
|
|
|
+ : null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class MultiplePagesHitsError extends ExtensibleCustomError {
|
|
class MultiplePagesHitsError extends ExtensibleCustomError {
|
|
|
-
|
|
|
|
|
pagePath: string;
|
|
pagePath: string;
|
|
|
|
|
|
|
|
constructor(pagePath: string) {
|
|
constructor(pagePath: string) {
|
|
|
super(`MultiplePagesHitsError occured by '${pagePath}'`);
|
|
super(`MultiplePagesHitsError occured by '${pagePath}'`);
|
|
|
this.pagePath = pagePath;
|
|
this.pagePath = pagePath;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function injectPageData(context: GetServerSidePropsContext, props: Props): Promise<void> {
|
|
|
|
|
|
|
+async function injectPageData(
|
|
|
|
|
+ context: GetServerSidePropsContext,
|
|
|
|
|
+ props: Props,
|
|
|
|
|
+): Promise<void> {
|
|
|
const { model: mongooseModel } = await import('mongoose');
|
|
const { model: mongooseModel } = await import('mongoose');
|
|
|
|
|
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
@@ -471,7 +605,8 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
|
|
|
|
|
|
|
|
if (!isPermalink) {
|
|
if (!isPermalink) {
|
|
|
// check redirects
|
|
// check redirects
|
|
|
- const chains = await PageRedirect.retrievePageRedirectEndpoints(currentPathname);
|
|
|
|
|
|
|
+ const chains =
|
|
|
|
|
+ await PageRedirect.retrievePageRedirectEndpoints(currentPathname);
|
|
|
if (chains != null) {
|
|
if (chains != null) {
|
|
|
// overwrite currentPathname
|
|
// overwrite currentPathname
|
|
|
currentPathname = chains.end.toPath;
|
|
currentPathname = chains.end.toPath;
|
|
@@ -481,13 +616,23 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// check whether the specified page path hits to multiple pages
|
|
// check whether the specified page path hits to multiple pages
|
|
|
- const count = await Page.countByPathAndViewer(currentPathname, user, null, true);
|
|
|
|
|
|
|
+ const count = await Page.countByPathAndViewer(
|
|
|
|
|
+ currentPathname,
|
|
|
|
|
+ user,
|
|
|
|
|
+ null,
|
|
|
|
|
+ true,
|
|
|
|
|
+ );
|
|
|
if (count > 1) {
|
|
if (count > 1) {
|
|
|
throw new MultiplePagesHitsError(currentPathname);
|
|
throw new MultiplePagesHitsError(currentPathname);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const pageWithMeta = await pageService.findPageAndMetaDataByViewer(pageId, currentPathname, user, true); // includeEmpty = true, isSharedPage = false
|
|
|
|
|
|
|
+ const pageWithMeta = await pageService.findPageAndMetaDataByViewer(
|
|
|
|
|
+ pageId,
|
|
|
|
|
+ currentPathname,
|
|
|
|
|
+ user,
|
|
|
|
|
+ true,
|
|
|
|
|
+ ); // includeEmpty = true, isSharedPage = false
|
|
|
const { data: page, meta } = pageWithMeta ?? {};
|
|
const { data: page, meta } = pageWithMeta ?? {};
|
|
|
|
|
|
|
|
// add user to seen users
|
|
// add user to seen users
|
|
@@ -501,7 +646,9 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
|
|
|
if (page != null) {
|
|
if (page != null) {
|
|
|
page.initLatestRevisionField(revisionId);
|
|
page.initLatestRevisionField(revisionId);
|
|
|
props.isLatestRevision = page.isLatestRevision();
|
|
props.isLatestRevision = page.isLatestRevision();
|
|
|
- const ssrMaxRevisionBodyLength = configManager.getConfig('app:ssrMaxRevisionBodyLength');
|
|
|
|
|
|
|
+ const ssrMaxRevisionBodyLength = configManager.getConfig(
|
|
|
|
|
+ 'app:ssrMaxRevisionBodyLength',
|
|
|
|
|
+ );
|
|
|
props.skipSSR = await skipSSR(page, ssrMaxRevisionBodyLength);
|
|
props.skipSSR = await skipSSR(page, ssrMaxRevisionBodyLength);
|
|
|
const populatedPage = await page.populateDataToShowRevision(props.skipSSR); // shouldExcludeBody = skipSSR
|
|
const populatedPage = await page.populateDataToShowRevision(props.skipSSR); // shouldExcludeBody = skipSSR
|
|
|
|
|
|
|
@@ -512,7 +659,10 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function injectRoutingInformation(context: GetServerSidePropsContext, props: Props): Promise<void> {
|
|
|
|
|
|
|
+async function injectRoutingInformation(
|
|
|
|
|
+ context: GetServerSidePropsContext,
|
|
|
|
|
+ props: Props,
|
|
|
|
|
+): Promise<void> {
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
const { crowi } = req;
|
|
const { crowi } = req;
|
|
|
const Page = crowi.model('Page') as PageModel;
|
|
const Page = crowi.model('Page') as PageModel;
|
|
@@ -525,15 +675,15 @@ async function injectRoutingInformation(context: GetServerSidePropsContext, prop
|
|
|
|
|
|
|
|
if (props.isIdenticalPathPage) {
|
|
if (props.isIdenticalPathPage) {
|
|
|
props.isNotCreatable = true;
|
|
props.isNotCreatable = true;
|
|
|
- }
|
|
|
|
|
- else if (page == null) {
|
|
|
|
|
|
|
+ } else if (page == null) {
|
|
|
props.isNotFound = true;
|
|
props.isNotFound = true;
|
|
|
props.isNotCreatable = !isCreatablePage(currentPathname);
|
|
props.isNotCreatable = !isCreatablePage(currentPathname);
|
|
|
// check the page is forbidden or just does not exist.
|
|
// check the page is forbidden or just does not exist.
|
|
|
- const count = isPermalink ? await Page.count({ _id: pageId }) : await Page.count({ path: currentPathname });
|
|
|
|
|
|
|
+ const count = isPermalink
|
|
|
|
|
+ ? await Page.count({ _id: pageId })
|
|
|
|
|
+ : await Page.count({ path: currentPathname });
|
|
|
props.isForbidden = count > 0;
|
|
props.isForbidden = count > 0;
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
|
|
+ } else {
|
|
|
props.isNotFound = page.isEmpty;
|
|
props.isNotFound = page.isEmpty;
|
|
|
props.isNotCreatable = false;
|
|
props.isNotCreatable = false;
|
|
|
props.isForbidden = false;
|
|
props.isForbidden = false;
|
|
@@ -570,23 +720,40 @@ async function injectRoutingInformation(context: GetServerSidePropsContext, prop
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
-function injectServerConfigurations(context: GetServerSidePropsContext, props: Props): void {
|
|
|
|
|
|
|
+function injectServerConfigurations(
|
|
|
|
|
+ context: GetServerSidePropsContext,
|
|
|
|
|
+ props: Props,
|
|
|
|
|
+): void {
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
const { crowi } = req;
|
|
const { crowi } = req;
|
|
|
const {
|
|
const {
|
|
|
- configManager, searchService, aclService, fileUploadService,
|
|
|
|
|
- slackIntegrationService, passportService,
|
|
|
|
|
|
|
+ configManager,
|
|
|
|
|
+ searchService,
|
|
|
|
|
+ aclService,
|
|
|
|
|
+ fileUploadService,
|
|
|
|
|
+ slackIntegrationService,
|
|
|
|
|
+ passportService,
|
|
|
} = crowi;
|
|
} = crowi;
|
|
|
|
|
|
|
|
props.aiEnabled = configManager.getConfig('app:aiEnabled');
|
|
props.aiEnabled = configManager.getConfig('app:aiEnabled');
|
|
|
- props.limitLearnablePageCountPerAssistant = configManager.getConfig('openai:limitLearnablePageCountPerAssistant');
|
|
|
|
|
- props.isUsersHomepageDeletionEnabled = configManager.getConfig('security:user-homepage-deletion:isEnabled');
|
|
|
|
|
|
|
+ props.limitLearnablePageCountPerAssistant = configManager.getConfig(
|
|
|
|
|
+ 'openai:limitLearnablePageCountPerAssistant',
|
|
|
|
|
+ );
|
|
|
|
|
+ props.isUsersHomepageDeletionEnabled = configManager.getConfig(
|
|
|
|
|
+ 'security:user-homepage-deletion:isEnabled',
|
|
|
|
|
+ );
|
|
|
props.isSearchServiceConfigured = searchService.isConfigured;
|
|
props.isSearchServiceConfigured = searchService.isConfigured;
|
|
|
props.isSearchServiceReachable = searchService.isReachable;
|
|
props.isSearchServiceReachable = searchService.isReachable;
|
|
|
- props.isSearchScopeChildrenAsDefault = configManager.getConfig('customize:isSearchScopeChildrenAsDefault');
|
|
|
|
|
- props.elasticsearchMaxBodyLengthToIndex = configManager.getConfig('app:elasticsearchMaxBodyLengthToIndex');
|
|
|
|
|
|
|
+ props.isSearchScopeChildrenAsDefault = configManager.getConfig(
|
|
|
|
|
+ 'customize:isSearchScopeChildrenAsDefault',
|
|
|
|
|
+ );
|
|
|
|
|
+ props.elasticsearchMaxBodyLengthToIndex = configManager.getConfig(
|
|
|
|
|
+ 'app:elasticsearchMaxBodyLengthToIndex',
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- props.isRomUserAllowedToComment = configManager.getConfig('security:isRomUserAllowedToComment');
|
|
|
|
|
|
|
+ props.isRomUserAllowedToComment = configManager.getConfig(
|
|
|
|
|
+ 'security:isRomUserAllowedToComment',
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
props.isSlackConfigured = slackIntegrationService.isSlackConfigured;
|
|
props.isSlackConfigured = slackIntegrationService.isSlackConfigured;
|
|
|
// props.isMailerSetup = mailService.isMailerSetup;
|
|
// props.isMailerSetup = mailService.isMailerSetup;
|
|
@@ -595,50 +762,90 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
|
|
|
props.drawioUri = configManager.getConfig('app:drawioUri');
|
|
props.drawioUri = configManager.getConfig('app:drawioUri');
|
|
|
// props.highlightJsStyle = configManager.getConfig('customize:highlightJsStyle');
|
|
// props.highlightJsStyle = configManager.getConfig('customize:highlightJsStyle');
|
|
|
props.isAllReplyShown = configManager.getConfig('customize:isAllReplyShown');
|
|
props.isAllReplyShown = configManager.getConfig('customize:isAllReplyShown');
|
|
|
- props.showPageSideAuthors = configManager.getConfig('customize:showPageSideAuthors');
|
|
|
|
|
- props.isContainerFluid = configManager.getConfig('customize:isContainerFluid');
|
|
|
|
|
- props.isEnabledStaleNotification = configManager.getConfig('customize:isEnabledStaleNotification');
|
|
|
|
|
- props.disableLinkSharing = configManager.getConfig('security:disableLinkSharing');
|
|
|
|
|
|
|
+ props.showPageSideAuthors = configManager.getConfig(
|
|
|
|
|
+ 'customize:showPageSideAuthors',
|
|
|
|
|
+ );
|
|
|
|
|
+ props.isContainerFluid = configManager.getConfig(
|
|
|
|
|
+ 'customize:isContainerFluid',
|
|
|
|
|
+ );
|
|
|
|
|
+ props.isEnabledStaleNotification = configManager.getConfig(
|
|
|
|
|
+ 'customize:isEnabledStaleNotification',
|
|
|
|
|
+ );
|
|
|
|
|
+ props.disableLinkSharing = configManager.getConfig(
|
|
|
|
|
+ 'security:disableLinkSharing',
|
|
|
|
|
+ );
|
|
|
props.isUploadAllFileAllowed = fileUploadService.getFileUploadEnabled();
|
|
props.isUploadAllFileAllowed = fileUploadService.getFileUploadEnabled();
|
|
|
props.isUploadEnabled = fileUploadService.getIsUploadable();
|
|
props.isUploadEnabled = fileUploadService.getIsUploadable();
|
|
|
// TODO: remove growiCloudUri condition when bulk export can be relased for GROWI.cloud (https://redmine.weseek.co.jp/issues/163220)
|
|
// TODO: remove growiCloudUri condition when bulk export can be relased for GROWI.cloud (https://redmine.weseek.co.jp/issues/163220)
|
|
|
- props.isBulkExportPagesEnabled = configManager.getConfig('app:isBulkExportPagesEnabled') && configManager.getConfig('app:growiCloudUri') == null;
|
|
|
|
|
- props.isPdfBulkExportEnabled = configManager.getConfig('app:pageBulkExportPdfConverterUri') != null;
|
|
|
|
|
-
|
|
|
|
|
- props.isLocalAccountRegistrationEnabled = passportService.isLocalStrategySetup
|
|
|
|
|
- && configManager.getConfig('security:registrationMode') !== RegistrationMode.CLOSED;
|
|
|
|
|
-
|
|
|
|
|
- props.adminPreferredIndentSize = configManager.getConfig('markdown:adminPreferredIndentSize');
|
|
|
|
|
- props.isIndentSizeForced = configManager.getConfig('markdown:isIndentSizeForced');
|
|
|
|
|
|
|
+ props.isBulkExportPagesEnabled =
|
|
|
|
|
+ configManager.getConfig('app:isBulkExportPagesEnabled') &&
|
|
|
|
|
+ configManager.getConfig('app:growiCloudUri') == null;
|
|
|
|
|
+ props.isPdfBulkExportEnabled =
|
|
|
|
|
+ configManager.getConfig('app:pageBulkExportPdfConverterUri') != null;
|
|
|
|
|
+
|
|
|
|
|
+ props.isLocalAccountRegistrationEnabled =
|
|
|
|
|
+ passportService.isLocalStrategySetup &&
|
|
|
|
|
+ configManager.getConfig('security:registrationMode') !==
|
|
|
|
|
+ RegistrationMode.CLOSED;
|
|
|
|
|
+
|
|
|
|
|
+ props.adminPreferredIndentSize = configManager.getConfig(
|
|
|
|
|
+ 'markdown:adminPreferredIndentSize',
|
|
|
|
|
+ );
|
|
|
|
|
+ props.isIndentSizeForced = configManager.getConfig(
|
|
|
|
|
+ 'markdown:isIndentSizeForced',
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- props.isEnabledAttachTitleHeader = configManager.getConfig('customize:isEnabledAttachTitleHeader');
|
|
|
|
|
|
|
+ props.isEnabledAttachTitleHeader = configManager.getConfig(
|
|
|
|
|
+ 'customize:isEnabledAttachTitleHeader',
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
props.sidebarConfig = {
|
|
props.sidebarConfig = {
|
|
|
- isSidebarCollapsedMode: configManager.getConfig('customize:isSidebarCollapsedMode'),
|
|
|
|
|
- isSidebarClosedAtDockMode: configManager.getConfig('customize:isSidebarClosedAtDockMode'),
|
|
|
|
|
|
|
+ isSidebarCollapsedMode: configManager.getConfig(
|
|
|
|
|
+ 'customize:isSidebarCollapsedMode',
|
|
|
|
|
+ ),
|
|
|
|
|
+ isSidebarClosedAtDockMode: configManager.getConfig(
|
|
|
|
|
+ 'customize:isSidebarClosedAtDockMode',
|
|
|
|
|
+ ),
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
props.rendererConfig = {
|
|
props.rendererConfig = {
|
|
|
- isEnabledLinebreaks: configManager.getConfig('markdown:isEnabledLinebreaks'),
|
|
|
|
|
- isEnabledLinebreaksInComments: configManager.getConfig('markdown:isEnabledLinebreaksInComments'),
|
|
|
|
|
|
|
+ isEnabledLinebreaks: configManager.getConfig(
|
|
|
|
|
+ 'markdown:isEnabledLinebreaks',
|
|
|
|
|
+ ),
|
|
|
|
|
+ isEnabledLinebreaksInComments: configManager.getConfig(
|
|
|
|
|
+ 'markdown:isEnabledLinebreaksInComments',
|
|
|
|
|
+ ),
|
|
|
isEnabledMarp: configManager.getConfig('customize:isEnabledMarp'),
|
|
isEnabledMarp: configManager.getConfig('customize:isEnabledMarp'),
|
|
|
- adminPreferredIndentSize: configManager.getConfig('markdown:adminPreferredIndentSize'),
|
|
|
|
|
|
|
+ adminPreferredIndentSize: configManager.getConfig(
|
|
|
|
|
+ 'markdown:adminPreferredIndentSize',
|
|
|
|
|
+ ),
|
|
|
isIndentSizeForced: configManager.getConfig('markdown:isIndentSizeForced'),
|
|
isIndentSizeForced: configManager.getConfig('markdown:isIndentSizeForced'),
|
|
|
|
|
|
|
|
drawioUri: configManager.getConfig('app:drawioUri'),
|
|
drawioUri: configManager.getConfig('app:drawioUri'),
|
|
|
plantumlUri: configManager.getConfig('app:plantumlUri'),
|
|
plantumlUri: configManager.getConfig('app:plantumlUri'),
|
|
|
|
|
|
|
|
// XSS Options
|
|
// XSS Options
|
|
|
- isEnabledXssPrevention: configManager.getConfig('markdown:rehypeSanitize:isEnabledPrevention'),
|
|
|
|
|
|
|
+ isEnabledXssPrevention: configManager.getConfig(
|
|
|
|
|
+ 'markdown:rehypeSanitize:isEnabledPrevention',
|
|
|
|
|
+ ),
|
|
|
sanitizeType: configManager.getConfig('markdown:rehypeSanitize:option'),
|
|
sanitizeType: configManager.getConfig('markdown:rehypeSanitize:option'),
|
|
|
- customTagWhitelist: configManager.getConfig('markdown:rehypeSanitize:tagNames'),
|
|
|
|
|
- customAttrWhitelist: configManager.getConfig('markdown:rehypeSanitize:attributes') != null
|
|
|
|
|
- ? JSON.parse(configManager.getConfig('markdown:rehypeSanitize:attributes'))
|
|
|
|
|
- : undefined,
|
|
|
|
|
- highlightJsStyleBorder: configManager.getConfig('customize:highlightJsStyleBorder'),
|
|
|
|
|
|
|
+ customTagWhitelist: configManager.getConfig(
|
|
|
|
|
+ 'markdown:rehypeSanitize:tagNames',
|
|
|
|
|
+ ),
|
|
|
|
|
+ customAttrWhitelist:
|
|
|
|
|
+ configManager.getConfig('markdown:rehypeSanitize:attributes') != null
|
|
|
|
|
+ ? JSON.parse(
|
|
|
|
|
+ configManager.getConfig('markdown:rehypeSanitize:attributes'),
|
|
|
|
|
+ )
|
|
|
|
|
+ : undefined,
|
|
|
|
|
+ highlightJsStyleBorder: configManager.getConfig(
|
|
|
|
|
+ 'customize:highlightJsStyleBorder',
|
|
|
|
|
+ ),
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- props.ssrMaxRevisionBodyLength = configManager.getConfig('app:ssrMaxRevisionBodyLength');
|
|
|
|
|
|
|
+ props.ssrMaxRevisionBodyLength = configManager.getConfig(
|
|
|
|
|
+ 'app:ssrMaxRevisionBodyLength',
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -647,8 +854,16 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
|
|
|
* @param props
|
|
* @param props
|
|
|
* @param namespacesRequired
|
|
* @param namespacesRequired
|
|
|
*/
|
|
*/
|
|
|
-async function injectNextI18NextConfigurations(context: GetServerSidePropsContext, props: Props, namespacesRequired?: string[] | undefined): Promise<void> {
|
|
|
|
|
- const nextI18NextConfig = await getNextI18NextConfig(serverSideTranslations, context, namespacesRequired);
|
|
|
|
|
|
|
+async function injectNextI18NextConfigurations(
|
|
|
|
|
+ context: GetServerSidePropsContext,
|
|
|
|
|
+ props: Props,
|
|
|
|
|
+ namespacesRequired?: string[] | undefined,
|
|
|
|
|
+): Promise<void> {
|
|
|
|
|
+ const nextI18NextConfig = await getNextI18NextConfig(
|
|
|
|
|
+ serverSideTranslations,
|
|
|
|
|
+ context,
|
|
|
|
|
+ namespacesRequired,
|
|
|
|
|
+ );
|
|
|
props._nextI18Next = nextI18NextConfig._nextI18Next;
|
|
props._nextI18Next = nextI18NextConfig._nextI18Next;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -668,7 +883,9 @@ const getAction = (props: Props): SupportedActionType => {
|
|
|
return SupportedAction.ACTION_PAGE_VIEW;
|
|
return SupportedAction.ACTION_PAGE_VIEW;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
|
|
|
|
|
|
|
+export const getServerSideProps: GetServerSideProps = async (
|
|
|
|
|
+ context: GetServerSidePropsContext,
|
|
|
|
|
+) => {
|
|
|
const req = context.req as CrowiRequest;
|
|
const req = context.req as CrowiRequest;
|
|
|
const { user } = req;
|
|
const { user } = req;
|
|
|
|
|
|
|
@@ -697,12 +914,10 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
await injectPageData(context, props);
|
|
await injectPageData(context, props);
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
|
|
+ } catch (err) {
|
|
|
if (err instanceof MultiplePagesHitsError) {
|
|
if (err instanceof MultiplePagesHitsError) {
|
|
|
props.isIdenticalPathPage = true;
|
|
props.isIdenticalPathPage = true;
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
|
|
+ } else {
|
|
|
throw err;
|
|
throw err;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|