|
|
@@ -1,6 +1,6 @@
|
|
|
import { allOrigin } from '@growi/core';
|
|
|
import type {
|
|
|
- IPage, IUser, IUserHasId, Lang,
|
|
|
+ IPage, IUser, IUserHasId,
|
|
|
} from '@growi/core';
|
|
|
import { ErrorV3 } from '@growi/core/dist/models';
|
|
|
import { isCreatablePage, isUserPage, isUsersHomepage } from '@growi/core/dist/utils/page-path-utils';
|
|
|
@@ -23,7 +23,6 @@ import {
|
|
|
import type { PageDocument, PageModel } from '~/server/models/page';
|
|
|
import PageTagRelation from '~/server/models/page-tag-relation';
|
|
|
import { configManager } from '~/server/service/config-manager';
|
|
|
-import { determineLocale } from '~/utils/locale-utils';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
import { apiV3FormValidator } from '../../../middlewares/apiv3-form-validator';
|
|
|
@@ -43,10 +42,8 @@ async function generateUntitledPath(parentPath: string, basePathname: string, in
|
|
|
return path;
|
|
|
}
|
|
|
|
|
|
-async function determinePath(locale: Lang, _parentPath?: string, _path?: string, optionalParentPath?: string): Promise<string> {
|
|
|
- // const t = i18n?.getFixedT(locale);
|
|
|
- // const basePathname = t?.('create_page.untitled') || 'Undefined';
|
|
|
- const basePathname = 'Undefined';
|
|
|
+async function determinePath(t: any, _parentPath?: string, _path?: string, optionalParentPath?: string): Promise<string> {
|
|
|
+ const basePathname = t('create_page.untitled');
|
|
|
|
|
|
if (_path != null) {
|
|
|
const path = normalizePath(_path);
|
|
|
@@ -92,6 +89,10 @@ type ReqBody = IApiv3PageCreateParams
|
|
|
|
|
|
interface CreatePageRequest extends Request<undefined, ApiV3Response, ReqBody> {
|
|
|
user: IUserHasId,
|
|
|
+
|
|
|
+ // TODO: remove req.t
|
|
|
+ // https://redmine.weseek.co.jp/issues/125884
|
|
|
+ t: any
|
|
|
}
|
|
|
|
|
|
type CreatePageHandlersFactory = (crowi: Crowi) => RequestHandler[];
|
|
|
@@ -214,9 +215,7 @@ export const createPageHandlersFactory: CreatePageHandlersFactory = (crowi) => {
|
|
|
try {
|
|
|
const { path, parentPath, optionalParentPath } = req.body;
|
|
|
|
|
|
- const locale = determineLocale(req.headers, req.user);
|
|
|
-
|
|
|
- pathToCreate = await determinePath(locale, parentPath, path, optionalParentPath);
|
|
|
+ pathToCreate = await determinePath(req.t, parentPath, path, optionalParentPath);
|
|
|
}
|
|
|
catch (err) {
|
|
|
return res.apiv3Err(new ErrorV3(err.toString(), 'could_not_create_page'));
|