|
|
@@ -1,64 +1,44 @@
|
|
|
-import type {
|
|
|
- NextPage, GetServerSideProps, GetServerSidePropsContext,
|
|
|
-} from 'next';
|
|
|
-import { useTranslation } from 'next-i18next';
|
|
|
+import { useHydrateAtoms } from 'jotai/utils';
|
|
|
+import type { GetServerSideProps, GetServerSidePropsContext } from 'next';
|
|
|
import dynamic from 'next/dynamic';
|
|
|
-import Head from 'next/head';
|
|
|
|
|
|
-import type { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
-import type { CommonProps } from '~/pages/utils/commons';
|
|
|
-import { generateCustomTitle } from '~/pages/utils/commons';
|
|
|
-import { useIsSearchServiceReachable, useCurrentUser } from '~/stores-universal/context';
|
|
|
+import { isSearchScopeChildrenAsDefaultAtom, isSearchServiceConfiguredAtom, isSearchServiceReachableAtom } from '~/states/server-configurations';
|
|
|
+
|
|
|
+import type { NextPageWithLayout } from '../_app.page';
|
|
|
+import type { SearchConfigurationProps } from '../basic-layout-page';
|
|
|
+import { getServerSideSearchConfigurationProps } from '../basic-layout-page/get-server-side-props/search-configurations';
|
|
|
+import { mergeGetServerSidePropsResults } from '../utils/server-side-props';
|
|
|
+
|
|
|
+import type { AdminCommonProps } from './_shared';
|
|
|
+import { createAdminPageLayout, getServerSideAdminCommonProps } from './_shared';
|
|
|
|
|
|
-import { retrieveServerSideProps } from '../../utils/admin-page-util';
|
|
|
|
|
|
-const AdminLayout = dynamic(() => import('~/components/Layout/AdminLayout'), { ssr: false });
|
|
|
const FullTextSearchManagement = dynamic(
|
|
|
() => import('~/client/components/Admin/FullTextSearchManagement').then(mod => mod.FullTextSearchManagement), { ssr: false },
|
|
|
);
|
|
|
-const ForbiddenPage = dynamic(() => import('~/client/components/Admin/ForbiddenPage').then(mod => mod.ForbiddenPage), { ssr: false });
|
|
|
-
|
|
|
-
|
|
|
-type Props = CommonProps & {
|
|
|
- isSearchServiceReachable: boolean,
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-const AdminFullTextSearchManagementPage: NextPage<Props> = (props) => {
|
|
|
- const { t } = useTranslation('admin');
|
|
|
- useCurrentUser(props.currentUser ?? null);
|
|
|
- useIsSearchServiceReachable(props.isSearchServiceReachable);
|
|
|
|
|
|
- const title = t('full_text_search_management.full_text_search_management');
|
|
|
- const headTitle = generateCustomTitle(props, title);
|
|
|
+type Props = AdminCommonProps & SearchConfigurationProps;
|
|
|
|
|
|
- if (props.isAccessDeniedForNonAdminUser) {
|
|
|
- return <ForbiddenPage />;
|
|
|
- }
|
|
|
+const AdminFullTextSearchManagementPage: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
+ // hydrate
|
|
|
+ useHydrateAtoms([
|
|
|
+ [isSearchServiceConfiguredAtom, props.searchConfig.isSearchServiceConfigured],
|
|
|
+ [isSearchServiceReachableAtom, props.searchConfig.isSearchServiceReachable],
|
|
|
+ [isSearchScopeChildrenAsDefaultAtom, props.searchConfig.isSearchScopeChildrenAsDefault],
|
|
|
+ ], { dangerouslyForceHydrate: true });
|
|
|
|
|
|
- return (
|
|
|
- <AdminLayout componentTitle={title}>
|
|
|
- <Head>
|
|
|
- <title>{headTitle}</title>
|
|
|
- </Head>
|
|
|
- <FullTextSearchManagement />
|
|
|
- </AdminLayout>
|
|
|
- );
|
|
|
-};
|
|
|
-
|
|
|
-const injectServerConfigurations = async(context: GetServerSidePropsContext, props: Props): Promise<void> => {
|
|
|
- const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
- const { crowi } = req;
|
|
|
- const { searchService } = crowi;
|
|
|
-
|
|
|
- props.isSearchServiceReachable = searchService.isReachable;
|
|
|
+ return <FullTextSearchManagement />;
|
|
|
};
|
|
|
|
|
|
+AdminFullTextSearchManagementPage.getLayout = createAdminPageLayout<Props>({
|
|
|
+ title: (_p, t) => t('full_text_search_management.full_text_search_management'),
|
|
|
+});
|
|
|
|
|
|
-export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
|
|
|
- const props = await retrieveServerSideProps(context, injectServerConfigurations);
|
|
|
- return props;
|
|
|
+export const getServerSideProps: GetServerSideProps<Props> = async(context: GetServerSidePropsContext) => {
|
|
|
+ return mergeGetServerSidePropsResults(
|
|
|
+ await getServerSideAdminCommonProps(context),
|
|
|
+ await getServerSideSearchConfigurationProps(context),
|
|
|
+ );
|
|
|
};
|
|
|
|
|
|
-
|
|
|
export default AdminFullTextSearchManagementPage;
|