|
@@ -14,23 +14,17 @@ import { useRouter } from 'next/router';
|
|
|
import { BasicLayout } from '~/components/Layout/BasicLayout';
|
|
import { BasicLayout } from '~/components/Layout/BasicLayout';
|
|
|
import { CrowiRequest } from '~/interfaces/crowi-request';
|
|
import { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
import type { RendererConfig } from '~/interfaces/services/renderer';
|
|
import type { RendererConfig } from '~/interfaces/services/renderer';
|
|
|
-import { ISidebarConfig } from '~/interfaces/sidebar-config';
|
|
|
|
|
-import { IUserUISettings } from '~/interfaces/user-ui-settings';
|
|
|
|
|
-import { UserUISettingsModel } from '~/server/models/user-ui-settings';
|
|
|
|
|
import {
|
|
import {
|
|
|
useCurrentUser, useIsSearchPage,
|
|
useCurrentUser, useIsSearchPage,
|
|
|
useIsSearchServiceConfigured, useIsSearchServiceReachable,
|
|
useIsSearchServiceConfigured, useIsSearchServiceReachable,
|
|
|
useCsrfToken, useIsSearchScopeChildrenAsDefault,
|
|
useCsrfToken, useIsSearchScopeChildrenAsDefault,
|
|
|
useRegistrationWhiteList, useShowPageLimitationXL, useRendererConfig,
|
|
useRegistrationWhiteList, useShowPageLimitationXL, useRendererConfig,
|
|
|
} from '~/stores/context';
|
|
} from '~/stores/context';
|
|
|
-import {
|
|
|
|
|
- usePreferDrawerModeByUser, usePreferDrawerModeOnEditByUser, useSidebarCollapsed, useCurrentSidebarContents, useCurrentProductNavWidth,
|
|
|
|
|
-} from '~/stores/ui';
|
|
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import { NextPageWithLayout } from '../_app.page';
|
|
import { NextPageWithLayout } from '../_app.page';
|
|
|
import {
|
|
import {
|
|
|
- CommonProps, getNextI18NextConfig, getServerSideCommonProps, generateCustomTitle, useInitSidebarConfig,
|
|
|
|
|
|
|
+ CommonProps, getNextI18NextConfig, getServerSideCommonProps, generateCustomTitle,
|
|
|
} from '../utils/commons';
|
|
} from '../utils/commons';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -40,8 +34,6 @@ type Props = CommonProps & {
|
|
|
isSearchServiceConfigured: boolean,
|
|
isSearchServiceConfigured: boolean,
|
|
|
isSearchServiceReachable: boolean,
|
|
isSearchServiceReachable: boolean,
|
|
|
isSearchScopeChildrenAsDefault: boolean,
|
|
isSearchScopeChildrenAsDefault: boolean,
|
|
|
- userUISettings?: IUserUISettings
|
|
|
|
|
- sidebarConfig: ISidebarConfig,
|
|
|
|
|
rendererConfig: RendererConfig,
|
|
rendererConfig: RendererConfig,
|
|
|
showPageLimitationXL: number,
|
|
showPageLimitationXL: number,
|
|
|
|
|
|
|
@@ -97,9 +89,6 @@ const MePage: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
// commons
|
|
// commons
|
|
|
useCsrfToken(props.csrfToken);
|
|
useCsrfToken(props.csrfToken);
|
|
|
|
|
|
|
|
- // init sidebar config with UserUISettings and sidebarConfig
|
|
|
|
|
- useInitSidebarConfig(props.sidebarConfig, props.userUISettings);
|
|
|
|
|
-
|
|
|
|
|
// page
|
|
// page
|
|
|
useIsSearchServiceConfigured(props.isSearchServiceConfigured);
|
|
useIsSearchServiceConfigured(props.isSearchServiceConfigured);
|
|
|
useIsSearchServiceReachable(props.isSearchServiceReachable);
|
|
useIsSearchServiceReachable(props.isSearchServiceReachable);
|
|
@@ -139,17 +128,6 @@ MePage.getLayout = function getLayout(page) {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-async function injectUserUISettings(context: GetServerSidePropsContext, props: Props): Promise<void> {
|
|
|
|
|
- const req = context.req as CrowiRequest<IUserHasId & any>;
|
|
|
|
|
- const { user } = req;
|
|
|
|
|
- const UserUISettings = mongooseModel('UserUISettings') as UserUISettingsModel;
|
|
|
|
|
-
|
|
|
|
|
- const userUISettings = user == null ? null : await UserUISettings.findOne({ user: user._id }).exec();
|
|
|
|
|
- if (userUISettings != null) {
|
|
|
|
|
- props.userUISettings = userUISettings.toObject();
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
async function injectServerConfigurations(context: GetServerSidePropsContext, props: Props): Promise<void> {
|
|
async function injectServerConfigurations(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;
|
|
@@ -221,7 +199,6 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
props.currentUser = userData.toObject();
|
|
props.currentUser = userData.toObject();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- await injectUserUISettings(context, props);
|
|
|
|
|
await injectServerConfigurations(context, props);
|
|
await injectServerConfigurations(context, props);
|
|
|
await injectNextI18NextConfigurations(context, props, ['translation', 'admin', 'commons']);
|
|
await injectNextI18NextConfigurations(context, props, ['translation', 'admin', 'commons']);
|
|
|
|
|
|