|
|
@@ -1,5 +1,5 @@
|
|
|
-import React, { ReactNode, useEffect } from 'react';
|
|
|
-
|
|
|
+import type { ReactNode } from 'react';
|
|
|
+import React, { useEffect } from 'react';
|
|
|
|
|
|
import EventEmitter from 'events';
|
|
|
|
|
|
@@ -23,6 +23,7 @@ import superjson from 'superjson';
|
|
|
import { useEditorModeClassName } from '~/client/services/layout';
|
|
|
import { PageView } from '~/components/Page/PageView';
|
|
|
import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript';
|
|
|
+import { SupportedAction, type SupportedActionType } from '~/interfaces/activity';
|
|
|
import type { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
import type { EditorConfig } from '~/interfaces/editor-settings';
|
|
|
import type { IPageGrantData } from '~/interfaces/page';
|
|
|
@@ -58,7 +59,7 @@ import { DisplaySwitcher } from '../components/Page/DisplaySwitcher';
|
|
|
import type { NextPageWithLayout } from './_app.page';
|
|
|
import type { CommonProps } from './utils/commons';
|
|
|
import {
|
|
|
- getNextI18NextConfig, getServerSideCommonProps, generateCustomTitleForPage, useInitSidebarConfig, skipSSR,
|
|
|
+ getNextI18NextConfig, getServerSideCommonProps, generateCustomTitleForPage, useInitSidebarConfig, skipSSR, addActivity,
|
|
|
} from './utils/commons';
|
|
|
|
|
|
|
|
|
@@ -596,6 +597,22 @@ async function injectNextI18NextConfigurations(context: GetServerSidePropsContex
|
|
|
props._nextI18Next = nextI18NextConfig._nextI18Next;
|
|
|
}
|
|
|
|
|
|
+const getAction = (props: Props): SupportedActionType => {
|
|
|
+ if (props.isNotCreatable) {
|
|
|
+ return SupportedAction.ACTION_PAGE_NOT_CREATABLE;
|
|
|
+ }
|
|
|
+ if (props.isForbidden) {
|
|
|
+ return SupportedAction.ACTION_PAGE_FORBIDDEN;
|
|
|
+ }
|
|
|
+ if (props.isNotFound) {
|
|
|
+ return SupportedAction.ACTION_PAGE_NOT_FOUND;
|
|
|
+ }
|
|
|
+ if (pagePathUtils.isUsersHomepage(props.pageWithMeta?.data.path ?? '')) {
|
|
|
+ return SupportedAction.ACTION_PAGE_USER_HOME_VIEW;
|
|
|
+ }
|
|
|
+ return SupportedAction.ACTION_PAGE_VIEW;
|
|
|
+};
|
|
|
+
|
|
|
export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
|
|
|
const req = context.req as CrowiRequest;
|
|
|
const { user } = req;
|
|
|
@@ -639,6 +656,7 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
injectServerConfigurations(context, props);
|
|
|
await injectNextI18NextConfigurations(context, props, ['translation']);
|
|
|
|
|
|
+ addActivity(context, getAction(props));
|
|
|
return {
|
|
|
props,
|
|
|
};
|